summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-09-24 22:39:02 -0400
committerJason R. Coombs <jaraco@jaraco.com>2022-09-24 22:39:02 -0400
commit3980ab773c585f927bec6b3fea3243c09bf54a54 (patch)
tree91233620df85308f43dad8f5a98b4e2d86d1c1fa
parentbe4c242cf4d3a278dac556f0f6e777796088fb8b (diff)
downloadpython-setuptools-git-3980ab773c585f927bec6b3fea3243c09bf54a54.tar.gz
Prefer a temp_cwd fixture to reduce indentation.
-rw-r--r--conftest.py6
-rw-r--r--distutils/tests/py38compat.py2
-rw-r--r--distutils/tests/test_filelist.py26
3 files changed, 18 insertions, 16 deletions
diff --git a/conftest.py b/conftest.py
index 57d1802d..ef3e100c 100644
--- a/conftest.py
+++ b/conftest.py
@@ -90,6 +90,12 @@ def save_cwd():
@pytest.fixture
+def temp_cwd(tmp_path):
+ with path.Path(tmp_path):
+ yield
+
+
+@pytest.fixture
def threshold_warn():
from distutils.log import set_threshold, WARN
diff --git a/distutils/tests/py38compat.py b/distutils/tests/py38compat.py
index e359ccfc..9f6bc33f 100644
--- a/distutils/tests/py38compat.py
+++ b/distutils/tests/py38compat.py
@@ -24,7 +24,6 @@ try:
skip_unless_symlink,
temp_dir,
create_empty_file,
- temp_cwd,
)
except (ModuleNotFoundError, ImportError):
from test.support import (
@@ -34,7 +33,6 @@ except (ModuleNotFoundError, ImportError):
skip_unless_symlink,
temp_dir,
create_empty_file,
- temp_cwd,
)
diff --git a/distutils/tests/test_filelist.py b/distutils/tests/test_filelist.py
index 26071820..8c1a590c 100644
--- a/distutils/tests/test_filelist.py
+++ b/distutils/tests/test_filelist.py
@@ -303,26 +303,24 @@ class TestFileList(support.LoggingSilencer):
class TestFindAll:
@os_helper.skip_unless_symlink
- def test_missing_symlink(self):
- with os_helper.temp_cwd():
- os.symlink('foo', 'bar')
- assert filelist.findall() == []
+ def test_missing_symlink(self, temp_cwd):
+ os.symlink('foo', 'bar')
+ assert filelist.findall() == []
- def test_basic_discovery(self):
+ def test_basic_discovery(self, temp_cwd):
"""
When findall is called with no parameters or with
'.' as the parameter, the dot should be omitted from
the results.
"""
- with os_helper.temp_cwd():
- os.mkdir('foo')
- file1 = os.path.join('foo', 'file1.txt')
- os_helper.create_empty_file(file1)
- os.mkdir('bar')
- file2 = os.path.join('bar', 'file2.txt')
- os_helper.create_empty_file(file2)
- expected = [file2, file1]
- assert sorted(filelist.findall()) == expected
+ os.mkdir('foo')
+ file1 = os.path.join('foo', 'file1.txt')
+ os_helper.create_empty_file(file1)
+ os.mkdir('bar')
+ file2 = os.path.join('bar', 'file2.txt')
+ os_helper.create_empty_file(file2)
+ expected = [file2, file1]
+ assert sorted(filelist.findall()) == expected
def test_non_local_discovery(self):
"""