diff options
| author | mergify[bot] <mergify[bot]@users.noreply.github.com> | 2019-04-24 00:04:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-24 00:04:55 +0000 |
| commit | 83c667e0b2a98193851c07115d1af65011ed0fb6 (patch) | |
| tree | 19a542b1f9bd4edde2e98bf628d1b5e511d7701a /setuptools/tests | |
| parent | 97d7563915b6e2ad8a638e988361357709a83bda (diff) | |
| parent | 812a97c2a90f67a551b6b158e08fe466748d7902 (diff) | |
| download | external_python_setuptools-83c667e0b2a98193851c07115d1af65011ed0fb6.tar.gz external_python_setuptools-83c667e0b2a98193851c07115d1af65011ed0fb6.tar.bz2 external_python_setuptools-83c667e0b2a98193851c07115d1af65011ed0fb6.zip | |
Merge pull request #1750 from benoit-pierre/fix_1749
build_meta: fix 2 issues with `build_wheel` / `build_sdist`
Diffstat (limited to 'setuptools/tests')
| -rw-r--r-- | setuptools/tests/test_build_meta.py | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index 7612ebd7..e1efe561 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -157,9 +157,10 @@ class TestBuildMetaBackend: assert os.path.isfile(os.path.join(dist_dir, wheel_name)) - def test_build_wheel_with_existing_wheel_file_present(self, tmpdir_cwd): - # Building a wheel should still succeed if there's already a wheel - # in the wheel directory + @pytest.mark.parametrize('build_type', ('wheel', 'sdist')) + def test_build_with_existing_file_present(self, build_type, tmpdir_cwd): + # Building a sdist/wheel should still succeed if there's + # already a sdist/wheel in the destination directory. files = { 'setup.py': "from setuptools import setup\nsetup()", 'VERSION': "0.0.1", @@ -177,28 +178,31 @@ class TestBuildMetaBackend: build_files(files) - dist_dir = os.path.abspath('pip-wheel-preexisting') - os.makedirs(dist_dir) + dist_dir = os.path.abspath('preexisting-' + build_type) - # make first wheel build_backend = self.get_build_backend() - wheel_one = build_backend.build_wheel(dist_dir) + build_method = getattr(build_backend, 'build_' + build_type) + + # Build a first sdist/wheel. + # Note: this also check the destination directory is + # successfully created if it does not exist already. + first_result = build_method(dist_dir) - # change version + # Change version. with open("VERSION", "wt") as version_file: version_file.write("0.0.2") - # make *second* wheel - wheel_two = self.get_build_backend().build_wheel(dist_dir) + # Build a *second* sdist/wheel. + second_result = build_method(dist_dir) - assert os.path.isfile(os.path.join(dist_dir, wheel_one)) - assert wheel_one != wheel_two + assert os.path.isfile(os.path.join(dist_dir, first_result)) + assert first_result != second_result - # and if rebuilding the same wheel? - open(os.path.join(dist_dir, wheel_two), 'w').close() - wheel_three = self.get_build_backend().build_wheel(dist_dir) - assert wheel_three == wheel_two - assert os.path.getsize(os.path.join(dist_dir, wheel_three)) > 0 + # And if rebuilding the exact same sdist/wheel? + open(os.path.join(dist_dir, second_result), 'w').close() + third_result = build_method(dist_dir) + assert third_result == second_result + assert os.path.getsize(os.path.join(dist_dir, third_result)) > 0 def test_build_sdist(self, build_backend): dist_dir = os.path.abspath('pip-sdist') |
