Commit 9c40ab88 authored by Jason R. Coombs's avatar Jason R. Coombs

Rewrite TestSdistTest setup/teardown_method as pytest fixture.

parent 47aab652
...@@ -91,30 +91,29 @@ fail_on_latin1_encoded_filenames = pytest.mark.xfail( ...@@ -91,30 +91,29 @@ fail_on_latin1_encoded_filenames = pytest.mark.xfail(
) )
def touch(path):
path.write_text('', encoding='utf-8')
class TestSdistTest: class TestSdistTest:
def setup_method(self, method): @pytest.fixture(autouse=True)
self.temp_dir = tempfile.mkdtemp() def source_dir(self, tmpdir):
with open(os.path.join(self.temp_dir, 'setup.py'), 'w') as f: self.temp_dir = str(tmpdir)
f.write(SETUP_PY) (tmpdir / 'setup.py').write_text(SETUP_PY, encoding='utf-8')
# Set up the rest of the test package # Set up the rest of the test package
test_pkg = os.path.join(self.temp_dir, 'sdist_test') test_pkg = tmpdir / 'sdist_test'
os.mkdir(test_pkg) test_pkg.mkdir()
data_folder = os.path.join(self.temp_dir, "d") data_folder = tmpdir / 'd'
os.mkdir(data_folder) data_folder.mkdir()
# *.rst was not included in package_data, so c.rst should not be # *.rst was not included in package_data, so c.rst should not be
# automatically added to the manifest when not under version control # automatically added to the manifest when not under version control
for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst', for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst']:
os.path.join(data_folder, "e.dat")]: touch(test_pkg / fname)
# Just touch the files; their contents are irrelevant touch(data_folder / 'e.dat')
open(os.path.join(test_pkg, fname), 'w').close()
self.old_cwd = os.getcwd()
os.chdir(self.temp_dir)
def teardown_method(self, method): with tmpdir.as_cwd():
os.chdir(self.old_cwd) yield
shutil.rmtree(self.temp_dir)
def test_package_data_in_sdist(self): def test_package_data_in_sdist(self):
"""Regression test for pull request #4: ensures that files listed in """Regression test for pull request #4: ensures that files listed in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment