Content-Length: 4430 | pFad | http://github.com/gitpython-developers/GitPython/pull/1774.patch
thub.com
From b12a54a2fc7e988667f95145833a0dc8402b084d Mon Sep 17 00:00:00 2001
From: Eliah Kagan
Date: Mon, 18 Dec 2023 19:51:34 -0500
Subject: [PATCH 1/2] Use Path.touch to create files for rmtree tests
It's not necessary to use `write_bytes(b"")`, because pathlib.Path
has `touch()`.
---
test/test_util.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/test_util.py b/test/test_util.py
index 6616e1067..9408a91a0 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -46,7 +46,7 @@ def permission_error_tmpdir(tmp_path):
"""Fixture to test permissions errors in situations where they are not overcome."""
td = tmp_path / "testdir"
td.mkdir()
- (td / "x").write_bytes(b"")
+ (td / "x").touch()
# Set up PermissionError on Windows, where we can't delete read-only files.
(td / "x").chmod(stat.S_IRUSR)
@@ -73,7 +73,7 @@ def test_deletes_nested_dir_with_files(self, tmp_path):
td / "s" / "y",
td / "s" / "z",
):
- f.write_bytes(b"")
+ f.touch()
try:
rmtree(td)
@@ -95,7 +95,7 @@ def test_deletes_dir_with_readonly_files(self, tmp_path):
for d in td, td / "sub":
d.mkdir()
for f in td / "x", td / "sub" / "y":
- f.write_bytes(b"")
+ f.touch()
f.chmod(0)
try:
@@ -115,7 +115,7 @@ def test_avoids_changing_permissions_outside_tree(self, tmp_path):
dir1 = tmp_path / "dir1"
dir1.mkdir()
- (dir1 / "file").write_bytes(b"")
+ (dir1 / "file").touch()
(dir1 / "file").chmod(stat.S_IRUSR)
old_mode = (dir1 / "file").stat().st_mode
From 6a8ed70a6003c13800d908ab055038eb61ba4ce9 Mon Sep 17 00:00:00 2001
From: Eliah Kagan
Date: Mon, 18 Dec 2023 20:00:56 -0500
Subject: [PATCH 2/2] Run test_env_vars_for_windows_tests only on Windows
This skips the tests of how the HIDE_WINDOWS_KNOWN_ERRORS and
HIDE_WINDOWS_FREEZE_ERRORS environment variables affect the
same-named attributes of git.util, except when testing on Windows.
These are parsed only to ever set a True value on Windows, but
checking that this is the case is less important ever since
git.util.rmtree was changed to not check HIDE_WINDOWS_KNOWN_ERRORS
on other systems (and this is covered in other tests).
Setting the variables to True on non-Windows systems would still
have a bad effect on the tests themselves, some of which use them
as skip or xfail conditions separate from the skipping logic in
git.util.rmtree. However, this is effectively using them as part of
the test suite (which they were initially meant for and which they
may eventually go back to being, for #790), where they would not
ordinarily have tests.
The benefit and motivation for running these tests only on Windows
is that the tests can be simplified, so that their parameter sets
are no longer confusing. That change is also made here.
---
test/test_util.py | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/test/test_util.py b/test/test_util.py
index 9408a91a0..f3769088c 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -207,24 +207,28 @@ def _run_parse(name, value):
)
return ast.literal_eval(output)
+ @pytest.mark.skipif(
+ os.name != "nt",
+ reason="These environment variables are only used on Windows.",
+ )
@pytest.mark.parametrize(
"env_var_value, expected_truth_value",
[
- (None, os.name == "nt"), # True on Windows when the environment variable is unset.
+ (None, True), # When the environment variable is unset.
("", False),
(" ", False),
("0", False),
- ("1", os.name == "nt"),
+ ("1", True),
("false", False),
- ("true", os.name == "nt"),
+ ("true", True),
("False", False),
- ("True", os.name == "nt"),
+ ("True", True),
("no", False),
- ("yes", os.name == "nt"),
+ ("yes", True),
("NO", False),
- ("YES", os.name == "nt"),
+ ("YES", True),
(" no ", False),
- (" yes ", os.name == "nt"),
+ (" yes ", True),
],
)
@pytest.mark.parametrize(
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/gitpython-developers/GitPython/pull/1774.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy