From c8558d8d3b6c2cae273637ccec616489c2e7b439 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 17:29:47 +0200 Subject: Add failing test for #301. --HG-- branch : distribute extra : rebase_source : 2972e762cdab88e90c1c8b9b9a336afc641e996f --- setuptools/tests/test_test.py | 112 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 setuptools/tests/test_test.py (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py new file mode 100644 index 00000000..7194399a --- /dev/null +++ b/setuptools/tests/test_test.py @@ -0,0 +1,112 @@ +"""develop tests +""" +import sys +import os, shutil, tempfile, unittest +import tempfile +import site +from StringIO import StringIO + +from distutils.errors import DistutilsError +from setuptools.command.test import test +from setuptools.command import easy_install as easy_install_pkg +from setuptools.dist import Distribution + +SETUP_PY = """\ +from setuptools import setup + +setup(name='foo') +""" + +NS_INIT = """try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) +""" +TEST_PY = """import unittest + +class TestTest(unittest.TestCase): + def test_test(self): + print "Foo" # Should fail under Python 3 unless 2to3 is used + +test_suite = unittest.makeSuite(TestTest) +""" + +class TestTestTest(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, 'name')) + os.mkdir(os.path.join(self.dir, 'name', 'space')) + os.mkdir(os.path.join(self.dir, 'name', 'space', 'tests')) + # 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() + # name/__init__.py + init = os.path.join(self.dir, 'name', '__init__.py') + f = open(init, 'w') + f.write(NS_INIT) + f.close() + # name/space/__init__.py + init = os.path.join(self.dir, 'name', 'space', '__init__.py') + f = open(init, 'w') + f.write('#empty\n') + f.close() + # name/space/tests/__init__.py + init = os.path.join(self.dir, 'name', 'space', 'tests', '__init__.py') + f = open(init, 'w') + f.write(TEST_PY) + f.close() + + 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(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) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site + + def test_test(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + + dist = Distribution(dict( + script_name='setup.py', + script_args=['bdist_egg'], + name='foo', + py_modules=['name'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', + )) + dist.script_name = 'setup.py' + cmd = test(dist) + cmd.user = 1 + cmd.ensure_finalized() + cmd.install_dir = site.USER_SITE + cmd.user = 1 + old_stdout = sys.stdout + sys.stdout = StringIO() + try: + cmd.run() + except SystemExit: # The test runner calls sys.exit, stop that making an error. + pass + finally: + sys.stdout = old_stdout + +test_suite = unittest.makeSuite(TestTestTest) -- cgit v1.2.1 From 78ac59d4ab00868456155cd3f83be15f78acccf3 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 18:56:02 +0200 Subject: Once the test is correctly setup, the problem actually goes away. --HG-- branch : distribute extra : rebase_source : 8a1c310010599165aa973bb207b07616428df66b --- setuptools/tests/test_test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 7194399a..5000f234 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -14,10 +14,15 @@ from setuptools.dist import Distribution SETUP_PY = """\ from setuptools import setup -setup(name='foo') +setup(name='foo', + packages=['name', 'name.space', 'name.space.tests'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', +) """ -NS_INIT = """try: +NS_INIT = """ +try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path @@ -87,12 +92,11 @@ class TestTestTest(unittest.TestCase): return dist = Distribution(dict( - script_name='setup.py', - script_args=['bdist_egg'], name='foo', - py_modules=['name'], + packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', + use_2to3=True, )) dist.script_name = 'setup.py' cmd = test(dist) -- 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_test.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 5000f234..87ccaf44 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -112,5 +112,3 @@ class TestTestTest(unittest.TestCase): pass finally: sys.stdout = old_stdout - -test_suite = unittest.makeSuite(TestTestTest) -- 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_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 87ccaf44..04134ec5 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -107,8 +107,9 @@ class TestTestTest(unittest.TestCase): old_stdout = sys.stdout sys.stdout = StringIO() try: - cmd.run() - except SystemExit: # The test runner calls sys.exit, stop that making an error. - pass + try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. + cmd.run() + except SystemExit: # The test runner calls sys.exit, stop that making an error. + pass finally: sys.stdout = old_stdout -- cgit v1.2.1 From 0d962727403be73b0b1eac234ed81b941dd7cae9 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 18:01:49 +0200 Subject: Issue #310: Non-ascii characters in a namespace __init__.py causes errors. --HG-- branch : distribute extra : rebase_source : 668e1c79a2bcc314bcf1f7213b317766bb8511ab --- setuptools/tests/test_test.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 04134ec5..ddbebaa9 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -1,3 +1,5 @@ +# -*- coding: UTF-8 -*- + """develop tests """ import sys @@ -21,13 +23,19 @@ setup(name='foo', ) """ -NS_INIT = """ +NS_INIT = """# -*- coding: Latin-1 -*- +# Söme Arbiträry Ünicode to test Issüé 310 try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) """ +# Make sure this is Latin-1 binary, before writing: +if sys.version_info < (3,): + NS_INIT = NS_INIT.decode('UTF-8') +NS_INIT = NS_INIT.encode('Latin-1') + TEST_PY = """import unittest class TestTest(unittest.TestCase): @@ -50,23 +58,23 @@ class TestTestTest(unittest.TestCase): os.mkdir(os.path.join(self.dir, 'name', 'space', 'tests')) # setup.py setup = os.path.join(self.dir, 'setup.py') - f = open(setup, 'w') + f = open(setup, 'wt') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() # name/__init__.py init = os.path.join(self.dir, 'name', '__init__.py') - f = open(init, 'w') + f = open(init, 'wb') f.write(NS_INIT) f.close() # name/space/__init__.py init = os.path.join(self.dir, 'name', 'space', '__init__.py') - f = open(init, 'w') + f = open(init, 'wt') f.write('#empty\n') f.close() # name/space/tests/__init__.py init = os.path.join(self.dir, 'name', 'space', 'tests', '__init__.py') - f = open(init, 'w') + f = open(init, 'wt') f.write(TEST_PY) f.close() @@ -105,7 +113,7 @@ class TestTestTest(unittest.TestCase): cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout - sys.stdout = StringIO() + #sys.stdout = StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run() @@ -113,3 +121,4 @@ class TestTestTest(unittest.TestCase): pass finally: sys.stdout = old_stdout + \ No newline at end of file -- cgit v1.2.1 From f8d45b50bfcafabe759183e716059a2e2f702420 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Fri, 24 Aug 2012 15:33:56 +0200 Subject: Oups. --HG-- branch : distribute extra : rebase_source : 515bd00c3028ba0d58e57fd51d524a798b9b898d --- setuptools/tests/test_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index ddbebaa9..ad7cbd0f 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -113,7 +113,7 @@ class TestTestTest(unittest.TestCase): cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout - #sys.stdout = StringIO() + sys.stdout = StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run() -- cgit v1.2.1 From ac3ba239c54965e464e6047fd872f02ca1c0cb99 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Wed, 10 Oct 2012 09:39:21 +0100 Subject: Post-merge fixes for Python 3. --HG-- branch : distribute extra : source : 6b9041dea7b9197f6ea1fb993d7a05dd4f7c580d --- setuptools/tests/test_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index ad7cbd0f..e7022995 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -6,9 +6,9 @@ import sys import os, shutil, tempfile, unittest import tempfile import site -from StringIO import StringIO from distutils.errors import DistutilsError +from setuptools.compat import StringIO from setuptools.command.test import test from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution @@ -121,4 +121,4 @@ class TestTestTest(unittest.TestCase): pass finally: sys.stdout = old_stdout - \ No newline at end of file + -- cgit v1.2.1 From f52d063aa81f64bbb71562510a87d3aedbad2ed9 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 17 Jun 2013 10:20:56 -0500 Subject: Re-save test modules with UTF-8 encoding --HG-- branch : distribute extra : rebase_source : 6728580b2f2f10026fe0f196db7ea5510acac704 extra : histedit_source : f4fbf02bbe3e4e39caf1aa2f5a354c99d9249e65 --- setuptools/tests/test_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index e7022995..7a06a403 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -1,4 +1,4 @@ -# -*- coding: UTF-8 -*- +# -*- coding: UTF-8 -*- """develop tests """ @@ -23,7 +23,7 @@ setup(name='foo', ) """ -NS_INIT = """# -*- coding: Latin-1 -*- +NS_INIT = """# -*- coding: Latin-1 -*- # Söme Arbiträry Ünicode to test Issüé 310 try: __import__('pkg_resources').declare_namespace(__name__) @@ -77,7 +77,7 @@ class TestTestTest(unittest.TestCase): f = open(init, 'wt') f.write(TEST_PY) f.close() - + os.chdir(self.dir) self.old_base = site.USER_BASE site.USER_BASE = tempfile.mkdtemp() @@ -87,7 +87,7 @@ class TestTestTest(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) @@ -98,7 +98,7 @@ class TestTestTest(unittest.TestCase): def test_test(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return - + dist = Distribution(dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], @@ -121,4 +121,4 @@ class TestTestTest(unittest.TestCase): pass finally: sys.stdout = old_stdout - + -- 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_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 7a06a403..f85123b0 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -2,10 +2,12 @@ """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.compat import StringIO -- cgit v1.2.1 From 8567ca65adbf927a0af5c9b7314688dfbc46ab66 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 12:25:31 -0400 Subject: Use PY3 and PY2 throughout --- setuptools/tests/test_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index f85123b0..df92085e 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -10,7 +10,7 @@ import tempfile import unittest from distutils.errors import DistutilsError -from setuptools.compat import StringIO +from setuptools.compat import StringIO, PY2 from setuptools.command.test import test from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution @@ -34,7 +34,7 @@ except ImportError: __path__ = extend_path(__path__, __name__) """ # Make sure this is Latin-1 binary, before writing: -if sys.version_info < (3,): +if PY2: NS_INIT = NS_INIT.decode('UTF-8') NS_INIT = NS_INIT.encode('Latin-1') -- cgit v1.2.1 From b49435397a5094f94678adf3549cc8941aa469b7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 5 Jul 2014 15:06:51 -0400 Subject: Use six for Python 2 compatibility --HG-- branch : feature/issue-229 extra : source : 7b1997ececc5772798ce33a0f8e77387cb55a977 --- setuptools/tests/test_test.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index df92085e..67df14e5 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -8,9 +8,10 @@ import site import sys import tempfile import unittest - from distutils.errors import DistutilsError -from setuptools.compat import StringIO, PY2 + +import six + from setuptools.command.test import test from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution @@ -34,7 +35,7 @@ except ImportError: __path__ = extend_path(__path__, __name__) """ # Make sure this is Latin-1 binary, before writing: -if PY2: +if six.PY2: NS_INIT = NS_INIT.decode('UTF-8') NS_INIT = NS_INIT.encode('Latin-1') @@ -115,7 +116,7 @@ class TestTestTest(unittest.TestCase): cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout - sys.stdout = StringIO() + sys.stdout = six.StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run() -- cgit v1.2.1 From ee20548e4039df2a49157f5d85090286434ced5f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 11:58:58 -0500 Subject: Remove unused imports --- setuptools/tests/test_test.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index df92085e..edd1769a 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -9,10 +9,8 @@ import sys import tempfile import unittest -from distutils.errors import DistutilsError from setuptools.compat import StringIO, PY2 from setuptools.command.test import test -from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution SETUP_PY = """\ -- cgit v1.2.1 From a974f8c7b1b30bdb462531627a39255a0b82fdff Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:00:11 -0500 Subject: Use DALS for nicer indentation --- setuptools/tests/test_test.py | 52 ++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index edd1769a..9a8f9313 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -13,37 +13,43 @@ from setuptools.compat import StringIO, PY2 from setuptools.command.test import test from setuptools.dist import Distribution -SETUP_PY = """\ -from setuptools import setup - -setup(name='foo', - packages=['name', 'name.space', 'name.space.tests'], - namespace_packages=['name'], - test_suite='name.space.tests.test_suite', -) -""" +from .textwrap import DALS + +SETUP_PY = DALS(""" + from setuptools import setup + + setup(name='foo', + packages=['name', 'name.space', 'name.space.tests'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', + ) + """) + +NS_INIT = DALS(""" + # -*- coding: Latin-1 -*- + # Söme Arbiträry Ünicode to test Issüé 310 + try: + __import__('pkg_resources').declare_namespace(__name__) + except ImportError: + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) + """) -NS_INIT = """# -*- coding: Latin-1 -*- -# Söme Arbiträry Ünicode to test Issüé 310 -try: - __import__('pkg_resources').declare_namespace(__name__) -except ImportError: - from pkgutil import extend_path - __path__ = extend_path(__path__, __name__) -""" # Make sure this is Latin-1 binary, before writing: if PY2: NS_INIT = NS_INIT.decode('UTF-8') NS_INIT = NS_INIT.encode('Latin-1') -TEST_PY = """import unittest +TEST_PY = DALS(""" + import unittest -class TestTest(unittest.TestCase): - def test_test(self): - print "Foo" # Should fail under Python 3 unless 2to3 is used + class TestTest(unittest.TestCase): + def test_test(self): + print "Foo" # Should fail under Python 3 unless 2to3 is used + + test_suite = unittest.makeSuite(TestTest) + """) -test_suite = unittest.makeSuite(TestTest) -""" class TestTestTest(unittest.TestCase): -- cgit v1.2.1 From 14beff81f0f4369a3323a84f49d53747a38bccfd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:01:57 -0500 Subject: Port test_test to pytest --- setuptools/tests/test_test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 9a8f9313..f527aa24 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -7,7 +7,6 @@ import shutil import site import sys import tempfile -import unittest from setuptools.compat import StringIO, PY2 from setuptools.command.test import test @@ -51,9 +50,9 @@ TEST_PY = DALS(""" """) -class TestTestTest(unittest.TestCase): +class TestTestTest: - def setUp(self): + def setup_method(self, method): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return @@ -90,7 +89,7 @@ class TestTestTest(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'): return -- cgit v1.2.1 From d66783b40a483c9edf6117d7ebbb49c18e00de17 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:02:52 -0500 Subject: Python 2.6 can be assumed --- setuptools/tests/test_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index f527aa24..abd0038b 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -53,7 +53,7 @@ TEST_PY = DALS(""" class TestTestTest: def setup_method(self, method): - if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + if hasattr(sys, 'real_prefix'): return # Directory structure @@ -90,7 +90,7 @@ class TestTestTest: site.USER_SITE = tempfile.mkdtemp() def teardown_method(self, method): - if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + if hasattr(sys, 'real_prefix'): return os.chdir(self.old_cwd) @@ -101,7 +101,7 @@ class TestTestTest: site.USER_SITE = self.old_site def test_test(self): - if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + if hasattr(sys, 'real_prefix'): return dist = Distribution(dict( -- cgit v1.2.1 From f0eaf642ac52c02cc605ee1222bd143ef5f36623 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:06:51 -0500 Subject: Use skipif marker for real_prefix --- setuptools/tests/test_test.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index abd0038b..5d7b72ba 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -8,6 +8,8 @@ import site import sys import tempfile +import pytest + from setuptools.compat import StringIO, PY2 from setuptools.command.test import test from setuptools.dist import Distribution @@ -50,12 +52,10 @@ TEST_PY = DALS(""" """) +@pytest.mark.skipif('hasattr(sys, "real_prefix")') class TestTestTest: def setup_method(self, method): - if hasattr(sys, 'real_prefix'): - return - # Directory structure self.dir = tempfile.mkdtemp() os.mkdir(os.path.join(self.dir, 'name')) @@ -90,9 +90,6 @@ class TestTestTest: site.USER_SITE = tempfile.mkdtemp() def teardown_method(self, method): - if hasattr(sys, 'real_prefix'): - return - os.chdir(self.old_cwd) shutil.rmtree(self.dir) shutil.rmtree(site.USER_BASE) @@ -101,9 +98,6 @@ class TestTestTest: site.USER_SITE = self.old_site def test_test(self): - if hasattr(sys, 'real_prefix'): - return - dist = Distribution(dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], -- cgit v1.2.1 From 6a5d120fa48b91f4e4cd78404f48daa8f97a2bc4 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:08:30 -0500 Subject: Use context opener --- setuptools/tests/test_test.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 5d7b72ba..aec9ec98 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -61,27 +61,27 @@ class TestTestTest: os.mkdir(os.path.join(self.dir, 'name')) os.mkdir(os.path.join(self.dir, 'name', 'space')) os.mkdir(os.path.join(self.dir, 'name', 'space', 'tests')) + # setup.py setup = os.path.join(self.dir, 'setup.py') - f = open(setup, 'wt') - f.write(SETUP_PY) - f.close() + with open(setup, 'wt') as f: + f.write(SETUP_PY) self.old_cwd = os.getcwd() + # name/__init__.py init = os.path.join(self.dir, 'name', '__init__.py') - f = open(init, 'wb') - f.write(NS_INIT) - f.close() + with open(init, 'wb') as f: + f.write(NS_INIT) + # name/space/__init__.py init = os.path.join(self.dir, 'name', 'space', '__init__.py') - f = open(init, 'wt') - f.write('#empty\n') - f.close() + with open(init, 'wt') as f: + f.write('#empty\n') + # name/space/tests/__init__.py init = os.path.join(self.dir, 'name', 'space', 'tests', '__init__.py') - f = open(init, 'wt') - f.write(TEST_PY) - f.close() + with open(init, 'wt') as f: + f.write(TEST_PY) os.chdir(self.dir) self.old_base = site.USER_BASE -- cgit v1.2.1 From f6684c70f00276cc1ffa5225e543fbf7d7de6e71 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:13:45 -0500 Subject: Use useroverride fixture --- setuptools/tests/test_test.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index aec9ec98..6d279e40 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -53,6 +53,7 @@ TEST_PY = DALS(""" @pytest.mark.skipif('hasattr(sys, "real_prefix")') +@pytest.mark.usefixture('useroverride') class TestTestTest: def setup_method(self, method): @@ -84,18 +85,10 @@ class TestTestTest: f.write(TEST_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): 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_test(self): dist = Distribution(dict( -- cgit v1.2.1 From 2ebaaf2315395b99b6790717659cb26a25cb715f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:35:03 -0500 Subject: Replace setup/teardown with a shorter, more elegant fixture. --- setuptools/tests/test_test.py | 60 +++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 6d279e40..1f4a7dda 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -3,10 +3,8 @@ """develop tests """ import os -import shutil import site import sys -import tempfile import pytest @@ -52,44 +50,32 @@ TEST_PY = DALS(""" """) +@pytest.fixture +def sample_test(tmpdir_cwd): + os.makedirs('name/space/tests') + + # setup.py + with open('setup.py', 'wt') as f: + f.write(SETUP_PY) + + # name/__init__.py + with open('name/__init__.py', 'wb') as f: + f.write(NS_INIT) + + # name/space/__init__.py + with open('name/space/__init__.py', 'wt') as f: + f.write('#empty\n') + + # name/space/tests/__init__.py + with open('name/space/tests/__init__.py', 'wt') as f: + f.write(TEST_PY) + + @pytest.mark.skipif('hasattr(sys, "real_prefix")') -@pytest.mark.usefixture('useroverride') +@pytest.mark.usefixtures('user_override') +@pytest.mark.usefixtures('sample_test') class TestTestTest: - def setup_method(self, method): - # Directory structure - self.dir = tempfile.mkdtemp() - os.mkdir(os.path.join(self.dir, 'name')) - os.mkdir(os.path.join(self.dir, 'name', 'space')) - os.mkdir(os.path.join(self.dir, 'name', 'space', 'tests')) - - # setup.py - setup = os.path.join(self.dir, 'setup.py') - with open(setup, 'wt') as f: - f.write(SETUP_PY) - self.old_cwd = os.getcwd() - - # name/__init__.py - init = os.path.join(self.dir, 'name', '__init__.py') - with open(init, 'wb') as f: - f.write(NS_INIT) - - # name/space/__init__.py - init = os.path.join(self.dir, 'name', 'space', '__init__.py') - with open(init, 'wt') as f: - f.write('#empty\n') - - # name/space/tests/__init__.py - init = os.path.join(self.dir, 'name', 'space', 'tests', '__init__.py') - with open(init, 'wt') as f: - f.write(TEST_PY) - - os.chdir(self.dir) - - def teardown_method(self, method): - os.chdir(self.old_cwd) - shutil.rmtree(self.dir) - def test_test(self): dist = Distribution(dict( name='foo', -- cgit v1.2.1 From ea576715047f0b4356d2ee39ec7c603305db0e8a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:37:39 -0500 Subject: Use quiet context --- setuptools/tests/test_test.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 1f4a7dda..51c3a9b4 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -4,15 +4,15 @@ """ import os import site -import sys import pytest -from setuptools.compat import StringIO, PY2 +from setuptools.compat import PY2 from setuptools.command.test import test from setuptools.dist import Distribution from .textwrap import DALS +from . import contexts SETUP_PY = DALS(""" from setuptools import setup @@ -90,13 +90,10 @@ class TestTestTest: cmd.ensure_finalized() cmd.install_dir = site.USER_SITE cmd.user = 1 - old_stdout = sys.stdout - sys.stdout = StringIO() - try: - try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. + with contexts.quiet(): + try: cmd.run() - except SystemExit: # The test runner calls sys.exit, stop that making an error. + except SystemExit: + # The test runner calls sys.exit; suppress the exception pass - finally: - sys.stdout = old_stdout -- cgit v1.2.1 From 23c128e6ba47135134c317f42f1f42426eb9ae78 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:44:43 -0500 Subject: Suppress exceptions in a context for clarity, brevity, and reuse. --- setuptools/tests/test_test.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 51c3a9b4..41b7d078 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -91,9 +91,6 @@ class TestTestTest: cmd.install_dir = site.USER_SITE cmd.user = 1 with contexts.quiet(): - try: + # The test runner calls sys.exit + with contexts.suppress_exceptions(SystemExit): cmd.run() - except SystemExit: - # The test runner calls sys.exit; suppress the exception - pass - -- cgit v1.2.1 From adda5ac7b25a17843749f054e48bc36de4c54b72 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:45:38 -0500 Subject: Extract var --- setuptools/tests/test_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 41b7d078..f2b444f7 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -77,13 +77,14 @@ def sample_test(tmpdir_cwd): class TestTestTest: def test_test(self): - dist = Distribution(dict( + params = dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True, - )) + ) + dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.user = 1 -- cgit v1.2.1 From 69c864c159b9f960e8881f5a60d20453ad17a30f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:55:29 -0500 Subject: Use unicode literals to define files as text, and encode specifically when saving files. --- setuptools/tests/test_test.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index f2b444f7..4430e6ea 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -1,13 +1,12 @@ # -*- coding: UTF-8 -*- -"""develop tests -""" +from __future__ import unicode_literals + import os import site import pytest -from setuptools.compat import PY2 from setuptools.command.test import test from setuptools.dist import Distribution @@ -34,11 +33,6 @@ NS_INIT = DALS(""" __path__ = extend_path(__path__, __name__) """) -# Make sure this is Latin-1 binary, before writing: -if PY2: - NS_INIT = NS_INIT.decode('UTF-8') -NS_INIT = NS_INIT.encode('Latin-1') - TEST_PY = DALS(""" import unittest @@ -60,7 +54,7 @@ def sample_test(tmpdir_cwd): # name/__init__.py with open('name/__init__.py', 'wb') as f: - f.write(NS_INIT) + f.write(NS_INIT.encode('Latin-1')) # name/space/__init__.py with open('name/space/__init__.py', 'wt') as f: -- cgit v1.2.1 From 73dd2fa9592d68e037a27468c36fdf3b32e0e16f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 12:56:31 -0500 Subject: Update comment to reflect issue was reported in Distribute. --- setuptools/tests/test_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 4430e6ea..a66294c9 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -25,7 +25,7 @@ SETUP_PY = DALS(""" NS_INIT = DALS(""" # -*- coding: Latin-1 -*- - # Söme Arbiträry Ünicode to test Issüé 310 + # Söme Arbiträry Ünicode to test Distribute Issüé 310 try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: -- 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_test.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 6587dc40..4155a5b1 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -6,7 +6,6 @@ import os import site from distutils.errors import DistutilsError -import six import pytest from setuptools.command.test import test -- 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_test.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 4155a5b1..7ea43c57 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -70,7 +70,6 @@ def sample_test(tmpdir_cwd): @pytest.mark.usefixtures('user_override') @pytest.mark.usefixtures('sample_test') class TestTestTest: - def test_test(self): params = dict( name='foo', -- cgit v1.2.1 From b5d00314293e400bc72f3699e428f168ac74d824 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 26 Jun 2017 17:58:09 +0200 Subject: tests: improve `test` command test - cleanup test: we're not installing, so no need to override the user site, or skip the test when run with a virtual environment - use pytest support for capturing output (`context.quiet` does not work with Python 2), and check the output --- setuptools/tests/test_test.py | 51 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 7ea43c57..02cba00d 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -2,9 +2,8 @@ from __future__ import unicode_literals +from distutils import log import os -import site -from distutils.errors import DistutilsError import pytest @@ -66,26 +65,28 @@ def sample_test(tmpdir_cwd): f.write(TEST_PY) -@pytest.mark.skipif('hasattr(sys, "real_prefix")') -@pytest.mark.usefixtures('user_override') -@pytest.mark.usefixtures('sample_test') -class TestTestTest: - def test_test(self): - params = dict( - name='foo', - packages=['name', 'name.space', 'name.space.tests'], - namespace_packages=['name'], - test_suite='name.space.tests.test_suite', - use_2to3=True, - ) - dist = Distribution(params) - dist.script_name = 'setup.py' - cmd = test(dist) - cmd.user = 1 - cmd.ensure_finalized() - cmd.install_dir = site.USER_SITE - cmd.user = 1 - with contexts.quiet(): - # The test runner calls sys.exit - with contexts.suppress_exceptions(SystemExit): - cmd.run() +@pytest.fixture +def silent_log(): + # Running some of the other tests will automatically + # change the log level to info, messing our output. + log.set_verbosity(0) + + +@pytest.mark.usefixtures('sample_test', 'silent_log') +def test_test(capfd): + params = dict( + name='foo', + packages=['name', 'name.space', 'name.space.tests'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', + use_2to3=True, + ) + dist = Distribution(params) + dist.script_name = 'setup.py' + cmd = test(dist) + cmd.ensure_finalized() + # The test runner calls sys.exit + with contexts.suppress_exceptions(SystemExit): + cmd.run() + out, err = capfd.readouterr() + assert out == 'Foo\n' -- cgit v1.2.1 From 803707a68f228f452703333cbf75708938c2eb9e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 26 Jun 2017 18:28:07 +0200 Subject: tests: check `test` command run tests only once --- setuptools/tests/test_test.py | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 02cba00d..960527bc 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from distutils import log import os +import sys import pytest @@ -66,13 +67,13 @@ def sample_test(tmpdir_cwd): @pytest.fixture -def silent_log(): +def quiet_log(): # Running some of the other tests will automatically # change the log level to info, messing our output. log.set_verbosity(0) -@pytest.mark.usefixtures('sample_test', 'silent_log') +@pytest.mark.usefixtures('sample_test', 'quiet_log') def test_test(capfd): params = dict( name='foo', @@ -90,3 +91,41 @@ def test_test(capfd): cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n' + + +@pytest.mark.xfail( + sys.version_info < (2, 7), + reason="No discover support for unittest on Python 2.6", +) +@pytest.mark.usefixtures('tmpdir_cwd', 'quiet_log') +def test_tests_are_run_once(capfd): + params = dict( + name='foo', + packages=['dummy'], + ) + with open('setup.py', 'wt') as f: + f.write('from setuptools import setup; setup(\n') + for k, v in sorted(params.items()): + f.write(' %s=%r,\n' % (k, v)) + f.write(')\n') + os.makedirs('dummy') + with open('dummy/__init__.py', 'wt'): + pass + with open('dummy/test_dummy.py', 'wt') as f: + f.write(DALS( + """ + from __future__ import print_function + import unittest + class TestTest(unittest.TestCase): + def test_test(self): + print('Foo') + """)) + dist = Distribution(params) + dist.script_name = 'setup.py' + cmd = test(dist) + cmd.ensure_finalized() + # The test runner calls sys.exit + with contexts.suppress_exceptions(SystemExit): + cmd.run() + out, err = capfd.readouterr() + assert out == 'Foo\n' -- cgit v1.2.1 From d3215c10b6f9ccd8940f9345642ee0718f158585 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Sat, 27 Oct 2018 11:25:51 +0100 Subject: Mark Py 2/3-only tests as skip instead of xfail Also reuse pre-defined py2_only and py3_only decorators where appropriate. --- setuptools/tests/test_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 960527bc..4ba70484 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -93,7 +93,7 @@ def test_test(capfd): assert out == 'Foo\n' -@pytest.mark.xfail( +@pytest.mark.skipif( sys.version_info < (2, 7), reason="No discover support for unittest on Python 2.6", ) -- cgit v1.2.1 From 98056a680fde6bede9ce4c159b72d1ac01bf9067 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Sat, 27 Oct 2018 11:39:30 +0100 Subject: Remove pytest marker and code for Python < 2.7 --- setuptools/tests/test_test.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 4ba70484..8d1425e1 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -93,10 +93,6 @@ def test_test(capfd): assert out == 'Foo\n' -@pytest.mark.skipif( - sys.version_info < (2, 7), - reason="No discover support for unittest on Python 2.6", -) @pytest.mark.usefixtures('tmpdir_cwd', 'quiet_log') def test_tests_are_run_once(capfd): params = dict( -- cgit v1.2.1 From 5cd86987530892bfb01f68ad5f1a2b997a3d01e7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 26 Jan 2019 20:20:12 -0500 Subject: Feed the hobgoblins (delint). --- setuptools/tests/test_test.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 8d1425e1..faaa6ba9 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals from distutils import log import os -import sys import pytest -- cgit v1.2.1 From d89682fcba90595d5d6aaf071d6efcc815bceba8 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 21 Oct 2019 16:49:13 -0700 Subject: Change coding cookie to use utf-8 (lowercase) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While perfectly valid, the encoding 'UTF-8' (uppercase) is not recognized by the Emacs MULE system. As such, it displays the following warning when opening a file with it used as an encoding cookie: Warning (mule): Invalid coding system ‘UTF-8’ is specified for the current buffer/file by the :coding tag. It is highly recommended to fix it before writing to a file. Some discussion of this can be found at: https://stackoverflow.com/questions/14031724/how-to-make-emacs-accept-utf-8-uppercase-encoding While the post does offer a workaround for Emacs users, rather than ask all to implement it, use the more typical utf-8 (lowercase). --- setuptools/tests/test_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index faaa6ba9..3415913b 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -1,4 +1,4 @@ -# -*- coding: UTF-8 -*- +# -*- coding: utf-8 -*- from __future__ import unicode_literals -- cgit v1.2.1 From cd84510713ada48bf33d4efa749c2952e3fc1a49 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 19 Oct 2019 08:39:30 -0700 Subject: Deprecate the test command Provide a warning to users. Suggest using tox as an alternative generic entry point. Refs #1684 --- setuptools/tests/test_test.py | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index faaa6ba9..382bd640 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals +import mock from distutils import log import os @@ -124,3 +125,52 @@ def test_tests_are_run_once(capfd): cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n' + + +@pytest.mark.usefixtures('sample_test') +def test_warns_deprecation(capfd): + params = dict( + name='foo', + packages=['name', 'name.space', 'name.space.tests'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', + use_2to3=True + ) + dist = Distribution(params) + dist.script_name = 'setup.py' + cmd = test(dist) + cmd.ensure_finalized() + cmd.announce = mock.Mock() + cmd.run() + capfd.readouterr() + msg = ( + "WARNING: Testing via this command is deprecated and will be " + "removed in a future version. Users looking for a generic test " + "entry point independent of test runner are encouraged to use " + "tox." + ) + cmd.announce.assert_any_call(msg, log.WARN) + + +@pytest.mark.usefixtures('sample_test') +def test_deprecation_stderr(capfd): + params = dict( + name='foo', + packages=['name', 'name.space', 'name.space.tests'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', + use_2to3=True + ) + dist = Distribution(params) + dist.script_name = 'setup.py' + cmd = test(dist) + cmd.ensure_finalized() + cmd.run() + out, err = capfd.readouterr() + msg = ( + "WARNING: Testing via this command is deprecated and will be " + "removed in a future version. Users looking for a generic test " + "entry point independent of test runner are encouraged to use " + "tox.\n" + ) + assert msg in err -- cgit v1.2.1 From 4069e0b536802a47c8c15ce839fd98a5f4c84620 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 21 Oct 2019 17:01:18 -0700 Subject: Remove outdated comment and suppressed exception from test_test.py The test command has not called sys.exit since commit 2c4fd43277fc477d85b50e15c37b176136676270. --- setuptools/tests/test_test.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 280c837b..6242a018 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -86,9 +86,7 @@ def test_test(capfd): dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() - # The test runner calls sys.exit - with contexts.suppress_exceptions(SystemExit): - cmd.run() + cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n' @@ -120,9 +118,7 @@ def test_tests_are_run_once(capfd): dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() - # The test runner calls sys.exit - with contexts.suppress_exceptions(SystemExit): - cmd.run() + cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n' -- cgit v1.2.1 From 3d4d8b9dde61b87271861b8c7ebeb168ac4fa72b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Jan 2020 12:46:30 -0500 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_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 6242a018..8ee70a7e 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -12,7 +12,7 @@ from setuptools.command.test import test from setuptools.dist import Distribution from .textwrap import DALS -from . import contexts + SETUP_PY = DALS(""" from setuptools import setup -- cgit v1.2.1 From 2d607a9e59aa854b387f22d79301acb8739b133a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 10 May 2020 13:19:52 -0400 Subject: Emit deprecation warning when 2to3 is used. Ref #2086. --- setuptools/tests/test_test.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 8ee70a7e..0f77d8ff 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -73,7 +73,11 @@ def quiet_log(): log.set_verbosity(0) +ack_2to3 = pytest.mark.filterwarnings('ignore:2to3 support is deprecated') + + @pytest.mark.usefixtures('sample_test', 'quiet_log') +@ack_2to3 def test_test(capfd): params = dict( name='foo', @@ -124,6 +128,7 @@ def test_tests_are_run_once(capfd): @pytest.mark.usefixtures('sample_test') +@ack_2to3 def test_warns_deprecation(capfd): params = dict( name='foo', @@ -149,6 +154,7 @@ def test_warns_deprecation(capfd): @pytest.mark.usefixtures('sample_test') +@ack_2to3 def test_deprecation_stderr(capfd): params = dict( name='foo', -- 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_test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 0f77d8ff..892fd120 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -10,6 +10,7 @@ import pytest from setuptools.command.test import test from setuptools.dist import Distribution +from setuptools.tests import ack_2to3 from .textwrap import DALS @@ -73,9 +74,6 @@ def quiet_log(): log.set_verbosity(0) -ack_2to3 = pytest.mark.filterwarnings('ignore:2to3 support is deprecated') - - @pytest.mark.usefixtures('sample_test', 'quiet_log') @ack_2to3 def test_test(capfd): -- 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_test.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 892fd120..180562e2 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - import mock from distutils import log import os @@ -110,7 +106,6 @@ def test_tests_are_run_once(capfd): with open('dummy/test_dummy.py', 'wt') as f: f.write(DALS( """ - from __future__ import print_function import unittest class TestTest(unittest.TestCase): def test_test(self): -- 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_test.py | 100 ++++++++---------------------------------- 1 file changed, 19 insertions(+), 81 deletions(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 180562e2..4e7193c8 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -6,12 +6,12 @@ import pytest from setuptools.command.test import test from setuptools.dist import Distribution -from setuptools.tests import ack_2to3 from .textwrap import DALS -SETUP_PY = DALS(""" +SETUP_PY = DALS( + """ from setuptools import setup setup(name='foo', @@ -19,9 +19,11 @@ SETUP_PY = DALS(""" namespace_packages=['name'], test_suite='name.space.tests.test_suite', ) - """) + """ +) -NS_INIT = DALS(""" +NS_INIT = DALS( + """ # -*- coding: Latin-1 -*- # Söme Arbiträry Ünicode to test Distribute Issüé 310 try: @@ -29,17 +31,20 @@ NS_INIT = DALS(""" except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) - """) + """ +) -TEST_PY = DALS(""" +TEST_PY = DALS( + """ import unittest class TestTest(unittest.TestCase): def test_test(self): - print "Foo" # Should fail under Python 3 unless 2to3 is used + print "Foo" # Should fail under Python 3 test_suite = unittest.makeSuite(TestTest) - """) + """ +) @pytest.fixture @@ -70,25 +75,6 @@ def quiet_log(): log.set_verbosity(0) -@pytest.mark.usefixtures('sample_test', 'quiet_log') -@ack_2to3 -def test_test(capfd): - params = dict( - name='foo', - packages=['name', 'name.space', 'name.space.tests'], - namespace_packages=['name'], - test_suite='name.space.tests.test_suite', - use_2to3=True, - ) - dist = Distribution(params) - dist.script_name = 'setup.py' - cmd = test(dist) - cmd.ensure_finalized() - cmd.run() - out, err = capfd.readouterr() - assert out == 'Foo\n' - - @pytest.mark.usefixtures('tmpdir_cwd', 'quiet_log') def test_tests_are_run_once(capfd): params = dict( @@ -104,13 +90,16 @@ def test_tests_are_run_once(capfd): with open('dummy/__init__.py', 'wt'): pass with open('dummy/test_dummy.py', 'wt') as f: - f.write(DALS( - """ + f.write( + DALS( + """ import unittest class TestTest(unittest.TestCase): def test_test(self): print('Foo') - """)) + """ + ) + ) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) @@ -118,54 +107,3 @@ def test_tests_are_run_once(capfd): cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n' - - -@pytest.mark.usefixtures('sample_test') -@ack_2to3 -def test_warns_deprecation(capfd): - params = dict( - name='foo', - packages=['name', 'name.space', 'name.space.tests'], - namespace_packages=['name'], - test_suite='name.space.tests.test_suite', - use_2to3=True - ) - dist = Distribution(params) - dist.script_name = 'setup.py' - cmd = test(dist) - cmd.ensure_finalized() - cmd.announce = mock.Mock() - cmd.run() - capfd.readouterr() - msg = ( - "WARNING: Testing via this command is deprecated and will be " - "removed in a future version. Users looking for a generic test " - "entry point independent of test runner are encouraged to use " - "tox." - ) - cmd.announce.assert_any_call(msg, log.WARN) - - -@pytest.mark.usefixtures('sample_test') -@ack_2to3 -def test_deprecation_stderr(capfd): - params = dict( - name='foo', - packages=['name', 'name.space', 'name.space.tests'], - namespace_packages=['name'], - test_suite='name.space.tests.test_suite', - use_2to3=True - ) - dist = Distribution(params) - dist.script_name = 'setup.py' - cmd = test(dist) - cmd.ensure_finalized() - cmd.run() - out, err = capfd.readouterr() - msg = ( - "WARNING: Testing via this command is deprecated and will be " - "removed in a future version. Users looking for a generic test " - "entry point independent of test runner are encouraged to use " - "tox.\n" - ) - assert msg in err -- 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_test.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_test.py') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 4e7193c8..6bce8e20 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -1,4 +1,3 @@ -import mock from distutils import log import os -- cgit v1.2.1