From 05ddf95fbac925bed8a75497e48a72e1d0ff6fdb Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 27 Oct 2009 10:42:38 +0100 Subject: now develop supports the --user option fixes #58 --HG-- branch : distribute extra : rebase_source : 1f25aaecb7ff9c7b273430e68dc2bc2d2e23db7d --- setuptools/tests/test_develop.py | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 setuptools/tests/test_develop.py (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py new file mode 100644 index 00000000..ff12d345 --- /dev/null +++ b/setuptools/tests/test_develop.py @@ -0,0 +1,63 @@ +"""develop tests +""" +import sys +import os, shutil, tempfile, unittest +import tempfile +import site +from StringIO import StringIO + +from setuptools.command.develop import develop +from setuptools.command import develop as develop_pkg +from setuptools.dist import Distribution + +SETUP_PY = """\ +from setuptools import setup + +setup(name='foo') +""" + +class TestDevelopTest(unittest.TestCase): + + def setUp(self): + self.dir = tempfile.mkdtemp() + setup = os.path.join(self.dir, SETUP_PY) + f = open(setup, 'w') + f.write(SETUP_PY) + f.close() + self.old_cwd = os.getcwd() + os.chdir(self.dir) + if sys.version >= "2.6": + self.old_base = site.USER_BASE + site.USER_BASE = develop_pkg.USER_BASE = tempfile.mkdtemp() + self.old_site = site.USER_SITE + site.USER_SITE = develop_pkg.USER_SITE = tempfile.mkdtemp() + + def tearDown(self): + os.chdir(self.old_cwd) + shutil.rmtree(self.dir) + if sys.version >= "2.6": + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site + + def test_develop(self): + if sys.version < "2.6": + return + dist = Distribution() + dist.script_name = 'setup.py' + cmd = develop(dist) + cmd.user = 1 + cmd.ensure_finalized() + cmd.user = 1 + old_stdout = sys.stdout + sys.stdout = StringIO() + try: + cmd.run() + finally: + sys.stdout = old_stdout + + # let's see if we got our egg link at the right place + content = os.listdir(site.USER_SITE) + self.assertEquals(content, ['UNKNOWN.egg-link']) + -- cgit v1.2.1 From a5c7e0b5256ce53c49dabfe709b37f9644630b96 Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 27 Oct 2009 16:23:23 +0100 Subject: make sure USER_SITE is listed as a sitedir in easy_install --HG-- branch : distribute extra : rebase_source : f632d56d77b31a6b4f2183728e770d00005b0060 --- setuptools/tests/test_develop.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index ff12d345..85a6c337 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -59,5 +59,6 @@ class TestDevelopTest(unittest.TestCase): # let's see if we got our egg link at the right place content = os.listdir(site.USER_SITE) - self.assertEquals(content, ['UNKNOWN.egg-link']) + content.sort() + self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) -- cgit v1.2.1 From 33886a7ecce2ec6269eade7a31baf055bd673802 Mon Sep 17 00:00:00 2001 From: Alice Bevan-McGregor Date: Sun, 15 Nov 2009 05:41:43 -0800 Subject: Added upload_docs unit test and fixed a bug in test_develop. --HG-- branch : distribute extra : rebase_source : 0ce56dee9fbf2976d41f403fb86d8a2f714820c2 --- setuptools/tests/test_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 85a6c337..1d5fa141 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -20,7 +20,7 @@ class TestDevelopTest(unittest.TestCase): def setUp(self): self.dir = tempfile.mkdtemp() - setup = os.path.join(self.dir, SETUP_PY) + setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') f.write(SETUP_PY) f.close() -- cgit v1.2.1 From c14e1a1398cf7ece7a4bcb15317868163789d879 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 11 Feb 2010 21:32:14 +0100 Subject: enable easy_install --user, *warning breaks tests* the test-isolation got borked and operates on the users home instead of the test-tempdirs --HG-- branch : distribute extra : rebase_source : 1e9bf310b6ba92629d7ba494af17f519cfe17dc5 --- setuptools/tests/test_develop.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 1d5fa141..315c1ac8 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -7,7 +7,7 @@ import site from StringIO import StringIO from setuptools.command.develop import develop -from setuptools.command import develop as develop_pkg +from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution SETUP_PY = """\ @@ -18,7 +18,7 @@ setup(name='foo') class TestDevelopTest(unittest.TestCase): - def setUp(self): + def setUp(self): self.dir = tempfile.mkdtemp() setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') @@ -28,18 +28,18 @@ class TestDevelopTest(unittest.TestCase): os.chdir(self.dir) if sys.version >= "2.6": self.old_base = site.USER_BASE - site.USER_BASE = develop_pkg.USER_BASE = tempfile.mkdtemp() + site.USER_BASE = easy_install_pkg.USER_BASE = tempfile.mkdtemp() self.old_site = site.USER_SITE - site.USER_SITE = develop_pkg.USER_SITE = tempfile.mkdtemp() + site.USER_SITE = easy_install_pkg.USER_SITE = tempfile.mkdtemp() - def tearDown(self): + def tearDown(self): os.chdir(self.old_cwd) shutil.rmtree(self.dir) if sys.version >= "2.6": shutil.rmtree(site.USER_BASE) shutil.rmtree(site.USER_SITE) - site.USER_BASE = self.old_base - site.USER_SITE = self.old_site + easy_install_pkg.USER_BASE = site.USER_BASE = self.old_base + easy_install_pkg.USER_SITE = site.USER_SITE = self.old_site def test_develop(self): if sys.version < "2.6": -- cgit v1.2.1 From 0b3d2302b8b209c7bed8bdad6e1a6cff34889779 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 11 Feb 2010 23:57:28 +0100 Subject: move the rest of the path handling code from develop to easy_install also resuffle the path handlers a bit, hopefully everything works now --HG-- branch : distribute extra : rebase_source : dc8e4217f5832b15e8f7287c95732bc68d1e1cf5 --- setuptools/tests/test_develop.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 315c1ac8..10b2be9e 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -28,9 +28,9 @@ class TestDevelopTest(unittest.TestCase): os.chdir(self.dir) if sys.version >= "2.6": self.old_base = site.USER_BASE - site.USER_BASE = easy_install_pkg.USER_BASE = tempfile.mkdtemp() + site.USER_BASE = tempfile.mkdtemp() self.old_site = site.USER_SITE - site.USER_SITE = easy_install_pkg.USER_SITE = tempfile.mkdtemp() + site.USER_SITE = tempfile.mkdtemp() def tearDown(self): os.chdir(self.old_cwd) @@ -38,8 +38,8 @@ class TestDevelopTest(unittest.TestCase): if sys.version >= "2.6": shutil.rmtree(site.USER_BASE) shutil.rmtree(site.USER_SITE) - easy_install_pkg.USER_BASE = site.USER_BASE = self.old_base - easy_install_pkg.USER_SITE = site.USER_SITE = self.old_site + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site def test_develop(self): if sys.version < "2.6": @@ -49,6 +49,7 @@ class TestDevelopTest(unittest.TestCase): cmd = develop(dist) cmd.user = 1 cmd.ensure_finalized() + cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout sys.stdout = StringIO() -- cgit v1.2.1 From 4331740bfbdc6e148808375c406dab795ae43d9b Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Wed, 7 Apr 2010 10:00:46 +0200 Subject: make sure we test that the directory exists before we install stuff asked by setup_requires fixes #138 --HG-- branch : distribute extra : rebase_source : 1078501b886e4f0864b4ce84517b2fbc5399da35 --- setuptools/tests/test_develop.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 10b2be9e..a567dd5a 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -6,6 +6,7 @@ import tempfile import site from StringIO import StringIO +from distutils.errors import DistutilsError from setuptools.command.develop import develop from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution @@ -18,7 +19,7 @@ setup(name='foo') class TestDevelopTest(unittest.TestCase): - def setUp(self): + def setUp(self): self.dir = tempfile.mkdtemp() setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') @@ -32,7 +33,7 @@ class TestDevelopTest(unittest.TestCase): self.old_site = site.USER_SITE site.USER_SITE = tempfile.mkdtemp() - def tearDown(self): + def tearDown(self): os.chdir(self.old_cwd) shutil.rmtree(self.dir) if sys.version >= "2.6": @@ -63,3 +64,19 @@ class TestDevelopTest(unittest.TestCase): content.sort() self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) + def test_develop_with_setup_requires(self): + + wanted = ("Could not find suitable distribution for " + "Requirement.parse('I-DONT-EXIST')") + old_dir = os.getcwd() + os.chdir(self.dir) + try: + try: + dist = Distribution({'setup_requires': ['I_DONT_EXIST']}) + except DistutilsError, e: + error = str(e) + if error == wanted: + pass + finally: + os.chdir(old_dir) + -- cgit v1.2.1 From d715e5ae9aeabfec93c9f4478f9933f9b991b06a Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Thu, 26 May 2011 12:12:42 +0200 Subject: skipping a tets if in virtualenv --HG-- branch : distribute extra : rebase_source : c0928a6dc8eaa695a8abedd25c9defb0561145a3 --- setuptools/tests/test_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index a567dd5a..5576d5e5 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -43,7 +43,7 @@ class TestDevelopTest(unittest.TestCase): site.USER_SITE = self.old_site def test_develop(self): - if sys.version < "2.6": + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return dist = Distribution() dist.script_name = 'setup.py' -- cgit v1.2.1 From 58a658b26d1c95b31d02050dcccd648d2e4ce27b Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 20 Jun 2011 22:55:16 +0100 Subject: Changes to support 2.x and 3.x in the same codebase. --HG-- branch : distribute extra : rebase_source : 7d3608edee54a43789f0574d702fb839628b5071 --- setuptools/tests/test_develop.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 5576d5e5..752a70e9 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -4,11 +4,11 @@ import sys import os, shutil, tempfile, unittest import tempfile import site -from StringIO import StringIO from distutils.errors import DistutilsError from setuptools.command.develop import develop from setuptools.command import easy_install as easy_install_pkg +from setuptools.compat import StringIO from setuptools.dist import Distribution SETUP_PY = """\ @@ -73,7 +73,8 @@ class TestDevelopTest(unittest.TestCase): try: try: dist = Distribution({'setup_requires': ['I_DONT_EXIST']}) - except DistutilsError, e: + except DistutilsError: + e = sys.exc_info()[1] error = str(e) if error == wanted: pass -- cgit v1.2.1 From 61f4c9c4cbf148253c9e06f3e05757e01affeb6e Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 19:05:36 +0200 Subject: Added failing test for #299. --HG-- branch : distribute extra : rebase_source : 4a3ac76a6a49e06e1fecd1d6f4e08fa922f82f73 --- setuptools/tests/test_develop.py | 48 +++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 11 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 5576d5e5..f345d8fc 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -14,33 +14,51 @@ from setuptools.dist import Distribution SETUP_PY = """\ from setuptools import setup -setup(name='foo') +setup(name='foo', + packages=['foo'], +) +""" + +INIT_PY = """print "foo" """ class TestDevelopTest(unittest.TestCase): def setUp(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + + # Directory structure self.dir = tempfile.mkdtemp() + os.mkdir(os.path.join(self.dir, 'foo')) + # setup.py setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() + # foo/__init__.py + init = os.path.join(self.dir, 'foo', '__init__.py') + f = open(init, 'w') + f.write(INIT_PY) + f.close() + os.chdir(self.dir) - if sys.version >= "2.6": - self.old_base = site.USER_BASE - site.USER_BASE = tempfile.mkdtemp() - self.old_site = site.USER_SITE - site.USER_SITE = tempfile.mkdtemp() + self.old_base = site.USER_BASE + site.USER_BASE = tempfile.mkdtemp() + self.old_site = site.USER_SITE + site.USER_SITE = tempfile.mkdtemp() def tearDown(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + os.chdir(self.old_cwd) shutil.rmtree(self.dir) - if sys.version >= "2.6": - shutil.rmtree(site.USER_BASE) - shutil.rmtree(site.USER_SITE) - site.USER_BASE = self.old_base - site.USER_SITE = self.old_site + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site def test_develop(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): @@ -64,6 +82,14 @@ class TestDevelopTest(unittest.TestCase): content.sort() self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) + # Check that we are using the right code. + path = open(os.path.join(site.USER_SITE, 'UNKNOWN.egg-link'), 'rt').read().split()[0].strip() + init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() + if sys.version < "3": + self.assertEquals(init, 'print "foo"') + else: + self.assertEquals(init, 'print("foo")') + def test_develop_with_setup_requires(self): wanted = ("Could not find suitable distribution for " -- cgit v1.2.1 From 42afe54cf9e15ef655e7ed5fef9483682fcd5af2 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 20:52:16 +0200 Subject: Added fix for the develop command, #299. --HG-- branch : distribute extra : rebase_source : ef69472e5a9ce97d9102578898e81e516f06497a --- setuptools/tests/test_develop.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index f345d8fc..fcf33c58 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -16,6 +16,7 @@ from setuptools import setup setup(name='foo', packages=['foo'], + use_2to3=True, ) """ @@ -63,7 +64,12 @@ class TestDevelopTest(unittest.TestCase): def test_develop(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return - dist = Distribution() + dist = Distribution( + dict(name='foo', + packages=['foo'], + use_2to3=True, + version='0.0', + )) dist.script_name = 'setup.py' cmd = develop(dist) cmd.user = 1 @@ -71,7 +77,7 @@ class TestDevelopTest(unittest.TestCase): cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout - sys.stdout = StringIO() + #sys.stdout = StringIO() try: cmd.run() finally: @@ -80,17 +86,17 @@ class TestDevelopTest(unittest.TestCase): # let's see if we got our egg link at the right place content = os.listdir(site.USER_SITE) content.sort() - self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) + self.assertEquals(content, ['easy-install.pth', 'foo.egg-link']) # Check that we are using the right code. - path = open(os.path.join(site.USER_SITE, 'UNKNOWN.egg-link'), 'rt').read().split()[0].strip() + path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip() init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() if sys.version < "3": self.assertEquals(init, 'print "foo"') else: self.assertEquals(init, 'print("foo")') - def test_develop_with_setup_requires(self): + def notest_develop_with_setup_requires(self): wanted = ("Could not find suitable distribution for " "Requirement.parse('I-DONT-EXIST')") -- cgit v1.2.1 From e743dabde0d60aaeca5c9e4dc5c29ac3ac625646 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 16:41:06 +0200 Subject: Got rid of deprecated assert_ and assertEquals. --HG-- branch : distribute extra : rebase_source : 9d7032bac7db98e445ab6a46b2610c278c691c2d --- setuptools/tests/test_develop.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index fcf33c58..3e071dad 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -86,15 +86,15 @@ class TestDevelopTest(unittest.TestCase): # let's see if we got our egg link at the right place content = os.listdir(site.USER_SITE) content.sort() - self.assertEquals(content, ['easy-install.pth', 'foo.egg-link']) + self.assertEqual(content, ['easy-install.pth', 'foo.egg-link']) # Check that we are using the right code. path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip() init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() if sys.version < "3": - self.assertEquals(init, 'print "foo"') + self.assertEqual(init, 'print "foo"') else: - self.assertEquals(init, 'print("foo")') + self.assertEqual(init, 'print("foo")') def notest_develop_with_setup_requires(self): -- cgit v1.2.1 From 94fc39cb62df19e85b07658f2fa5d0b4a7bf9303 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Wed, 10 Oct 2012 10:49:54 +0100 Subject: Fixed some resource leaks. --HG-- branch : distribute extra : source : 98c929e25fee11a99eb125dd9a13521321d68dd3 --- setuptools/tests/test_develop.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index ecd2212d..0813959d 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -43,7 +43,7 @@ class TestDevelopTest(unittest.TestCase): f = open(init, 'w') f.write(INIT_PY) f.close() - + os.chdir(self.dir) self.old_base = site.USER_BASE site.USER_BASE = tempfile.mkdtemp() @@ -53,7 +53,7 @@ class TestDevelopTest(unittest.TestCase): def tearDown(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return - + os.chdir(self.old_cwd) shutil.rmtree(self.dir) shutil.rmtree(site.USER_BASE) @@ -89,8 +89,16 @@ class TestDevelopTest(unittest.TestCase): self.assertEqual(content, ['easy-install.pth', 'foo.egg-link']) # Check that we are using the right code. - path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip() - init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() + f = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt') + try: + path = f.read().split()[0].strip() + finally: + f.close() + f = open(os.path.join(path, 'foo', '__init__.py'), 'rt') + try: + init = f.read().strip() + finally: + f.close() if sys.version < "3": self.assertEqual(init, 'print "foo"') else: @@ -112,4 +120,3 @@ class TestDevelopTest(unittest.TestCase): pass finally: os.chdir(old_dir) - -- cgit v1.2.1 From 721559fe76a1cda3de639ee2aaa446595169d26b Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 29 Dec 2012 06:23:09 +0100 Subject: Fix some ResourceWarnings. --HG-- branch : distribute extra : rebase_source : 31ac3f0135d8cfe0fabc274f1649d1c99eba2868 --- setuptools/tests/test_develop.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 3e071dad..315058c5 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -89,8 +89,12 @@ class TestDevelopTest(unittest.TestCase): self.assertEqual(content, ['easy-install.pth', 'foo.egg-link']) # Check that we are using the right code. - path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip() - init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() + egg_link_file = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt') + path = egg_link_file.read().split()[0].strip() + egg_link_file.close() + init_file = open(os.path.join(path, 'foo', '__init__.py'), 'rt') + init = init_file.read().strip() + init_file.close() if sys.version < "3": self.assertEqual(init, 'print "foo"') else: -- cgit v1.2.1 From 8e657eac1ef02faedca99df319fff6b63f4a4305 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Sat, 15 Jun 2013 15:34:53 +0100 Subject: Initial commit. All tests pass on 2.7, 3.2 and 3.3, though there are some atexit errors in the multiprocessing module in 2.7/3.2 (seemingly unrelated to setuptools). --HG-- branch : single-codebase --- setuptools/tests/test_develop.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 315058c5..e2939fea 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -4,11 +4,11 @@ import sys import os, shutil, tempfile, unittest import tempfile import site -from StringIO import StringIO from distutils.errors import DistutilsError from setuptools.command.develop import develop from setuptools.command import easy_install as easy_install_pkg +from setuptools.compat import StringIO from setuptools.dist import Distribution SETUP_PY = """\ @@ -43,7 +43,7 @@ class TestDevelopTest(unittest.TestCase): f = open(init, 'w') f.write(INIT_PY) f.close() - + os.chdir(self.dir) self.old_base = site.USER_BASE site.USER_BASE = tempfile.mkdtemp() @@ -51,9 +51,9 @@ class TestDevelopTest(unittest.TestCase): site.USER_SITE = tempfile.mkdtemp() def tearDown(self): - if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + if sys.version < "2.6" or hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix): return - + os.chdir(self.old_cwd) shutil.rmtree(self.dir) shutil.rmtree(site.USER_BASE) @@ -109,7 +109,8 @@ class TestDevelopTest(unittest.TestCase): try: try: dist = Distribution({'setup_requires': ['I_DONT_EXIST']}) - except DistutilsError, e: + except DistutilsError: + e = sys.exc_info()[1] error = str(e) if error == wanted: pass -- cgit v1.2.1 From 657501ddc8410495c9f44b7280f4a7abf3241753 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 15 Feb 2014 22:54:03 +0100 Subject: Clean some imports. --- setuptools/tests/test_develop.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 7b90161a..18f35c0f 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -1,9 +1,11 @@ """develop tests """ +import os +import shutil +import site import sys -import os, shutil, tempfile, unittest import tempfile -import site +import unittest from distutils.errors import DistutilsError from setuptools.command.develop import develop -- cgit v1.2.1 From fbf309d3e3b529f6ff0d57ecbb22514755b1154d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 23 Jun 2014 17:00:01 -0400 Subject: Remove unused imports, unused variables, and excess whitespace --- setuptools/tests/test_develop.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 18f35c0f..66d182eb 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -9,8 +9,6 @@ import unittest from distutils.errors import DistutilsError from setuptools.command.develop import develop -from setuptools.command import easy_install as easy_install_pkg -from setuptools.compat import StringIO from setuptools.dist import Distribution SETUP_PY = """\ @@ -114,11 +112,11 @@ class TestDevelopTest(unittest.TestCase): os.chdir(self.dir) try: try: - dist = Distribution({'setup_requires': ['I_DONT_EXIST']}) + Distribution({'setup_requires': ['I_DONT_EXIST']}) except DistutilsError: e = sys.exc_info()[1] error = str(e) - if error == wanted: + if error == wanted: pass finally: os.chdir(old_dir) -- cgit v1.2.1 From 0ef90459f8c249a53a0c5e9daaa8a4cf407f7fe9 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Jan 2015 18:09:36 -0500 Subject: Convert test_develop to use pytest --- setuptools/tests/test_develop.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 66d182eb..9d8a56c3 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -5,7 +5,6 @@ import shutil import site import sys import tempfile -import unittest from distutils.errors import DistutilsError from setuptools.command.develop import develop @@ -23,9 +22,9 @@ setup(name='foo', INIT_PY = """print "foo" """ -class TestDevelopTest(unittest.TestCase): +class TestDevelopTest: - def setUp(self): + def setup_method(self, method): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return @@ -50,7 +49,7 @@ class TestDevelopTest(unittest.TestCase): self.old_site = site.USER_SITE site.USER_SITE = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self, method): if sys.version < "2.6" or hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix): return @@ -86,7 +85,7 @@ class TestDevelopTest(unittest.TestCase): # let's see if we got our egg link at the right place content = os.listdir(site.USER_SITE) content.sort() - self.assertEqual(content, ['easy-install.pth', 'foo.egg-link']) + assert content == ['easy-install.pth', 'foo.egg-link'] # Check that we are using the right code. egg_link_file = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt') @@ -100,9 +99,9 @@ class TestDevelopTest(unittest.TestCase): finally: init_file.close() if sys.version < "3": - self.assertEqual(init, 'print "foo"') + assert init == 'print "foo"' else: - self.assertEqual(init, 'print("foo")') + assert init == 'print("foo")' def notest_develop_with_setup_requires(self): -- cgit v1.2.1 From a5b9b91081943cb771a3fc7b5873410599513332 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Jan 2015 18:12:40 -0500 Subject: Remove consideration for older Pythons --- setuptools/tests/test_develop.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 9d8a56c3..890880dc 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -25,7 +25,7 @@ INIT_PY = """print "foo" class TestDevelopTest: def setup_method(self, method): - if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + if hasattr(sys, 'real_prefix'): return # Directory structure @@ -50,7 +50,7 @@ class TestDevelopTest: site.USER_SITE = tempfile.mkdtemp() def teardown_method(self, method): - if sys.version < "2.6" or hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix): + if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix): return os.chdir(self.old_cwd) @@ -61,7 +61,7 @@ class TestDevelopTest: site.USER_SITE = self.old_site def test_develop(self): - if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + if hasattr(sys, 'real_prefix'): return dist = Distribution( dict(name='foo', -- cgit v1.2.1 From c3319da5b2e4a8d597a5b27d4a034199eea78745 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Jan 2015 18:13:41 -0500 Subject: Remove apparently unused method. --- setuptools/tests/test_develop.py | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 890880dc..f18ddd6e 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -102,20 +102,3 @@ class TestDevelopTest: assert init == 'print "foo"' else: assert init == 'print("foo")' - - def notest_develop_with_setup_requires(self): - - wanted = ("Could not find suitable distribution for " - "Requirement.parse('I-DONT-EXIST')") - old_dir = os.getcwd() - os.chdir(self.dir) - try: - try: - Distribution({'setup_requires': ['I_DONT_EXIST']}) - except DistutilsError: - e = sys.exc_info()[1] - error = str(e) - if error == wanted: - pass - finally: - os.chdir(old_dir) -- cgit v1.2.1 From 943d583e1ec0d6e4a8a4f3be4361223c39e937d5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 09:17:00 -0500 Subject: Remove unused import --- setuptools/tests/test_develop.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index f18ddd6e..ed1b194a 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -6,7 +6,6 @@ import site import sys import tempfile -from distutils.errors import DistutilsError from setuptools.command.develop import develop from setuptools.dist import Distribution -- cgit v1.2.1 From 3bcf6213d25381d9df9baa2b7a16c9449fbf78e7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 18:55:48 -0500 Subject: Use context manager for opening file --- setuptools/tests/test_develop.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index ed1b194a..b920655d 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -32,15 +32,13 @@ class TestDevelopTest: os.mkdir(os.path.join(self.dir, 'foo')) # setup.py setup = os.path.join(self.dir, 'setup.py') - f = open(setup, 'w') - f.write(SETUP_PY) - f.close() + with open(setup, 'w') as f: + f.write(SETUP_PY) self.old_cwd = os.getcwd() # foo/__init__.py init = os.path.join(self.dir, 'foo', '__init__.py') - f = open(init, 'w') - f.write(INIT_PY) - f.close() + with open(init, 'w') as f: + f.write(INIT_PY) os.chdir(self.dir) self.old_base = site.USER_BASE -- cgit v1.2.1 From bc7f3b0a36a1c676809f89eae7299afbb7f70f32 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 19:32:13 -0500 Subject: Extract setup/teardown methods as proper fixtures. --- setuptools/tests/test_develop.py | 57 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index b920655d..96b9f4ef 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -6,8 +6,12 @@ import site import sys import tempfile +import pytest + from setuptools.command.develop import develop from setuptools.dist import Distribution +from . import contexts + SETUP_PY = """\ from setuptools import setup @@ -21,43 +25,42 @@ setup(name='foo', INIT_PY = """print "foo" """ +@pytest.yield_fixture +def temp_user(monkeypatch): + with contexts.tempdir() as user_base: + with contexts.tempdir() as user_site: + monkeypatch.setattr('site.USER_BASE', user_base) + monkeypatch.setattr('site.USER_SITE', user_site) + yield + + +@pytest.yield_fixture +def test_env(tmpdir, temp_user): + target = tmpdir + foo = target.mkdir('foo') + setup = target / 'setup.py' + if setup.isfile(): + raise ValueError(dir(target)) + with setup.open('w') as f: + f.write(SETUP_PY) + init = foo / '__init__.py' + with init.open('w') as f: + f.write(INIT_PY) + with target.as_cwd(): + yield target + + class TestDevelopTest: def setup_method(self, method): if hasattr(sys, 'real_prefix'): return - # Directory structure - self.dir = tempfile.mkdtemp() - os.mkdir(os.path.join(self.dir, 'foo')) - # setup.py - setup = os.path.join(self.dir, 'setup.py') - with open(setup, 'w') as f: - f.write(SETUP_PY) - self.old_cwd = os.getcwd() - # foo/__init__.py - init = os.path.join(self.dir, 'foo', '__init__.py') - with open(init, 'w') as f: - f.write(INIT_PY) - - os.chdir(self.dir) - self.old_base = site.USER_BASE - site.USER_BASE = tempfile.mkdtemp() - self.old_site = site.USER_SITE - site.USER_SITE = tempfile.mkdtemp() - def teardown_method(self, method): if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix): return - os.chdir(self.old_cwd) - shutil.rmtree(self.dir) - shutil.rmtree(site.USER_BASE) - shutil.rmtree(site.USER_SITE) - site.USER_BASE = self.old_base - site.USER_SITE = self.old_site - - def test_develop(self): + def test_develop(self, test_env): if hasattr(sys, 'real_prefix'): return dist = Distribution( -- cgit v1.2.1 From 448cfc53cd16fb11562def2ee8b9bf66ed178b21 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 19:37:11 -0500 Subject: Replace silent test acceptance with a proper skip check --- setuptools/tests/test_develop.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 96b9f4ef..2baf83bb 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -51,18 +51,9 @@ def test_env(tmpdir, temp_user): class TestDevelopTest: - - def setup_method(self, method): - if hasattr(sys, 'real_prefix'): - return - - def teardown_method(self, method): - if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix): - return - + @pytest.mark.skipif(hasattr(sys, 'real_prefix'), + reason="Cannot run when invoked in a virtualenv") def test_develop(self, test_env): - if hasattr(sys, 'real_prefix'): - return dist = Distribution( dict(name='foo', packages=['foo'], -- cgit v1.2.1 From e1e3570fb01aa4f1fe6d0e56cfb73d38b781a307 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 19:38:13 -0500 Subject: Extract variable --- setuptools/tests/test_develop.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 2baf83bb..49e007e6 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -54,12 +54,13 @@ class TestDevelopTest: @pytest.mark.skipif(hasattr(sys, 'real_prefix'), reason="Cannot run when invoked in a virtualenv") def test_develop(self, test_env): - dist = Distribution( - dict(name='foo', - packages=['foo'], - use_2to3=True, - version='0.0', - )) + settings = dict( + name='foo', + packages=['foo'], + use_2to3=True, + version='0.0', + ) + dist = Distribution(settings) dist.script_name = 'setup.py' cmd = develop(dist) cmd.user = 1 -- cgit v1.2.1 From 731c83fd5ebe79a7643465e68310c11387b427e8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 19:41:32 -0500 Subject: Remove unused imports --- setuptools/tests/test_develop.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 49e007e6..962c4f3c 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -1,10 +1,8 @@ """develop tests """ import os -import shutil import site import sys -import tempfile import pytest -- cgit v1.2.1 From 693f20d40fca6b41ac629665901c350cd3dcd4e8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 19:45:12 -0500 Subject: Use quiet context to suppress stdout. --- setuptools/tests/test_develop.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 962c4f3c..f0adcb18 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -65,12 +65,8 @@ class TestDevelopTest: cmd.ensure_finalized() cmd.install_dir = site.USER_SITE cmd.user = 1 - old_stdout = sys.stdout - #sys.stdout = StringIO() - try: + with contexts.quiet(): cmd.run() - finally: - sys.stdout = old_stdout # let's see if we got our egg link at the right place content = os.listdir(site.USER_SITE) -- cgit v1.2.1 From 0861296a63b3fafd059759840fb62ba12d4e6adc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 19:47:58 -0500 Subject: Use io.open and its context for simpler reading of a file --- setuptools/tests/test_develop.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index f0adcb18..ec655462 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -3,6 +3,7 @@ import os import site import sys +import io import pytest @@ -74,16 +75,12 @@ class TestDevelopTest: assert content == ['easy-install.pth', 'foo.egg-link'] # Check that we are using the right code. - egg_link_file = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt') - try: + fn = os.path.join(site.USER_SITE, 'foo.egg-link') + with io.open(fn) as egg_link_file: path = egg_link_file.read().split()[0].strip() - finally: - egg_link_file.close() - init_file = open(os.path.join(path, 'foo', '__init__.py'), 'rt') - try: + fn = os.path.join(path, 'foo', '__init__.py') + with io.open(fn) as init_file: init = init_file.read().strip() - finally: - init_file.close() if sys.version < "3": assert init == 'print "foo"' else: -- cgit v1.2.1 From 951a3b9df51c1c46a39753dc6f2854ea18f45729 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 20:01:32 -0500 Subject: Use if clause. --- setuptools/tests/test_develop.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index ec655462..35f3ea25 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -10,6 +10,7 @@ import pytest from setuptools.command.develop import develop from setuptools.dist import Distribution from . import contexts +from setuptools.compat import PY3 SETUP_PY = """\ @@ -81,7 +82,6 @@ class TestDevelopTest: fn = os.path.join(path, 'foo', '__init__.py') with io.open(fn) as init_file: init = init_file.read().strip() - if sys.version < "3": - assert init == 'print "foo"' - else: - assert init == 'print("foo")' + + expected = 'print("foo")' if PY3 else 'print "foo"' + assert init == expected -- cgit v1.2.1 From 436be23a0ac5d7f21f261bdcd6fd9119a4f55346 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 20:38:52 -0500 Subject: Rename tests for clarity --- setuptools/tests/test_develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 35f3ea25..725c4ce2 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -50,10 +50,10 @@ def test_env(tmpdir, temp_user): yield target -class TestDevelopTest: +class TestDevelop: @pytest.mark.skipif(hasattr(sys, 'real_prefix'), reason="Cannot run when invoked in a virtualenv") - def test_develop(self, test_env): + def test_2to3_user_mode(self, test_env): settings = dict( name='foo', packages=['foo'], -- cgit v1.2.1 From 7bd76e0869310de9da5a32ca2c860f6a1fa461b5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 21:21:09 -0500 Subject: Draft a test for testing the new expectation for develop command (and general functionality when console scripts are present). --- setuptools/tests/test_develop.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 725c4ce2..71f0d69a 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -85,3 +85,28 @@ class TestDevelop: expected = 'print("foo")' if PY3 else 'print "foo"' assert init == expected + + def test_console_scripts(self, tmpdir): + """ + Test that console scripts are installed and that they reference + only the project by name and not the current version. + """ + pytest.skip("TODO: needs a fixture to cause 'develop' " + "to be invoked without mutating environment.") + settings = dict( + name='foo', + packages=['foo'], + version='0.0', + entry_points={ + 'console_scripts': [ + 'foocmd = foo:foo', + ], + }, + ) + dist = Distribution(settings) + dist.script_name = 'setup.py' + cmd = develop(dist) + cmd.ensure_finalized() + cmd.install_dir = tmpdir + cmd.run() + #assert '0.0' not in foocmd_text -- cgit v1.2.1 From 75a571e4d9d5f5c3fde661c54a368b533be1978b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 25 Nov 2015 10:04:33 -0500 Subject: Skip the test when running under venv also --- setuptools/tests/test_develop.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 71f0d69a..ab5da00e 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -51,8 +51,10 @@ def test_env(tmpdir, temp_user): class TestDevelop: - @pytest.mark.skipif(hasattr(sys, 'real_prefix'), - reason="Cannot run when invoked in a virtualenv") + in_virtualenv = hasattr(sys, 'real_prefix') + in_venv = hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix + @pytest.mark.skipif(in_virtualenv or in_venv, + reason="Cannot run when invoked in a virtualenv or venv") def test_2to3_user_mode(self, test_env): settings = dict( name='foo', -- cgit v1.2.1 From 06872bb0bbbeb953e90bd0941444b0d499056557 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 31 Dec 2015 11:51:01 -0500 Subject: Update vendoring technique to match that used for packaging. Ref #229. --HG-- branch : feature/issue-229 --- setuptools/tests/test_develop.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 236b3aa6..71aaed6a 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -5,7 +5,12 @@ import site import sys import io -import six +try: + from setuptools._vendor import six +except ImportError: + # fallback to naturally-installed version; allows system packagers to + # omit vendored packages. + import six import pytest -- cgit v1.2.1 From 952c1bafda1929c74c737646aa025e6ffad6632e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 31 Dec 2015 16:30:47 -0500 Subject: Modeling after Astropy's technique for bundling libraries, the imports are now much cleaner. Thanks @embray. Ref #229. --HG-- branch : feature/issue-229 --- setuptools/tests/test_develop.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 71aaed6a..1b844499 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -5,12 +5,7 @@ import site import sys import io -try: - from setuptools._vendor import six -except ImportError: - # fallback to naturally-installed version; allows system packagers to - # omit vendored packages. - import six +from setuptools.extern import six import pytest -- cgit v1.2.1 From 6d11e88f938f09ef16db4c6064b6e74acba4db1d Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 12 Jul 2016 22:00:43 +0700 Subject: Fix quantity of blank lines after code object. --- setuptools/tests/test_develop.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 1b844499..d22e5e4a 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -26,6 +26,7 @@ setup(name='foo', INIT_PY = """print "foo" """ + @pytest.yield_fixture def temp_user(monkeypatch): with contexts.tempdir() as user_base: @@ -54,6 +55,7 @@ def test_env(tmpdir, temp_user): class TestDevelop: in_virtualenv = hasattr(sys, 'real_prefix') in_venv = hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix + @pytest.mark.skipif(in_virtualenv or in_venv, reason="Cannot run when invoked in a virtualenv or venv") def test_2to3_user_mode(self, test_env): -- cgit v1.2.1 From f2bf9162c26ee17cef89425135d2c684d6e8ce98 Mon Sep 17 00:00:00 2001 From: stepshal Date: Thu, 21 Jul 2016 04:25:53 +0700 Subject: Format block comment. --- setuptools/tests/test_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index d22e5e4a..f1580785 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -114,4 +114,4 @@ class TestDevelop: cmd.ensure_finalized() cmd.install_dir = tmpdir cmd.run() - #assert '0.0' not in foocmd_text + # assert '0.0' not in foocmd_text -- cgit v1.2.1 From 31bd37c6ac8de9e8c1bacebc2d8e1215df91eb96 Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 18 Oct 2016 20:24:35 +0700 Subject: Fix quantity of blank lines. --- setuptools/tests/test_develop.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index f1580785..4cf483f2 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -13,7 +13,6 @@ from setuptools.command.develop import develop from setuptools.dist import Distribution from . import contexts - SETUP_PY = """\ from setuptools import setup -- cgit v1.2.1 From bcddc3dd9aa2b436a4260d4345d4ab1c6d4363ca Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 7 Nov 2016 03:53:32 -0500 Subject: Add test capturing expectation for #250. --- setuptools/tests/test_develop.py | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 4cf483f2..bf162d8d 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -114,3 +114,76 @@ class TestDevelop: cmd.install_dir = tmpdir cmd.run() # assert '0.0' not in foocmd_text + + +import textwrap +import subprocess + + +class TestNamespaces: + @staticmethod + def build_namespace_package(tmpdir, name): + src_dir = tmpdir / name + src_dir.mkdir() + setup_py = src_dir / 'setup.py' + namespace, sep, rest = name.partition('.') + script = textwrap.dedent(""" + import setuptools + setuptools.setup( + name={name!r}, + version="1.0", + namespace_packages=[{namespace!r}], + packages=[{namespace!r}], + ) + """).format(**locals()) + setup_py.write_text(script, encoding='utf-8') + ns_pkg_dir = src_dir / namespace + ns_pkg_dir.mkdir() + pkg_init = ns_pkg_dir / '__init__.py' + tmpl = '__import__("pkg_resources").declare_namespace({namespace!r})' + decl = tmpl.format(**locals()) + pkg_init.write_text(decl, encoding='utf-8') + pkg_mod = ns_pkg_dir / (rest + '.py') + some_functionality = 'name = {rest!r}'.format(**locals()) + pkg_mod.write_text(some_functionality, encoding='utf-8') + return src_dir + + @staticmethod + def make_site_dir(target): + """ + Add a sitecustomize.py module in target to cause + target to be added to site dirs such that .pth files + are processed there. + """ + sc = target / 'sitecustomize.py' + target_str = str(target) + tmpl = '__import__("site").addsitedir({target_str!r})' + sc.write_text(tmpl.format(**locals()), encoding='utf-8') + + def test_namespace_package_importable(self, tmpdir): + """ + Installing two packages sharing the same namespace, one installed + naturally using pip or `--single-version-externally-managed` + and the other installed using `develop` should leave the namespace + in tact and both packages reachable by import. + """ + pkg_A = self.build_namespace_package(tmpdir, 'myns.pkgA') + pkg_B = self.build_namespace_package(tmpdir, 'myns.pkgB') + target = tmpdir / 'packages' + # use pip to install to the target directory + install_cmd = [ + 'pip', + 'install', + '-e', str(pkg_B), + str(pkg_A), + '-t', str(target), + ] + subprocess.check_call(install_cmd) + self.make_site_dir(target) + try_import = [ + sys.executable, + '-c', 'import myns.pkgA; import myns.pkgB', + ] + env = dict(PYTHONPATH=str(target)) + subprocess.check_call(try_import, env=env) + -- cgit v1.2.1 From fd623755cad7ee9fc1492029f4ebdde8ae6b1c1a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 7 Nov 2016 04:03:42 -0500 Subject: pip can't accept -e and -t --- setuptools/tests/test_develop.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index bf162d8d..8e905357 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -160,6 +160,19 @@ class TestNamespaces: tmpl = '__import__("site").addsitedir({target_str!r})' sc.write_text(tmpl.format(**locals()), encoding='utf-8') + @staticmethod + def install_develop(src_dir, target): + + develop_cmd = [ + sys.executable, + 'setup.py', + 'develop', + '--install-dir', str(target), + ] + env = dict(PYTHONPATH=str(target)) + with src_dir.as_cwd(): + subprocess.check_call(develop_cmd, env=env) + def test_namespace_package_importable(self, tmpdir): """ Installing two packages sharing the same namespace, one installed @@ -174,11 +187,11 @@ class TestNamespaces: install_cmd = [ 'pip', 'install', - '-e', str(pkg_B), str(pkg_A), '-t', str(target), ] subprocess.check_call(install_cmd) + self.install_develop(pkg_B, target) self.make_site_dir(target) try_import = [ sys.executable, -- cgit v1.2.1 From 3caf0231808268654570492a0623e72b22988243 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 7 Nov 2016 04:08:04 -0500 Subject: Move imports to top and use absolute_import for Python 2.7 compatibility --- setuptools/tests/test_develop.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 8e905357..d6c24219 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -1,9 +1,14 @@ """develop tests """ + +from __future__ import absolute_import + import os import site import sys import io +import textwrap +import subprocess from setuptools.extern import six @@ -116,10 +121,6 @@ class TestDevelop: # assert '0.0' not in foocmd_text -import textwrap -import subprocess - - class TestNamespaces: @staticmethod def build_namespace_package(tmpdir, name): -- cgit v1.2.1 From d580f089b95b58a9a414faa8ed35419e71c995e1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 7 Nov 2016 04:08:49 -0500 Subject: Use unicode literals for Python 2.7 compatibility --- setuptools/tests/test_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index d6c24219..fb8e0e3f 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -1,7 +1,7 @@ """develop tests """ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import site -- cgit v1.2.1 From 8c055ff64792c23e80f85f4c127d003fd2ae4b7d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 11 Dec 2016 20:48:07 -0500 Subject: Mark another test to fail. Ref #851 --- setuptools/tests/test_develop.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index e0227453..d1e40929 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -136,6 +136,8 @@ class TestNamespaces: with src_dir.as_cwd(): subprocess.check_call(develop_cmd, env=env) + @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), + reason="https://github.com/pypa/setuptools/issues/851") def test_namespace_package_importable(self, tmpdir): """ Installing two packages sharing the same namespace, one installed -- cgit v1.2.1 From d9c9284e19ce475c2366b279dd4db82a2751a571 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 12 Dec 2016 21:14:34 -0500 Subject: Additionally, in test_develop, ensure that pkg_resources is importable. Ref #885. --- setuptools/tests/test_develop.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index d1e40929..430a07e6 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -165,3 +165,9 @@ class TestNamespaces: env = dict(PYTHONPATH=str(target)) subprocess.check_call(try_import, env=env) + # additionally ensure that pkg_resources import works + pkg_resources_imp = [ + sys.executable, + '-c', 'import pkg_resources', + ] + subprocess.check_call(pkg_resources_imp, env=env) -- cgit v1.2.1 From 7a1c700e16523ad07532bea2ed87718fe29d3595 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 22 Dec 2016 09:31:40 -0500 Subject: Re-use test.paths_on_pythonpath to extend the PYTHONPATH variable rather than erasing it. When tests are run under pytest-runner (or other setup.py test invocations), the PYTHONPATH is carefully curated to include dependencies and the project under test. Overwriting PYTHONPATH will break tests in those environments. Fixes #884. --- setuptools/tests/test_develop.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 430a07e6..5dd72aae 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -10,6 +10,7 @@ import io import subprocess from setuptools.extern import six +from setuptools.command import test import pytest @@ -132,9 +133,9 @@ class TestNamespaces: 'develop', '--install-dir', str(target), ] - env = dict(PYTHONPATH=str(target)) with src_dir.as_cwd(): - subprocess.check_call(develop_cmd, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(develop_cmd) @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), reason="https://github.com/pypa/setuptools/issues/851") @@ -162,12 +163,13 @@ class TestNamespaces: sys.executable, '-c', 'import myns.pkgA; import myns.pkgB', ] - env = dict(PYTHONPATH=str(target)) - subprocess.check_call(try_import, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(try_import) # additionally ensure that pkg_resources import works pkg_resources_imp = [ sys.executable, '-c', 'import pkg_resources', ] - subprocess.check_call(pkg_resources_imp, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(pkg_resources_imp) -- cgit v1.2.1 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_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 5dd72aae..3b1b1e2d 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -9,7 +9,7 @@ import sys import io import subprocess -from setuptools.extern import six +import six from setuptools.command import test import pytest -- cgit v1.2.1 From ba15c9294488451900766898865c024dad2bf2be Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Jan 2017 10:23:51 -0500 Subject: Add tests for _resolve_setup_path, including one that elicits the error reported in #913. --- setuptools/tests/test_develop.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 3b1b1e2d..54e199c3 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -122,6 +122,22 @@ class TestDevelop: # assert '0.0' not in foocmd_text +class TestResolver: + """ + TODO: These tests were written with a minimal understanding + of what _resolve_setup_path is intending to do. Come up with + more meaningful cases that look like real-world scenarios. + """ + def test_resolve_setup_path_cwd(self): + assert develop._resolve_setup_path('.', '.', '.') == '.' + + def test_resolve_setup_path_one_dir(self): + assert develop._resolve_setup_path('pkgs', '.', 'pkgs') == '../' + + def test_resolve_setup_path_one_dir_trailing_slash(self): + assert develop._resolve_setup_path('pkgs/', '.', 'pkgs') == '../' + + class TestNamespaces: @staticmethod -- cgit v1.2.1 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_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 54e199c3..ad7cfa05 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -9,7 +9,7 @@ import sys import io import subprocess -import six +from setuptools.extern import six from setuptools.command import test import pytest -- cgit v1.2.1 From ee40d9fffac9c13ecfe9a427872adeeaedc57778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 20 Sep 2017 14:03:27 +0200 Subject: Tests: Run `python -m pip` instead of plain `pip` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to run the testsuite on systems where `/usr/bin/pip` is a specific Python version, but the tests are run on a different one. For example in Fedora RPM, when the Python 3 tests are invoked, they should use Python 3 pip, not Python 2 `/usr/bin/pip`. Unlike other approaches, like using `pip2`/`pip3` which is currently done in Fedora RPM (downstream patch), this way it Works Everywhereâ„¢ and the downstream patch can be dropped. See https://src.fedoraproject.org/rpms/python-setuptools/blob/54eaa03a4dc97f93a5e4c92c55e580a4ab55a058/f/0001-Run-test-on-a-version-specific-pip.patch --- setuptools/tests/test_develop.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index ad7cfa05..ec67c798 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -167,6 +167,8 @@ class TestNamespaces: target = tmpdir / 'packages' # use pip to install to the target directory install_cmd = [ + sys.executable, + '-m', 'pip', 'install', str(pkg_A), -- cgit v1.2.1 From 7ea8086d35b6e072c8deae6de54c55f0582161e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 20 Sep 2017 14:52:48 +0200 Subject: Tests: Run `python -m pip.__main__` to support Python 2.6 See https://bugs.python.org/issue2751 --- setuptools/tests/test_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index ec67c798..cb4ff4b4 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -169,7 +169,7 @@ class TestNamespaces: install_cmd = [ sys.executable, '-m', - 'pip', + 'pip.__main__', 'install', str(pkg_A), '-t', str(target), -- cgit v1.2.1 From 2ed8ca16d5bb38a72baa96fe00596d402dec9eb0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 20 Nov 2017 11:52:55 -0500 Subject: Reference to __main__ is only required for Python 2.6. --- setuptools/tests/test_develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index cb4ff4b4..ec67c798 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -169,7 +169,7 @@ class TestNamespaces: install_cmd = [ sys.executable, '-m', - 'pip.__main__', + 'pip', 'install', str(pkg_A), '-t', str(target), -- cgit v1.2.1 From 9edbd7e80fce13b1895c6932f70361285a65b84b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 20 Nov 2017 13:07:30 -0500 Subject: Disable hanging test on PyPy3. Ref #1202. --- setuptools/tests/test_develop.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index cb4ff4b4..a0aaada5 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -8,6 +8,7 @@ import site import sys import io import subprocess +import platform from setuptools.extern import six from setuptools.command import test @@ -153,8 +154,14 @@ class TestNamespaces: with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(develop_cmd) - @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), - reason="https://github.com/pypa/setuptools/issues/851") + @pytest.mark.skipif( + bool(os.environ.get("APPVEYOR")), + reason="https://github.com/pypa/setuptools/issues/851", + ) + @pytest.mark.skipif( + platform.python_implementation() == 'PyPy' and six.PY3, + reason="https://github.com/pypa/setuptools/issues/1202", + ) def test_namespace_package_importable(self, tmpdir): """ Installing two packages sharing the same namespace, one installed -- cgit v1.2.1 From 45ec75beccba6432b3ed7b80fd84b65276453e9d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 20 Nov 2017 13:10:04 -0500 Subject: Feed the hobgoblins (delint). --- setuptools/tests/test_develop.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index a0aaada5..35ea1403 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -62,7 +62,8 @@ class TestDevelop: in_virtualenv = hasattr(sys, 'real_prefix') in_venv = hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix - @pytest.mark.skipif(in_virtualenv or in_venv, + @pytest.mark.skipif( + in_virtualenv or in_venv, reason="Cannot run when invoked in a virtualenv or venv") def test_2to3_user_mode(self, test_env): settings = dict( @@ -102,7 +103,8 @@ class TestDevelop: Test that console scripts are installed and that they reference only the project by name and not the current version. """ - pytest.skip("TODO: needs a fixture to cause 'develop' " + pytest.skip( + "TODO: needs a fixture to cause 'develop' " "to be invoked without mutating environment.") settings = dict( name='foo', -- cgit v1.2.1 From 796abd8dbec884cedf326cb5f85512a5d5648c4e Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 8 Jan 2020 19:10:11 +0200 Subject: Fix for Python 4: replace unsafe six.PY3 with PY2 --- setuptools/tests/test_develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 00d4bd9a..792975fd 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -95,7 +95,7 @@ class TestDevelop: with io.open(fn) as init_file: init = init_file.read().strip() - expected = 'print("foo")' if six.PY3 else 'print "foo"' + expected = 'print "foo"' if six.PY2 else 'print("foo")' assert init == expected def test_console_scripts(self, tmpdir): @@ -161,7 +161,7 @@ class TestNamespaces: reason="https://github.com/pypa/setuptools/issues/851", ) @pytest.mark.skipif( - platform.python_implementation() == 'PyPy' and six.PY3, + platform.python_implementation() == 'PyPy' and not six.PY2, reason="https://github.com/pypa/setuptools/issues/1202", ) def test_namespace_package_importable(self, tmpdir): -- cgit v1.2.1 From 56bcce894e99059a8abda29d8b919b0bee7fd1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 12 May 2020 13:33:04 +0200 Subject: Reuse @ack_2to3 in TestDevelop.test_2to3_user_mode Fixes https://github.com/pypa/setuptools/issues/2100 --- setuptools/tests/test_develop.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 792975fd..bb89a865 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -17,6 +17,7 @@ import pytest from setuptools.command.develop import develop from setuptools.dist import Distribution +from setuptools.tests import ack_2to3 from . import contexts from . import namespaces @@ -65,6 +66,7 @@ class TestDevelop: @pytest.mark.skipif( in_virtualenv or in_venv, reason="Cannot run when invoked in a virtualenv or venv") + @ack_2to3 def test_2to3_user_mode(self, test_env): settings = dict( name='foo', -- cgit v1.2.1 From fb7ab81a3d080422687bad71f9ae9d36eeefbee2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 16 Aug 2020 00:29:24 -0400 Subject: Remove Python 2 compatibility --- setuptools/tests/test_develop.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index bb89a865..9854420e 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -1,8 +1,6 @@ """develop tests """ -from __future__ import absolute_import, unicode_literals - import os import site import sys @@ -10,7 +8,6 @@ import io import subprocess import platform -from setuptools.extern import six from setuptools.command import test import pytest @@ -97,7 +94,7 @@ class TestDevelop: with io.open(fn) as init_file: init = init_file.read().strip() - expected = 'print "foo"' if six.PY2 else 'print("foo")' + expected = 'print("foo")' assert init == expected def test_console_scripts(self, tmpdir): @@ -163,7 +160,7 @@ class TestNamespaces: reason="https://github.com/pypa/setuptools/issues/851", ) @pytest.mark.skipif( - platform.python_implementation() == 'PyPy' and not six.PY2, + platform.python_implementation() == 'PyPy', reason="https://github.com/pypa/setuptools/issues/1202", ) def test_namespace_package_importable(self, tmpdir): -- cgit v1.2.1 From 701eee9e53dcbfe200bef46420da420052699e68 Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen Date: Sun, 13 Dec 2020 18:01:50 +0800 Subject: Fix tests with pytest 6.2 The latest pytest deprecates pytest.yield_fixture in favor of pytest.fixture [1]. The changelog [2] says that both are the same. [1] https://github.com/pytest-dev/pytest/pull/7988 [2] https://docs.pytest.org/en/stable/changelog.html#pytest-6-2-0-2020-12-12 --- setuptools/tests/test_develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 9854420e..2766da2f 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -31,7 +31,7 @@ INIT_PY = """print "foo" """ -@pytest.yield_fixture +@pytest.fixture def temp_user(monkeypatch): with contexts.tempdir() as user_base: with contexts.tempdir() as user_site: @@ -40,7 +40,7 @@ def temp_user(monkeypatch): yield -@pytest.yield_fixture +@pytest.fixture def test_env(tmpdir, temp_user): target = tmpdir foo = target.mkdir('foo') -- cgit v1.2.1 From b4d8e4755eafc786a9848333ca73bff381747745 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 20 Mar 2021 21:19:49 -0400 Subject: Add test capturing missed expectation. Ref #2612. --- setuptools/tests/test_develop.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 2766da2f..e793c36d 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -7,6 +7,7 @@ import sys import io import subprocess import platform +import pathlib from setuptools.command import test @@ -199,3 +200,32 @@ class TestNamespaces: ] with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(pkg_resources_imp) + + @pytest.mark.xfail(reason="#2612") + def test_editable_prefix(self, tmp_path, sample_project): + """ + Editable install to a prefix should be discoverable. + """ + prefix = tmp_path / 'prefix' + prefix.mkdir() + + cmd = [ + sys.executable, + '-m', 'pip', + 'install', + '-e', str(sample_project), + '--prefix', str(prefix), + ] + subprocess.check_call(cmd) + + # now run 'sample' with the prefix on the PYTHONPATH + site_packages = prefix / next( + pathlib.Path(path).relative_to(sys.prefix) + for path in sys.path + if 'site-packages' in path + and path.startswith(sys.prefix) + ) + env = dict(PYTHONPATH=site_packages) + bin = 'Scripts' if platform.system() == 'Windows' else 'bin' + sample = prefix / bin / 'sample' + subprocess.check_call([sample], env=env) -- cgit v1.2.1 From cb962021c53b7130bf0a1792f75678efcc0724be Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 21 Mar 2021 03:38:43 -0400 Subject: Illustrate how one might leverage sitecustomize.py to make a project available on PYTHONPATH. Fixes #2612. --- setuptools/tests/test_develop.py | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index e793c36d..0dea40bd 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -8,6 +8,7 @@ import io import subprocess import platform import pathlib +import textwrap from setuptools.command import test @@ -201,7 +202,17 @@ class TestNamespaces: with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(pkg_resources_imp) - @pytest.mark.xfail(reason="#2612") + @staticmethod + def install_workaround(site_packages): + site_packages.mkdir(parents=True) + sc = site_packages / 'sitecustomize.py' + sc.write_text(textwrap.dedent(""" + import site + import pathlib + here = pathlib.Path(__file__).parent + site.addsitedir(str(here)) + """).lstrip()) + def test_editable_prefix(self, tmp_path, sample_project): """ Editable install to a prefix should be discoverable. @@ -209,23 +220,30 @@ class TestNamespaces: prefix = tmp_path / 'prefix' prefix.mkdir() + # figure out where pip will likely install the package + site_packages = prefix / next( + pathlib.Path(path).relative_to(sys.prefix) + for path in sys.path + if 'site-packages' in path + and path.startswith(sys.prefix) + ) + + # install the workaround + self.install_workaround(site_packages) + + env = dict(PYTHONPATH=site_packages) cmd = [ sys.executable, '-m', 'pip', 'install', - '-e', str(sample_project), + '--editable', + str(sample_project), '--prefix', str(prefix), + '--no-build-isolation', ] - subprocess.check_call(cmd) + subprocess.check_call(cmd, env=env) # now run 'sample' with the prefix on the PYTHONPATH - site_packages = prefix / next( - pathlib.Path(path).relative_to(sys.prefix) - for path in sys.path - if 'site-packages' in path - and path.startswith(sys.prefix) - ) - env = dict(PYTHONPATH=site_packages) bin = 'Scripts' if platform.system() == 'Windows' else 'bin' - sample = prefix / bin / 'sample' - subprocess.check_call([sample], env=env) + exe = prefix / bin / 'sample' + subprocess.check_call([exe], env=env) -- cgit v1.2.1 From 0c485af05591ba869b8adb96802d1cf4b49fe28d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 21 Mar 2021 04:03:10 -0400 Subject: Cast values to str and retain other environ vars for Windows' sake --- setuptools/tests/test_develop.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 0dea40bd..a0e84b9a 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -231,7 +231,7 @@ class TestNamespaces: # install the workaround self.install_workaround(site_packages) - env = dict(PYTHONPATH=site_packages) + env = dict(os.environ, PYTHONPATH=str(site_packages)) cmd = [ sys.executable, '-m', 'pip', @@ -246,4 +246,6 @@ class TestNamespaces: # now run 'sample' with the prefix on the PYTHONPATH bin = 'Scripts' if platform.system() == 'Windows' else 'bin' exe = prefix / bin / 'sample' + if sys.version_info < (3, 7) and platform.system() == 'Windows': + exe = str(exe) subprocess.check_call([exe], env=env) -- cgit v1.2.1 From 202c7a808e61a415d6a8c724a5d8fe664301863b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 21 Mar 2021 09:51:21 -0400 Subject: Expect failure on PyPy. --- setuptools/tests/test_develop.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index a0e84b9a..df8db4e2 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -213,6 +213,10 @@ class TestNamespaces: site.addsitedir(str(here)) """).lstrip()) + @pytest.mark.xfail( + platform.python_implementation() == 'PyPy', + reason="Workaround fails on PyPy (why?)", + ) def test_editable_prefix(self, tmp_path, sample_project): """ Editable install to a prefix should be discoverable. -- cgit v1.2.1 From ca296ca8663a376f3c36c9f8fd86b10ba81366c2 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 18 Jul 2021 09:27:21 +0100 Subject: remove lib2to3 usage --- setuptools/tests/test_develop.py | 73 ++++++++++++---------------------------- 1 file changed, 22 insertions(+), 51 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index df8db4e2..3c2d924c 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -16,7 +16,6 @@ import pytest from setuptools.command.develop import develop from setuptools.dist import Distribution -from setuptools.tests import ack_2to3 from . import contexts from . import namespaces @@ -25,7 +24,6 @@ from setuptools import setup setup(name='foo', packages=['foo'], - use_2to3=True, ) """ @@ -62,43 +60,6 @@ class TestDevelop: in_virtualenv = hasattr(sys, 'real_prefix') in_venv = hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix - @pytest.mark.skipif( - in_virtualenv or in_venv, - reason="Cannot run when invoked in a virtualenv or venv") - @ack_2to3 - def test_2to3_user_mode(self, test_env): - settings = dict( - name='foo', - packages=['foo'], - use_2to3=True, - version='0.0', - ) - dist = Distribution(settings) - dist.script_name = 'setup.py' - cmd = develop(dist) - cmd.user = 1 - cmd.ensure_finalized() - cmd.install_dir = site.USER_SITE - cmd.user = 1 - with contexts.quiet(): - cmd.run() - - # let's see if we got our egg link at the right place - content = os.listdir(site.USER_SITE) - content.sort() - assert content == ['easy-install.pth', 'foo.egg-link'] - - # Check that we are using the right code. - fn = os.path.join(site.USER_SITE, 'foo.egg-link') - with io.open(fn) as egg_link_file: - path = egg_link_file.read().split()[0].strip() - fn = os.path.join(path, 'foo', '__init__.py') - with io.open(fn) as init_file: - init = init_file.read().strip() - - expected = 'print("foo")' - assert init == expected - def test_console_scripts(self, tmpdir): """ Test that console scripts are installed and that they reference @@ -106,7 +67,8 @@ class TestDevelop: """ pytest.skip( "TODO: needs a fixture to cause 'develop' " - "to be invoked without mutating environment.") + "to be invoked without mutating environment." + ) settings = dict( name='foo', packages=['foo'], @@ -132,6 +94,7 @@ class TestResolver: of what _resolve_setup_path is intending to do. Come up with more meaningful cases that look like real-world scenarios. """ + def test_resolve_setup_path_cwd(self): assert develop._resolve_setup_path('.', '.', '.') == '.' @@ -143,7 +106,6 @@ class TestResolver: class TestNamespaces: - @staticmethod def install_develop(src_dir, target): @@ -151,7 +113,8 @@ class TestNamespaces: sys.executable, 'setup.py', 'develop', - '--install-dir', str(target), + '--install-dir', + str(target), ] with src_dir.as_cwd(): with test.test.paths_on_pythonpath([str(target)]): @@ -182,14 +145,16 @@ class TestNamespaces: 'pip', 'install', str(pkg_A), - '-t', str(target), + '-t', + str(target), ] subprocess.check_call(install_cmd) self.install_develop(pkg_B, target) namespaces.make_site_dir(target) try_import = [ sys.executable, - '-c', 'import myns.pkgA; import myns.pkgB', + '-c', + 'import myns.pkgA; import myns.pkgB', ] with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(try_import) @@ -197,7 +162,8 @@ class TestNamespaces: # additionally ensure that pkg_resources import works pkg_resources_imp = [ sys.executable, - '-c', 'import pkg_resources', + '-c', + 'import pkg_resources', ] with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(pkg_resources_imp) @@ -206,12 +172,16 @@ class TestNamespaces: def install_workaround(site_packages): site_packages.mkdir(parents=True) sc = site_packages / 'sitecustomize.py' - sc.write_text(textwrap.dedent(""" + sc.write_text( + textwrap.dedent( + """ import site import pathlib here = pathlib.Path(__file__).parent site.addsitedir(str(here)) - """).lstrip()) + """ + ).lstrip() + ) @pytest.mark.xfail( platform.python_implementation() == 'PyPy', @@ -228,8 +198,7 @@ class TestNamespaces: site_packages = prefix / next( pathlib.Path(path).relative_to(sys.prefix) for path in sys.path - if 'site-packages' in path - and path.startswith(sys.prefix) + if 'site-packages' in path and path.startswith(sys.prefix) ) # install the workaround @@ -238,11 +207,13 @@ class TestNamespaces: env = dict(os.environ, PYTHONPATH=str(site_packages)) cmd = [ sys.executable, - '-m', 'pip', + '-m', + 'pip', 'install', '--editable', str(sample_project), - '--prefix', str(prefix), + '--prefix', + str(prefix), '--no-build-isolation', ] subprocess.check_call(cmd, env=env) -- cgit v1.2.1 From bb8a8b8578295e6632ed464f355013a01c2a05e0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 4 Sep 2021 12:20:48 -0400 Subject: =?UTF-8?q?=F0=9F=91=B9=20Feed=20the=20hobgoblins=20(delint).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setuptools/tests/test_develop.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/tests/test_develop.py') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 3c2d924c..70c5794c 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -2,9 +2,7 @@ """ import os -import site import sys -import io import subprocess import platform import pathlib -- cgit v1.2.1