testing-cabal / testtools

Testtools - tasteful testing for python
https://testtools.readthedocs.io/en/latest/
Other
94 stars 88 forks source link

Compatibility with Python 3.11 #325

Closed hrnciar closed 2 years ago

hrnciar commented 2 years ago

Hello,

in Fedora we started to build testtools with prereleases of Python 3.11, currently 6th alpha. There is a bunch of failing tests. Some of them look to be caused by enhanced error locations in tracebacks[0]. Downstream report. Full log can be found here.

[0] https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks

======================================================================
FAIL: testtools.tests.test_run.TestRun.test_run_list_failed_import
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_run.py", line 200, in test_run_list_failed_import
    self.assertThat(out.getvalue(), DocTestMatches("""\
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: Expected:
    unittest.loader._FailedTest.runexample
    Failed to import test module: runexample
    Traceback (most recent call last):
      File ".../loader.py", line ..., in _find_test_path
        package = self._get_module_from_name(name)
      File ".../loader.py", line ..., in _get_module_from_name
        __import__(name)
      File ".../runexample/__init__.py", line 1
        class not in
    ...^...
    SyntaxError: invalid syntax

Got:
    unittest.loader._FailedTest.runexample
    Failed to import test module: runexample
    Traceback (most recent call last):
      File "/usr/lib64/python3.11/unittest/loader.py", line 440, in _find_test_path
        package = self._get_module_from_name(name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/unittest/loader.py", line 350, in _get_module_from_name
        __import__(name)
        ^^^^^^^^^^^^^^^^
      File "/tmp/tmpfo4g6gge/runexample/__init__.py", line 1
        class not in
              ^^^
    SyntaxError: invalid syntax
    <BLANKLINE>
======================================================================
FAIL: testtools.tests.test_testresult.TestNonAsciiResults.test_syntax_error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 2675, in test_syntax_error
    self.assertIn(self._as_output(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 399, in assertIn
    self.assertThat(haystack, Contains(needle), message)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: '  File "<string>", line 1\n    f(a, b c)\n         ^\nSyntaxError: ' not in 'Tests running...\n======================================================================\nERROR: test_syntax_error.Test.runTest\n----------------------------------------------------------------------\nTraceback (most recent call last):\n  File "/tmp/TestNonAsciiResultsbprecgag/test_syntax_error.py", line 6, in runTest\n    exec (\'f(a, b c)\')\n    ^^^^^^^^^^^^^^^^^^\n  File "<string>", line 1\n    f(a, b c)\n         ^^^\nSyntaxError: invalid syntax. Perhaps you forgot a comma?\n\nRan 1 test in 0.001s\nFAILED (failures=1)\n'
======================================================================
FAIL: testtools.tests.test_testresult.TestNonAsciiResults.test_unprintable_exception
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 2651, in test_unprintable_exception
    self.assertIn(self._as_output(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 399, in assertIn
    self.assertThat(haystack, Contains(needle), message)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: 'UnprintableError: <unprintable UnprintableError object>\n' not in 'Tests running...\n======================================================================\nERROR: test_unprintable_exception.Test.runTest\n----------------------------------------------------------------------\nTraceback (most recent call last):\n  File "/tmp/TestNonAsciiResults8eefw0o5/test_unprintable_exception.py", line 13, in runTest\n    raise UnprintableError\n    ^^^^^^^^^^^^^^^^^^^^^^\ntest_unprintable_exception.UnprintableError: <exception str() failed>\n\nRan 1 test in 0.001s\nFAILED (failures=1)\n'
======================================================================
FAIL: testtools.tests.test_testresult.TestNonAsciiResultsWithUnittest.test_syntax_error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 2675, in test_syntax_error
    self.assertIn(self._as_output(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 399, in assertIn
    self.assertThat(haystack, Contains(needle), message)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: '  File "<string>", line 1\n    f(a, b c)\n         ^\nSyntaxError: ' not in 'E\n======================================================================\nERROR: runTest (test_syntax_error.Test)\ntest_syntax_error.Test.runTest\n----------------------------------------------------------------------\ntesttools.testresult.real._StringException: Traceback (most recent call last):\n  File "/tmp/TestNonAsciiResultsWithUnittest234klsm1/test_syntax_error.py", line 6, in runTest\n    exec (\'f(a, b c)\')\n    ^^^^^^^^^^^^^^^^^^\n  File "<string>", line 1\n    f(a, b c)\n         ^^^\nSyntaxError: invalid syntax. Perhaps you forgot a comma?\n\n\n----------------------------------------------------------------------\nRan 1 test in 0.000s\n\nFAILED (errors=1)\n'
======================================================================
FAIL: testtools.tests.test_testresult.TestNonAsciiResultsWithUnittest.test_unprintable_exception
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 2651, in test_unprintable_exception
    self.assertIn(self._as_output(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 399, in assertIn
    self.assertThat(haystack, Contains(needle), message)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: 'UnprintableError: <unprintable UnprintableError object>\n' not in 'E\n======================================================================\nERROR: runTest (test_unprintable_exception.Test)\ntest_unprintable_exception.Test.runTest\n----------------------------------------------------------------------\ntesttools.testresult.real._StringException: Traceback (most recent call last):\n  File "/tmp/TestNonAsciiResultsWithUnittest8s4fceaw/test_unprintable_exception.py", line 13, in runTest\n    raise UnprintableError\n    ^^^^^^^^^^^^^^^^^^^^^^\ntest_unprintable_exception.UnprintableError: <exception str() failed>\n\n\n----------------------------------------------------------------------\nRan 1 test in 0.000s\n\nFAILED (errors=1)\n'
======================================================================
FAIL: testtools.tests.test_testresult.TestTestResult.test_traceback_formatting_with_stack_hidden
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/runtest.py", line 193, in _run_user
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 702, in _run_test_method
    return self._get_test_method()()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 1281, in test_traceback_formatting_with_stack_hidden
    self.assertThat(
    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: Expected:
    Traceback (most recent call last):
      File "...testtools...tests...test_testresult.py", line ..., in error
        1/0
    ZeroDivisionError: ...
Got:
    Traceback (most recent call last):
      File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 98, in error
        1/0
        ~^~
    ZeroDivisionError: division by zero
======================================================================
FAIL: testtools.tests.test_testresult.TestTestResult.test_traceback_formatting_without_stack_hidden
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/runtest.py", line 193, in _run_user
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 702, in _run_test_method
    return self._get_test_method()()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 1264, in test_traceback_formatting_without_stack_hidden
    self.assertThat(
    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: Differences (unified diff with -expected +actual):
    @@ -1,8 +1,11 @@
     Traceback (most recent call last):
    -  File "...testtools...runtest.py", line ..., in _run_user
    +  File "/builddir/build/BUILD/testtools-2.5.0/testtools/runtest.py", line 193, in _run_user
         return fn(*args, **kwargs)
    -  File "...testtools...testcase.py", line ..., in _run_test_method
    +           ^^^^^^^^^^^^^^^^^^^
    +  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 702, in _run_test_method
         return self._get_test_method()()
    -  File "...testtools...tests...test_testresult.py", line ..., in error
    +           ^^^^^^^^^^^^^^^^^^^^^^^^^
    +  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 98, in error
         1/0
    -ZeroDivisionError: ...
    +    ~^~
    +ZeroDivisionError: division by zero
======================================================================
FAIL: testtools.tests.test_testresult.TestTestResult.test_traceback_with_locals
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/runtest.py", line 193, in _run_user
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 702, in _run_test_method
    return self._get_test_method()()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 1320, in test_traceback_with_locals
    self.assertThat(
    ^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: Differences (unified diff with -expected +actual):
    @@ -1,16 +1,19 @@
     Traceback (most recent call last):
    -  File "...testtools...runtest.py", line ..., in _run_user
    +  File "/builddir/build/BUILD/testtools-2.5.0/testtools/runtest.py", line 193, in _run_user
         return fn(*args, **kwargs)
    -    args = ...
    -    fn = ...
    -    kwargs = ...
    -    self = ...
    -  File "...testtools...testcase.py", line ..., in _run_test_method
    +           ^^^^^^^^^^^^^^^^^^^
    +    args = (<ExtendedToOriginalDecorator <testtools.testresult.real.TestResult run=1 errors=0 failures=0>>,)
    +    fn = <bound method TestCase._run_test_method of <testtools.tests.test_testresult.make_erroring_test.<locals>.Test.error id=0x7f4d1c152750>>
    +    kwargs = {}
    +    self = <testtools.runtest.RunTest object at 0x7f4d1c150fd0>
    +  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 702, in _run_test_method
         return self._get_test_method()()
    -    result = ...
    -    self = ...
    -  File "...testtools...tests...test_testresult.py", line ..., in error
    +           ^^^^^^^^^^^^^^^^^^^^^^^^^
    +    result = <ExtendedToOriginalDecorator <testtools.testresult.real.TestResult run=1 errors=0 failures=0>>
    +    self = <testtools.tests.test_testresult.make_erroring_test.<locals>.Test.error id=0x7f4d1c152750>
    +  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testresult.py", line 98, in error
         1/0
    +    ~^~
         a = 1
    -    self = ...
    -ZeroDivisionError: ...
    +    self = <testtools.tests.test_testresult.make_erroring_test.<locals>.Test.error id=0x7f4d1c152750>
    +ZeroDivisionError: division by zero
======================================================================
FAIL: testtools.tests.test_testsuite.TestConcurrentStreamTestSuiteRun.test_broken_runner
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/tests/test_testsuite.py", line 179, in test_broken_runner
    self.assertThat(events[2][6].decode('utf8'), DocTestMatches("""\
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/testtools-2.5.0/testtools/testcase.py", line 480, in assertThat
    raise mismatch_error
    ^^^^^^^^^^^^^^^^^^^^
testtools.matchers._impl.MismatchError: Expected:
      File "...testtools/testsuite.py", line ..., in _run_test
        test.run(process_result)
Got:
      File "/builddir/build/BUILD/testtools-2.5.0/testtools/testsuite.py", line 186, in _run_test
        test.run(process_result)
        ^^^^^^^^^^^^^^^^^^^^^^^^

Ran 2627 tests in 1.257s
FAILED (failures=9)