diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-02 09:49:58 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-02 09:49:58 -0500 |
commit | bbb68a8b848f9dbd4d44419fdae93b5e057763e5 (patch) | |
tree | 9666672d539a35006f7e518f3bec489020601f82 /setuptools | |
parent | b14ed9cb87ba7f9aff5baecceae9ca54351a6b4e (diff) | |
download | external_python_setuptools-bbb68a8b848f9dbd4d44419fdae93b5e057763e5.tar.gz external_python_setuptools-bbb68a8b848f9dbd4d44419fdae93b5e057763e5.tar.bz2 external_python_setuptools-bbb68a8b848f9dbd4d44419fdae93b5e057763e5.zip |
Rewrite test using pytest.
Diffstat (limited to 'setuptools')
-rw-r--r-- | setuptools/tests/fixtures.py | 7 | ||||
-rw-r--r-- | setuptools/tests/test_egg_info.py | 39 |
2 files changed, 20 insertions, 26 deletions
diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py index 225c2ea3..0b1eaf5f 100644 --- a/setuptools/tests/fixtures.py +++ b/setuptools/tests/fixtures.py @@ -3,6 +3,7 @@ import pytest from . import contexts + @pytest.yield_fixture def user_override(): """ @@ -15,3 +16,9 @@ def user_override(): with mock.patch('site.USER_SITE', user_site): with contexts.save_user_site_setting(): yield + + +@pytest.yield_fixture +def tmpdir_cwd(tmpdir): + with tmpdir.as_cwd() as orig: + yield orig diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 6b4d917f..d8c3252e 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -2,22 +2,11 @@ import os import tempfile import shutil import stat -import unittest from . import environment -class TestEggInfo(unittest.TestCase): - - def setUp(self): - self.test_dir = tempfile.mkdtemp() - - self.old_cwd = os.getcwd() - os.chdir(self.test_dir) - - def tearDown(self): - os.chdir(self.old_cwd) - shutil.rmtree(self.test_dir) +class TestEggInfo: def _create_project(self): with open('setup.py', 'w') as f: @@ -33,7 +22,7 @@ class TestEggInfo(unittest.TestCase): f.write('def run():\n') f.write(" print('hello')\n") - def test_egg_base_installed_egg_info(self): + def test_egg_base_installed_egg_info(self, tmpdir_cwd): self._create_project() temp_dir = tempfile.mkdtemp(prefix='setuptools-test.') os.chmod(temp_dir, stat.S_IRWXU) @@ -54,7 +43,7 @@ class TestEggInfo(unittest.TestCase): '--install-lib', paths['lib'], '--install-scripts', paths['scripts'], '--install-data', paths['data']], - pypath=os.pathsep.join([paths['lib'], self.old_cwd]), + pypath=os.pathsep.join([paths['lib'], str(tmpdir_cwd)]), data_stream=1, env=environ) if code: @@ -63,17 +52,15 @@ class TestEggInfo(unittest.TestCase): for dirpath, dirnames, filenames in os.walk(paths['lib']): if os.path.basename(dirpath) == 'EGG-INFO': egg_info = sorted(filenames) - self.assertEqual( - egg_info, - ['PKG-INFO', - 'SOURCES.txt', - 'dependency_links.txt', - 'entry_points.txt', - 'not-zip-safe', - 'top_level.txt']) + + expected = [ + 'PKG-INFO', + 'SOURCES.txt', + 'dependency_links.txt', + 'entry_points.txt', + 'not-zip-safe', + 'top_level.txt', + ] + assert egg_info == expected finally: shutil.rmtree(temp_dir) - - -def test_suite(): - return unittest.defaultTestLoader.loadTestsFromName(__name__) |