diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2017-10-12 09:53:13 +0200 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-10-12 09:53:13 +0200 |
| commit | 9a42fe5cbc5fa73d528547a918586647f2122140 (patch) | |
| tree | 17649aacab998cd2e9fa6d7f39e88ddb6a3e0ace /setuptools/tests | |
| parent | fa5f1be3b6cc13db5d6df9dfbe90542aad6bd3c9 (diff) | |
| download | external_python_setuptools-9a42fe5cbc5fa73d528547a918586647f2122140.tar.gz external_python_setuptools-9a42fe5cbc5fa73d528547a918586647f2122140.tar.bz2 external_python_setuptools-9a42fe5cbc5fa73d528547a918586647f2122140.zip | |
Use pytest tmpdir fixture for simplicity.
Diffstat (limited to 'setuptools/tests')
| -rw-r--r-- | setuptools/tests/test_pep517.py | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/setuptools/tests/test_pep517.py b/setuptools/tests/test_pep517.py index adc155cc..07b5aada 100644 --- a/setuptools/tests/test_pep517.py +++ b/setuptools/tests/test_pep517.py @@ -45,19 +45,9 @@ class BuildBackendCaller(BuildBackendBase): return getattr(mod, name)(*args, **kw) -@contextlib.contextmanager -def enter_directory(dir, val=None): - original_dir = os.getcwd() - os.chdir(dir) - yield val - os.chdir(original_dir) - - @pytest.fixture -def build_backend(): - tmpdir = tempfile.mkdtemp() - with enter_directory(tmpdir): - setup_script = DALS(""" +def build_backend(tmpdir): + setup_script = DALS(""" from setuptools import setup setup( @@ -68,48 +58,45 @@ def build_backend(): zip_safe=False, ) """) - - build_files({ - 'setup.py': setup_script, - 'hello.py': DALS(""" - def run(): - print('hello') - """) - }) - - return enter_directory(tmpdir, BuildBackend(cwd='.')) + defn = { + 'setup.py': setup_script, + 'hello.py': DALS(""" + def run(): + print('hello') + """) + } + build_files(defn, prefix=str(tmpdir)) + with tmpdir.as_cwd(): + yield BuildBackend(cwd='.') def test_get_requires_for_build_wheel(build_backend): - with build_backend as b: - assert list(sorted(b.get_requires_for_build_wheel())) == \ - list(sorted(['six', 'setuptools', 'wheel'])) + b = build_backend + assert list(sorted(b.get_requires_for_build_wheel())) == \ + list(sorted(['six', 'setuptools', 'wheel'])) def test_build_wheel(build_backend): - with build_backend as b: - dist_dir = os.path.abspath('pip-wheel') - os.makedirs(dist_dir) - wheel_name = b.build_wheel(dist_dir) + dist_dir = os.path.abspath('pip-wheel') + os.makedirs(dist_dir) + wheel_name = build_backend.build_wheel(dist_dir) - assert os.path.isfile(os.path.join(dist_dir, wheel_name)) + assert os.path.isfile(os.path.join(dist_dir, wheel_name)) def test_build_sdist(build_backend): - with build_backend as b: - dist_dir = os.path.abspath('pip-sdist') - os.makedirs(dist_dir) - sdist_name = b.build_sdist(dist_dir) + dist_dir = os.path.abspath('pip-sdist') + os.makedirs(dist_dir) + sdist_name = build_backend.build_sdist(dist_dir) - assert os.path.isfile(os.path.join(dist_dir, sdist_name)) + assert os.path.isfile(os.path.join(dist_dir, sdist_name)) def test_prepare_metadata_for_build_wheel(build_backend): - with build_backend as b: - dist_dir = os.path.abspath('pip-dist-info') - os.makedirs(dist_dir) + dist_dir = os.path.abspath('pip-dist-info') + os.makedirs(dist_dir) - dist_info = b.prepare_metadata_for_build_wheel(dist_dir) + dist_info = build_backend.prepare_metadata_for_build_wheel(dist_dir) - assert os.path.isfile(os.path.join(dist_dir, dist_info, - 'METADATA')) + assert os.path.isfile(os.path.join(dist_dir, dist_info, + 'METADATA')) |
