From ad05abd2f7fb4e43badc2441ab6d187caa31512d Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 7 May 2021 13:25:57 -0400 Subject: [PATCH 1/4] Just run unit tests normally on Python 3. --- src/allmydata/test/python3_tests.py | 37 ----------------------------- src/allmydata/util/_python3.py | 10 ++------ tox.ini | 3 +-- 3 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 src/allmydata/test/python3_tests.py diff --git a/src/allmydata/test/python3_tests.py b/src/allmydata/test/python3_tests.py deleted file mode 100644 index 9326caa51..000000000 --- a/src/allmydata/test/python3_tests.py +++ /dev/null @@ -1,37 +0,0 @@ -""" -This module defines the subset of the full test suite which is expected to -pass on Python 3 in a way which makes that suite discoverable by trial. - -This module has been ported to Python 3. -""" - -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from future.utils import PY2 -if PY2: - from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 - -from twisted.python.reflect import ( - namedModule, -) -from twisted.trial.runner import ( - TestLoader, -) -from twisted.trial.unittest import ( - TestSuite, -) - -from allmydata.util._python3 import ( - PORTED_TEST_MODULES, -) - -def testSuite(): - loader = TestLoader() - return TestSuite(list( - loader.loadModule(namedModule(module)) - for module - in PORTED_TEST_MODULES - )) diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 5f78af626..4a771a4d5 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -1,14 +1,8 @@ """ Track the port to Python 3. -The two easiest ways to run the part of the test suite which is expected to -pass on Python 3 are:: - - $ tox -e py36 - -and:: - - $ trial allmydata.test.python3_tests +At this point all unit tests have been ported to Python 3, so you can just run +them normally. This module has been ported to Python 3. """ diff --git a/tox.ini b/tox.ini index 4b52fd316..84eafd910 100644 --- a/tox.ini +++ b/tox.ini @@ -62,8 +62,7 @@ extras = test setenv = # Define TEST_SUITE in the environment as an aid to constructing the # correct test command below. - !py36: TEST_SUITE = allmydata - py36: TEST_SUITE = allmydata.test.python3_tests + TEST_SUITE = allmydata commands = # As an aid to debugging, dump all of the Python packages and their From 15399b8eba4fc2dadee9de35c34f8b7b4960739c Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 7 May 2021 13:26:14 -0400 Subject: [PATCH 2/4] News file. --- newsfragments/3705.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3705.minor diff --git a/newsfragments/3705.minor b/newsfragments/3705.minor new file mode 100644 index 000000000..e69de29bb From 930329126d4d041ab4166139afe5fee01c04fa4e Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 7 May 2021 13:28:01 -0400 Subject: [PATCH 3/4] One final test module to port to Python 3 (nominally). --- src/allmydata/test/test_python2_regressions.py | 12 ++++++++++++ src/allmydata/util/_python3.py | 1 + 2 files changed, 13 insertions(+) diff --git a/src/allmydata/test/test_python2_regressions.py b/src/allmydata/test/test_python2_regressions.py index 59b16d011..c641d2dba 100644 --- a/src/allmydata/test/test_python2_regressions.py +++ b/src/allmydata/test/test_python2_regressions.py @@ -2,6 +2,16 @@ Tests to check for Python2 regressions """ +from __future__ import unicode_literals +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from future.utils import PY2 +if PY2: + from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 + +from unittest import skipUnless from inspect import isclass from twisted.python.modules import getModule @@ -37,10 +47,12 @@ def defined_here(cls, where): """ return cls.__module__ == where + class PythonTwoRegressions(TestCase): """ Regression tests for Python 2 behaviors related to Python 3 porting. """ + @skipUnless(PY2, "No point in running on Python 3.") def test_new_style_classes(self): """ All classes in Tahoe-LAFS are new-style. diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 4a771a4d5..18575d624 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -240,6 +240,7 @@ PORTED_TEST_MODULES = [ "allmydata.test.test_node", "allmydata.test.test_observer", "allmydata.test.test_pipeline", + "allmydata.test.test_python2_regressions", "allmydata.test.test_python3", "allmydata.test.test_repairer", "allmydata.test.test_runner", From 1fbeb6e54eaa54cf8587e4013908adaddab069ea Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 7 May 2021 13:43:20 -0400 Subject: [PATCH 4/4] It's gone. --- src/allmydata/util/_python3.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 18575d624..51c7ad20f 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -102,7 +102,6 @@ PORTED_MODULES = [ "allmydata.test.matchers", "allmydata.test.mutable", "allmydata.test.mutable.util", - "allmydata.test.python3_tests", "allmydata.test.storage_plugin", "allmydata.test.strategies", "allmydata.test.web",