diff options
| author | Benoit Pierre <benoit.pierre@gmail.com> | 2017-07-15 03:32:57 +0200 |
|---|---|---|
| committer | Benoit Pierre <benoit.pierre@gmail.com> | 2017-07-15 06:37:00 +0200 |
| commit | 2328be3cc556076b91c8ec74da7b85b178dbc574 (patch) | |
| tree | 0826fcfd2eaeae8c56a10cc9708f764818349d50 /setuptools/tests | |
| parent | 7c2df64c8558ac71c20d86d3cb2a05daad99cc87 (diff) | |
| download | external_python_setuptools-2328be3cc556076b91c8ec74da7b85b178dbc574.tar.gz external_python_setuptools-2328be3cc556076b91c8ec74da7b85b178dbc574.tar.bz2 external_python_setuptools-2328be3cc556076b91c8ec74da7b85b178dbc574.zip | |
fix `extras_require` handling
Allow requirements of the form `"extra": ["barbazquux; {marker}"]`
by internally converting them to `"extra:{marker}": ["barbazquux"]`.
Diffstat (limited to 'setuptools/tests')
| -rw-r--r-- | setuptools/tests/test_egg_info.py | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 07bd8818..0b6f06b2 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -182,6 +182,11 @@ class TestEggInfo(object): mismatch_marker = "python_version<'{this_ver}'".format( this_ver=sys.version_info[0], ) + # Alternate equivalent syntax. + mismatch_marker_alternate = 'python_version < "{this_ver}"'.format( + this_ver=sys.version_info[0], + ) + invalid_marker = "<=>++" def test_install_requires_with_markers(self, tmpdir_cwd, env): tmpl = 'install_requires=["barbazquux;{marker}"],' @@ -193,9 +198,9 @@ class TestEggInfo(object): with open(requires_txt) as fp: install_requires = fp.read() expected_requires = DALS(''' - [:python_version < "{sys.version_info[0]}"] + [:{marker}] barbazquux - ''').format(sys=sys) + ''').format(marker=self.mismatch_marker_alternate) assert install_requires.lstrip() == expected_requires assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] @@ -214,19 +219,53 @@ class TestEggInfo(object): tmpdir_cwd, env, cmd=['test'], output="Ran 0 tests in") assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] - def test_extras_require_with_markers(self, tmpdir_cwd, env): + def test_extras_require_with_marker(self, tmpdir_cwd, env): tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},' req = tmpl.format(marker=self.mismatch_marker) self._setup_script_with_requires(req) self._run_install_command(tmpdir_cwd, env) + egg_info_dir = self._find_egg_info_files(env.paths['lib']).base + requires_txt = os.path.join(egg_info_dir, 'requires.txt') + with open(requires_txt) as fp: + install_requires = fp.read() + expected_requires = DALS(''' + [:{marker}] + barbazquux + ''').format(marker=self.mismatch_marker) + assert install_requires.lstrip() == expected_requires assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] - def test_extras_require_with_markers_in_req(self, tmpdir_cwd, env): + def test_extras_require_with_marker_in_req(self, tmpdir_cwd, env): tmpl = 'extras_require={{"extra": ["barbazquux; {marker}"]}},' req = tmpl.format(marker=self.mismatch_marker) self._setup_script_with_requires(req) + self._run_install_command(tmpdir_cwd, env) + egg_info_dir = self._find_egg_info_files(env.paths['lib']).base + requires_txt = os.path.join(egg_info_dir, 'requires.txt') + with open(requires_txt) as fp: + install_requires = fp.read() + expected_requires = DALS(''' + [extra:{marker}] + barbazquux + ''').format(marker=self.mismatch_marker_alternate) + assert install_requires.lstrip() == expected_requires + assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + + def test_extras_require_with_invalid_marker(self, tmpdir_cwd, env): + tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},' + req = tmpl.format(marker=self.invalid_marker) + self._setup_script_with_requires(req) with pytest.raises(AssertionError): self._run_install_command(tmpdir_cwd, env) + assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + + def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env): + tmpl = 'extras_require={{"extra": ["barbazquux; {marker}"]}},' + req = tmpl.format(marker=self.invalid_marker) + self._setup_script_with_requires(req) + with pytest.raises(AssertionError): + self._run_install_command(tmpdir_cwd, env) + assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] def test_python_requires_egg_info(self, tmpdir_cwd, env): self._setup_script_with_requires( |
