From 249f870f2c6fb60734e9db34e44f7e44cd35c914 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 10:08:00 -0500 Subject: Drop support for 'tag_svn_version' distribution option. Fixes #619. --- setuptools/tests/test_egg_info.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 75ae18df..a32b981d 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -88,9 +88,8 @@ class TestEggInfo(object): assert '[egg_info]' in content assert 'tag_build =' in content assert 'tag_date = 0' in content - assert 'tag_svn_revision = 0' in content - expected_order = 'tag_build', 'tag_date', 'tag_svn_revision' + expected_order = 'tag_build', 'tag_date', self._validate_content_order(content, expected_order) @@ -117,7 +116,6 @@ class TestEggInfo(object): [egg_info] tag_build = tag_date = 0 - tag_svn_revision = 0 """), }) dist = Distribution() @@ -131,9 +129,8 @@ class TestEggInfo(object): assert '[egg_info]' in content assert 'tag_build =' in content assert 'tag_date = 0' in content - assert 'tag_svn_revision = 0' in content - expected_order = 'tag_build', 'tag_date', 'tag_svn_revision' + expected_order = 'tag_build', 'tag_date', self._validate_content_order(content, expected_order) -- cgit v1.2.3 From ff371f18f0076bc63da05334f7e551c1cc29e10d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 22:34:28 -0500 Subject: Strip out vendored packages and require them instead. Ref #581. --- setuptools/tests/test_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index a32b981d..c9a4425a 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -6,7 +6,7 @@ import sys from setuptools.command.egg_info import egg_info, manifest_maker from setuptools.dist import Distribution -from setuptools.extern.six.moves import map +from six.moves import map import pytest -- cgit v1.2.3 From 3d0cc355fb5e8012cb8c72f0e25042a5a44f31d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Feb 2017 11:49:51 -0500 Subject: Revert "Merge pull request #933 from pypa/feature/581-depend-not-bundle" This reverts commit 089cdeb489a0fa94d11b7307b54210ef9aa40511, reversing changes made to aaec654d804cb78dbb6391afff721a63f26a71cd. --- setuptools/tests/test_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index c9a4425a..a32b981d 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -6,7 +6,7 @@ import sys from setuptools.command.egg_info import egg_info, manifest_maker from setuptools.dist import Distribution -from six.moves import map +from setuptools.extern.six.moves import map import pytest -- cgit v1.2.3 From 050808db513e54c12190d64d5ba0a1f6e8ad9590 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 10 Jul 2017 02:54:29 +0200 Subject: fix handling of environment markers in `install_requires` --- setuptools/tests/test_egg_info.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index a32b981d..55df4489 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -185,8 +185,12 @@ class TestEggInfo(object): 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') - assert "barbazquux;python_version<'2'" in open( - requires_txt).read().split('\n') + with open(requires_txt) as fp: + install_requires = fp.read() + assert install_requires.lstrip() == DALS(''' + [:python_version < "2"] + barbazquux + ''') assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] def test_setup_requires_with_markers(self, tmpdir_cwd, env): @@ -202,10 +206,11 @@ 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_extra_requires_with_markers(self, tmpdir_cwd, env): + def test_extras_require_with_markers(self, tmpdir_cwd, env): self._setup_script_with_requires( - """extra_requires={":python_version<'2'": ["barbazquux"]},""") - self._run_install_command(tmpdir_cwd, env) + """extras_require={"extra": ["barbazquux; python_version<'2'"]},""") + 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): -- cgit v1.2.3 From e82eadd1ff76b9aa3d5a8e472f48c054a296d8fe Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 13 Jul 2017 20:58:19 -0400 Subject: Restore test that includes an environment marker. --- setuptools/tests/test_egg_info.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 55df4489..51648fff 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -207,6 +207,12 @@ class TestEggInfo(object): assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] def test_extras_require_with_markers(self, tmpdir_cwd, env): + self._setup_script_with_requires( + """extras_require={":python_version<'2'": ["barbazquux"]},""") + self._run_install_command(tmpdir_cwd, env) + assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + + def test_extras_require_with_markers_in_req(self, tmpdir_cwd, env): self._setup_script_with_requires( """extras_require={"extra": ["barbazquux; python_version<'2'"]},""") with pytest.raises(AssertionError): -- cgit v1.2.3 From 44233b1b8cecc77001dec43a2d86e6955d529f82 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 13 Jul 2017 21:17:58 -0400 Subject: Extract the creation of the mismatch marker. --- setuptools/tests/test_egg_info.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 51648fff..1376075c 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -179,45 +179,53 @@ class TestEggInfo(object): 'setup.py': setup_script, }) + mismatch_marker = "python_version<'{this_ver}'".format( + this_ver=sys.version_info[0], + ) + def test_install_requires_with_markers(self, tmpdir_cwd, env): - self._setup_script_with_requires( - """install_requires=["barbazquux;python_version<'2'"],""") + tmpl = 'install_requires=["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() assert install_requires.lstrip() == DALS(''' - [:python_version < "2"] + [:python_version < "{sys.version_info[0]}"] barbazquux - ''') + ''').format(sys=sys) assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] def test_setup_requires_with_markers(self, tmpdir_cwd, env): - self._setup_script_with_requires( - """setup_requires=["barbazquux;python_version<'2'"],""") + tmpl = 'setup_requires=["barbazquux;{marker}"],' + req = tmpl.format(marker=self.mismatch_marker) + self._setup_script_with_requires(req) self._run_install_command(tmpdir_cwd, env) assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] def test_tests_require_with_markers(self, tmpdir_cwd, env): - self._setup_script_with_requires( - """tests_require=["barbazquux;python_version<'2'"],""") + tmpl = 'tests_require=["barbazquux;{marker}"],' + req = tmpl.format(marker=self.mismatch_marker) + self._setup_script_with_requires(req) self._run_install_command( 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): - self._setup_script_with_requires( - """extras_require={":python_version<'2'": ["barbazquux"]},""") + 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) assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] def test_extras_require_with_markers_in_req(self, tmpdir_cwd, env): - self._setup_script_with_requires( - """extras_require={"extra": ["barbazquux; python_version<'2'"]},""") + tmpl = 'extras_require={{"extra": ["barbazquux; {marker}"]}},' + req = tmpl.format(marker=self.mismatch_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( -- cgit v1.2.3 From 295dbf3043da95165683991d71c187c875daa600 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 13 Jul 2017 21:20:02 -0400 Subject: extract variable for expected_requires. --- setuptools/tests/test_egg_info.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 1376075c..6358abf0 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -192,10 +192,11 @@ class TestEggInfo(object): requires_txt = os.path.join(egg_info_dir, 'requires.txt') with open(requires_txt) as fp: install_requires = fp.read() - assert install_requires.lstrip() == DALS(''' - [:python_version < "{sys.version_info[0]}"] - barbazquux - ''').format(sys=sys) + expected_requires = DALS(''' + [:python_version < "{sys.version_info[0]}"] + barbazquux + ''').format(sys=sys) + assert install_requires.lstrip() == expected_requires assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] def test_setup_requires_with_markers(self, tmpdir_cwd, env): -- cgit v1.2.3 From 7257263ba6568ae2868a0eb96f4e36917fb607b1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 13 Jul 2017 22:10:08 -0400 Subject: Delint --- setuptools/tests/test_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 6358abf0..07bd8818 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -64,7 +64,7 @@ class TestEggInfo(object): yield env dict_order_fails = pytest.mark.skipif( - sys.version_info < (2,7), + sys.version_info < (2, 7), reason="Intermittent failures on Python 2.6", ) -- cgit v1.2.3 From 2328be3cc556076b91c8ec74da7b85b178dbc574 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 15 Jul 2017 03:32:57 +0200 Subject: fix `extras_require` handling Allow requirements of the form `"extra": ["barbazquux; {marker}"]` by internally converting them to `"extra:{marker}": ["barbazquux"]`. --- setuptools/tests/test_egg_info.py | 47 +++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_egg_info.py') 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( -- cgit v1.2.3 From a3ec721ec1e70f1f7aec6c3349ad85b446410809 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 14 Jul 2017 23:56:05 +0200 Subject: fix `install_requires` handling of extras Internally move requirements in `install_requires` that are using extras to `extras_require` so those extras don't get stripped when building wheels. --- setuptools/tests/test_egg_info.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 0b6f06b2..5ea55d61 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -188,7 +188,7 @@ class TestEggInfo(object): ) invalid_marker = "<=>++" - def test_install_requires_with_markers(self, tmpdir_cwd, env): + def test_install_requires_with_marker(self, tmpdir_cwd, env): tmpl = 'install_requires=["barbazquux;{marker}"],' req = tmpl.format(marker=self.mismatch_marker) self._setup_script_with_requires(req) @@ -204,6 +204,37 @@ class TestEggInfo(object): assert install_requires.lstrip() == expected_requires assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + def test_install_requires_with_extra(self, tmpdir_cwd, env): + req = 'install_requires=["barbazquux [test]"],' + 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(''' + [test] + barbazquux + ''') + assert install_requires.lstrip() == expected_requires + assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + + def test_install_requires_with_extra_and_marker(self, tmpdir_cwd, env): + tmpl = 'install_requires=["barbazquux [test]; {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(''' + [test:{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_setup_requires_with_markers(self, tmpdir_cwd, env): tmpl = 'setup_requires=["barbazquux;{marker}"],' req = tmpl.format(marker=self.mismatch_marker) -- cgit v1.2.3 From 880774ac34e43c832f52d64923c670f59b54f07e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 23 Jul 2017 22:14:47 +0200 Subject: Revert "fix `install_requires` handling of extras" This reverts commit a3ec721ec1e70f1f7aec6c3349ad85b446410809. --- setuptools/tests/test_egg_info.py | 42 +++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 5ea55d61..d9d4ec3b 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -207,14 +207,13 @@ class TestEggInfo(object): def test_install_requires_with_extra(self, tmpdir_cwd, env): req = 'install_requires=["barbazquux [test]"],' 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 + self._run_install_command(tmpdir_cwd, env, cmd=['egg_info']) + egg_info_dir = os.path.join('.', 'foo.egg-info') requires_txt = os.path.join(egg_info_dir, 'requires.txt') with open(requires_txt) as fp: install_requires = fp.read() expected_requires = DALS(''' - [test] - barbazquux + barbazquux[test] ''') assert install_requires.lstrip() == expected_requires assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] @@ -229,8 +228,8 @@ class TestEggInfo(object): with open(requires_txt) as fp: install_requires = fp.read() expected_requires = DALS(''' - [test:{marker}] - barbazquux + [:{marker}] + barbazquux[test] ''').format(marker=self.mismatch_marker_alternate) assert install_requires.lstrip() == expected_requires assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] @@ -250,6 +249,37 @@ 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_extra(self, tmpdir_cwd, env): + req = 'extras_require={"extra": ["barbazquux [test]"]},' + self._setup_script_with_requires(req) + self._run_install_command(tmpdir_cwd, env, cmd=['egg_info']) + egg_info_dir = os.path.join('.', 'foo.egg-info') + requires_txt = os.path.join(egg_info_dir, 'requires.txt') + with open(requires_txt) as fp: + install_requires = fp.read() + expected_requires = DALS(''' + [extra] + barbazquux[test] + ''') + assert install_requires.lstrip() == expected_requires + assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + + def test_extras_require_with_extra_and_marker_in_req(self, tmpdir_cwd, env): + tmpl = 'extras_require={{"extra": ["barbazquux [test]; {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[test] + ''').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_marker(self, tmpdir_cwd, env): tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},' req = tmpl.format(marker=self.mismatch_marker) -- cgit v1.2.3 From a82fd99f671e6bbcfd753196862d891c0d32d82c Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 25 Jul 2017 20:59:48 +0200 Subject: do not strip empty sections in `extras_require` --- setuptools/tests/test_egg_info.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index d9d4ec3b..9ea7cdce 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -274,6 +274,8 @@ class TestEggInfo(object): with open(requires_txt) as fp: install_requires = fp.read() expected_requires = DALS(''' + [extra] + [extra:{marker}] barbazquux[test] ''').format(marker=self.mismatch_marker_alternate) @@ -306,6 +308,8 @@ class TestEggInfo(object): with open(requires_txt) as fp: install_requires = fp.read() expected_requires = DALS(''' + [extra] + [extra:{marker}] barbazquux ''').format(marker=self.mismatch_marker_alternate) @@ -328,6 +332,20 @@ class TestEggInfo(object): self._run_install_command(tmpdir_cwd, env) assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + def test_extras_require_with_empty_section(self, tmpdir_cwd, env): + tmpl = 'extras_require={{"empty": []}},' + req = tmpl.format(marker=self.invalid_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(''' + [empty] + ''').format(marker=self.mismatch_marker_alternate) + assert install_requires.lstrip() == expected_requires + def test_python_requires_egg_info(self, tmpdir_cwd, env): self._setup_script_with_requires( """python_requires='>=2.7.12',""") -- cgit v1.2.3 From 096f3287314549ac423f1c1c443f8aefa0b64b4f Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 27 Jul 2017 01:45:54 +0200 Subject: fix requires handling when using setup.cfg --- setuptools/tests/test_egg_info.py | 334 ++++++++++++++++++++++---------------- 1 file changed, 193 insertions(+), 141 deletions(-) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 9ea7cdce..33d6cc52 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -1,3 +1,4 @@ +import ast import os import glob import re @@ -165,19 +166,17 @@ class TestEggInfo(object): sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt') assert 'docs/usage.rst' in open(sources_txt).read().split('\n') - def _setup_script_with_requires(self, requires_line): - setup_script = DALS(""" + def _setup_script_with_requires(self, requires, use_setup_cfg=False): + setup_script = DALS( + ''' from setuptools import setup - setup( - name='foo', - %s - zip_safe=False, - ) - """ % requires_line) - build_files({ - 'setup.py': setup_script, - }) + setup(name='foo', zip_safe=False, %s) + ''' + ) % ('' if use_setup_cfg else requires) + setup_config = requires if use_setup_cfg else '' + build_files({'setup.py': setup_script, + 'setup.cfg': setup_config}) mismatch_marker = "python_version<'{this_ver}'".format( this_ver=sys.version_info[0], @@ -188,131 +187,198 @@ class TestEggInfo(object): ) invalid_marker = "<=>++" - def test_install_requires_with_marker(self, tmpdir_cwd, env): - tmpl = 'install_requires=["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(''' - [:{marker}] - barbazquux - ''').format(marker=self.mismatch_marker_alternate) - assert install_requires.lstrip() == expected_requires - assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + class RequiresTestHelper(object): + + @staticmethod + def parametrize(*test_list, **format_dict): + idlist = [] + argvalues = [] + for test in test_list: + test_params = test.lstrip().split('\n\n', 3) + name_kwargs = test_params.pop(0).split('\n') + if len(name_kwargs) > 1: + install_cmd_kwargs = ast.literal_eval(name_kwargs[1].strip()) + else: + install_cmd_kwargs = {} + name = name_kwargs[0].strip() + setup_py_requires, setup_cfg_requires, expected_requires = ( + DALS(a).format(**format_dict) for a in test_params + ) + for id_, requires, use_cfg in ( + (name, setup_py_requires, False), + (name + '_in_setup_cfg', setup_cfg_requires, True), + ): + idlist.append(id_) + marks = () + if requires.startswith('@xfail\n'): + requires = requires[7:] + marks = pytest.mark.xfail + argvalues.append(pytest.param(requires, use_cfg, + expected_requires, + install_cmd_kwargs, + marks=marks)) + return pytest.mark.parametrize('requires,use_setup_cfg,' + 'expected_requires,install_cmd_kwargs', + argvalues, ids=idlist) + + @RequiresTestHelper.parametrize( + # Format of a test: + # + # id + # install_cmd_kwargs [optional] + # + # requires block (when used in setup.py) + # + # requires block (when used in setup.cfg) + # + # expected contents of requires.txt - def test_install_requires_with_extra(self, tmpdir_cwd, env): - req = 'install_requires=["barbazquux [test]"],' - self._setup_script_with_requires(req) - self._run_install_command(tmpdir_cwd, env, cmd=['egg_info']) - egg_info_dir = os.path.join('.', 'foo.egg-info') - requires_txt = os.path.join(egg_info_dir, 'requires.txt') - with open(requires_txt) as fp: - install_requires = fp.read() - expected_requires = DALS(''' - barbazquux[test] - ''') - assert install_requires.lstrip() == expected_requires - assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + ''' + install_requires_with_marker + + install_requires=["barbazquux;{mismatch_marker}"], + + [options] + install_requires = + barbazquux; {mismatch_marker} - def test_install_requires_with_extra_and_marker(self, tmpdir_cwd, env): - tmpl = 'install_requires=["barbazquux [test]; {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(''' - [:{marker}] - barbazquux[test] - ''').format(marker=self.mismatch_marker_alternate) - assert install_requires.lstrip() == expected_requires - assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + [:{mismatch_marker_alternate}] + barbazquux + ''', - def test_setup_requires_with_markers(self, tmpdir_cwd, env): - tmpl = 'setup_requires=["barbazquux;{marker}"],' - req = tmpl.format(marker=self.mismatch_marker) - self._setup_script_with_requires(req) - self._run_install_command(tmpdir_cwd, env) - assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + ''' + install_requires_with_extra + {'cmd': ['egg_info']} - def test_tests_require_with_markers(self, tmpdir_cwd, env): - tmpl = 'tests_require=["barbazquux;{marker}"],' - req = tmpl.format(marker=self.mismatch_marker) - self._setup_script_with_requires(req) - self._run_install_command( - tmpdir_cwd, env, cmd=['test'], output="Ran 0 tests in") - assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + install_requires=["barbazquux [test]"], - def test_extras_require_with_extra(self, tmpdir_cwd, env): - req = 'extras_require={"extra": ["barbazquux [test]"]},' - self._setup_script_with_requires(req) - self._run_install_command(tmpdir_cwd, env, cmd=['egg_info']) - egg_info_dir = os.path.join('.', 'foo.egg-info') - requires_txt = os.path.join(egg_info_dir, 'requires.txt') - with open(requires_txt) as fp: - install_requires = fp.read() - expected_requires = DALS(''' - [extra] - barbazquux[test] - ''') - assert install_requires.lstrip() == expected_requires - assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + [options] + install_requires = + barbazquux [test] - def test_extras_require_with_extra_and_marker_in_req(self, tmpdir_cwd, env): - tmpl = 'extras_require={{"extra": ["barbazquux [test]; {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] - - [extra:{marker}] - barbazquux[test] - ''').format(marker=self.mismatch_marker_alternate) - assert install_requires.lstrip() == expected_requires - assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + barbazquux[test] + ''', - 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*')) == [] + ''' + install_requires_with_extra_and_marker - 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 + install_requires=["barbazquux [test]; {mismatch_marker}"], + + [options] + install_requires = + barbazquux [test]; {mismatch_marker} + + [:{mismatch_marker_alternate}] + barbazquux[test] + ''', + + ''' + setup_requires_with_markers + + setup_requires=["barbazquux;{mismatch_marker}"], + + [options] + setup_requires = + barbazquux; {mismatch_marker} + + ''', + + ''' + tests_require_with_markers + {'cmd': ['test'], 'output': "Ran 0 tests in"} + + tests_require=["barbazquux;{mismatch_marker}"], + + [options] + tests_require = + barbazquux; {mismatch_marker} + + ''', + + ''' + extras_require_with_extra + {'cmd': ['egg_info']} + + extras_require={{"extra": ["barbazquux [test]"]}}, + + [options.extras_require] + extra = barbazquux [test] + + [extra] + barbazquux[test] + ''', + + ''' + extras_require_with_extra_and_marker_in_req + + extras_require={{"extra": ["barbazquux [test]; {mismatch_marker}"]}}, + + [options.extras_require] + extra = + barbazquux [test]; {mismatch_marker} + + [extra] + + [extra:{mismatch_marker_alternate}] + barbazquux[test] + ''', + + # FIXME: ConfigParser does not allow : in key names! + ''' + extras_require_with_marker + + extras_require={{":{mismatch_marker}": ["barbazquux"]}}, + + @xfail + [options.extras_require] + :{mismatch_marker} = barbazquux + + [:{mismatch_marker}] + barbazquux + ''', + + ''' + extras_require_with_marker_in_req + + extras_require={{"extra": ["barbazquux; {mismatch_marker}"]}}, + + [options.extras_require] + extra = + barbazquux; {mismatch_marker} + + [extra] + + [extra:{mismatch_marker_alternate}] + barbazquux + ''', + + ''' + extras_require_with_empty_section + + extras_require={{"empty": []}}, + + [options.extras_require] + empty = + + [empty] + ''', + # Format arguments. + invalid_marker=invalid_marker, + mismatch_marker=mismatch_marker, + mismatch_marker_alternate=mismatch_marker_alternate, + ) + def test_requires(self, tmpdir_cwd, env, + requires, use_setup_cfg, + expected_requires, install_cmd_kwargs): + self._setup_script_with_requires(requires, use_setup_cfg) + self._run_install_command(tmpdir_cwd, env, **install_cmd_kwargs) + egg_info_dir = os.path.join('.', 'foo.egg-info') requires_txt = os.path.join(egg_info_dir, 'requires.txt') - with open(requires_txt) as fp: - install_requires = fp.read() - expected_requires = DALS(''' - [extra] - - [extra:{marker}] - barbazquux - ''').format(marker=self.mismatch_marker_alternate) + if os.path.exists(requires_txt): + with open(requires_txt) as fp: + install_requires = fp.read() + else: + install_requires = '' assert install_requires.lstrip() == expected_requires assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] @@ -332,20 +398,6 @@ class TestEggInfo(object): self._run_install_command(tmpdir_cwd, env) assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] - def test_extras_require_with_empty_section(self, tmpdir_cwd, env): - tmpl = 'extras_require={{"empty": []}},' - req = tmpl.format(marker=self.invalid_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(''' - [empty] - ''').format(marker=self.mismatch_marker_alternate) - assert install_requires.lstrip() == expected_requires - def test_python_requires_egg_info(self, tmpdir_cwd, env): self._setup_script_with_requires( """python_requires='>=2.7.12',""") -- cgit v1.2.3 From ffc5f66bf730106854bd2bf41da494d5a17dcc46 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Sun, 31 Jul 2016 15:17:12 -0700 Subject: Add test_long_description_content_type Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `.egg-info` directory. `Description-Content-Type` is described at https://github.com/pypa/python-packaging-user-guide/pull/258 --- setuptools/tests/test_egg_info.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'setuptools/tests/test_egg_info.py') diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 33d6cc52..e454694d 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -398,6 +398,31 @@ class TestEggInfo(object): self._run_install_command(tmpdir_cwd, env) assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] + def test_long_description_content_type(self, tmpdir_cwd, env): + # Test that specifying a `long_description_content_type` keyword arg to + # the `setup` function results in writing a `Description-Content-Type` + # line to the `PKG-INFO` file in the `.egg-info` + # directory. + # `Description-Content-Type` is described at + # https://github.com/pypa/python-packaging-user-guide/pull/258 + + self._setup_script_with_requires( + """long_description_content_type='text/markdown',""") + environ = os.environ.copy().update( + HOME=env.paths['home'], + ) + code, data = environment.run_setup_py( + cmd=['egg_info'], + pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]), + data_stream=1, + env=environ, + ) + egg_info_dir = os.path.join('.', 'foo.egg-info') + with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file: + pkg_info_lines = pkginfo_file.read().split('\n') + expected_line = 'Description-Content-Type: text/markdown' + assert expected_line in pkg_info_lines + def test_python_requires_egg_info(self, tmpdir_cwd, env): self._setup_script_with_requires( """python_requires='>=2.7.12',""") -- cgit v1.2.3