Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.10: TestTrialUnittest.test_trial_error fails due to DeprecationWarning in twisted #8663

Closed
hroncok opened this issue May 12, 2021 · 1 comment · Fixed by #8664
Closed
Labels
type: selftests a problem in the tests of pytest

Comments

@hroncok
Copy link
Member

hroncok commented May 12, 2021

This is Python 3.10.0b1 on Fedora Linux.

On branch main @ 045ad5a:

$ tox -e py310-unittestextras -- testing/test_unittest.py
...
py310-unittestextras inst-nodeps: ...pytest/.tox/.tmp/package/3/pytest-6.3.0.dev440+g045ad5ac2.tar.gz
py310-unittestextras installed: argcomplete==1.12.3,asynctest==0.13.0,attrs==21.2.0,Automat==20.2.0,certifi==2020.12.5,chardet==4.0.0,constantly==15.1.0,elementpath==2.2.2,hyperlink==21.0.0,hypothesis==6.12.0,idna==2.10,incremental==21.3.0,iniconfig==1.1.1,mock==4.0.3,nose==1.3.7,packaging==20.9,pluggy==0.13.1,py==1.10.0,Pygments==2.9.0,pyparsing==2.4.7,pytest @ file://...pytest/.tox/.tmp/package/3/pytest-6.3.0.dev440%2Bg045ad5ac2.tar.gz,requests==2.25.1,six==1.16.0,sortedcontainers==2.3.0,toml==0.10.2,Twisted==21.2.0,urllib3==1.26.4,xmlschema==1.6.2,zope.interface==5.4.0
py310-unittestextras run-test-pre: PYTHONHASHSEED='761603216'
py310-unittestextras run-test: commands[0] | pytest testing/test_unittest.py
============================= test session starts ==============================
platform linux -- Python 3.10.0b1, pytest-6.3.0.dev440+g045ad5ac2, py-1.10.0, pluggy-0.13.1
cachedir: .tox/py310-unittestextras/.pytest_cache
rootdir: ...pytest, configfile: pyproject.toml
plugins: hypothesis-6.12.0
collected 69 items

testing/test_unittest.py ........................F...................... [ 68%]
....................s.                                                   [100%]

=================================== FAILURES ===================================
______________________ TestTrialUnittest.test_trial_error ______________________

self = <test_unittest.TestTrialUnittest object at 0x7f61f20d9ae0>
pytester = <Pytester PosixPath('/tmp/pytest-of-churchyard/pytest-6/test_trial_error0')>

    def test_trial_error(self, pytester: Pytester) -> None:
        pytester.makepyfile(
            """
            from twisted.trial.unittest import TestCase
            from twisted.internet.defer import Deferred
            from twisted.internet import reactor
    
            class TC(TestCase):
                def test_one(self):
                    crash
    
                def test_two(self):
                    def f(_):
                        crash
    
                    d = Deferred()
                    d.addCallback(f)
                    reactor.callLater(0.3, d.callback, None)
                    return d
    
                def test_three(self):
                    def f():
                        pass # will never get called
                    reactor.callLater(0.3, f)
                # will crash at teardown
    
                def test_four(self):
                    def f(_):
                        reactor.callLater(0.3, f)
                        crash
    
                    d = Deferred()
                    d.addCallback(f)
                    reactor.callLater(0.3, d.callback, None)
                    return d
                # will crash both at test time and at teardown
        """
        )
        result = pytester.runpytest("-vv", "-oconsole_output_style=classic")
>       result.stdout.fnmatch_lines(
            [
                "test_trial_error.py::TC::test_four FAILED",
                "test_trial_error.py::TC::test_four ERROR",
                "test_trial_error.py::TC::test_one FAILED",
                "test_trial_error.py::TC::test_three FAILED",
                "test_trial_error.py::TC::test_two FAILED",
                "*ERRORS*",
                "*_ ERROR at teardown of TC.test_four _*",
                "*DelayedCalls*",
                "*= FAILURES =*",
                "*_ TC.test_four _*",
                "*NameError*crash*",
                "*_ TC.test_one _*",
                "*NameError*crash*",
                "*_ TC.test_three _*",
                "*DelayedCalls*",
                "*_ TC.test_two _*",
                "*NameError*crash*",
                "*= 4 failed, 1 error in *",
            ]
        )
E       Failed: nomatch: 'test_trial_error.py::TC::test_four FAILED'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.10.0b1, pytest-6.3.0.dev440+g045ad5ac2, py-1.10.0, pluggy-0.13.1 -- ...pytest/.tox/py310-unittestextras/bin/python'
E           and: 'cachedir: .pytest_cache'
E           and: 'rootdir: /tmp/pytest-of-churchyard/pytest-6/test_trial_error0'
E           and: 'collecting ... collected 4 items'
E           and: ''
E       exact match: 'test_trial_error.py::TC::test_four FAILED'
E       exact match: 'test_trial_error.py::TC::test_four ERROR'
E       exact match: 'test_trial_error.py::TC::test_one FAILED'
E       exact match: 'test_trial_error.py::TC::test_three FAILED'
E       exact match: 'test_trial_error.py::TC::test_two FAILED'
E       nomatch: '*ERRORS*'
E           and: ''
E       fnmatch: '*ERRORS*'
E          with: '==================================== ERRORS ===================================='
E       fnmatch: '*_ ERROR at teardown of TC.test_four _*'
E          with: '______________________ ERROR at teardown of TC.test_four _______________________'
E       nomatch: '*DelayedCalls*'
E           and: "'NoneType' object is not iterable"
E           and: ''
E           and: 'During handling of the above exception, another exception occurred:'
E           and: 'NOTE: Incompatible Exception Representation, displaying natively:'
E           and: ''
E           and: 'twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.'
E       fnmatch: '*DelayedCalls*'
E          with: 'DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)'
E       nomatch: '*= FAILURES =*'
E           and: '<DelayedCall 0x7f61f1fa61d0 [0.2993643283843994s] called=0 cancelled=0 TC.test_four.<locals>.f()>'
E       fnmatch: '*= FAILURES =*'
E          with: '=================================== FAILURES ==================================='
E       fnmatch: '*_ TC.test_four _*'
E          with: '_________________________________ TC.test_four _________________________________'
E       nomatch: '*NameError*crash*'
E           and: ''
E           and: '_ = None'
E           and: ''
E           and: '    def f(_):'
E           and: '        reactor.callLater(0.3, f)'
E           and: '>       crash'
E       fnmatch: '*NameError*crash*'
E          with: "E       NameError: name 'crash' is not defined"
E       nomatch: '*_ TC.test_one _*'
E           and: ''
E           and: 'test_trial_error.py:27: NameError'
E       fnmatch: '*_ TC.test_one _*'
E          with: '_________________________________ TC.test_one __________________________________'
E       nomatch: '*NameError*crash*'
E           and: ''
E           and: 'self = <test_trial_error.TC testMethod=test_one>'
E           and: ''
E           and: '    def test_one(self):'
E           and: '>       crash'
E       fnmatch: '*NameError*crash*'
E          with: "E       NameError: name 'crash' is not defined"
E       nomatch: '*_ TC.test_three _*'
E           and: ''
E           and: 'test_trial_error.py:7: NameError'
E       fnmatch: '*_ TC.test_three _*'
E          with: '________________________________ TC.test_three _________________________________'
E       nomatch: '*DelayedCalls*'
E           and: "'NoneType' object is not iterable"
E           and: ''
E           and: 'During handling of the above exception, another exception occurred:'
E           and: 'NOTE: Incompatible Exception Representation, displaying natively:'
E           and: ''
E           and: 'twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.'
E       fnmatch: '*DelayedCalls*'
E          with: 'DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)'
E       nomatch: '*_ TC.test_two _*'
E           and: '<DelayedCall 0x7f61f1fe0340 [0.29947805404663086s] called=0 cancelled=0 TC.test_three.<locals>.f()>'
E       fnmatch: '*_ TC.test_two _*'
E          with: '_________________________________ TC.test_two __________________________________'
E       nomatch: '*NameError*crash*'
E           and: ''
E           and: '_ = None'
E           and: ''
E           and: '    def f(_):'
E           and: '>       crash'
E       fnmatch: '*NameError*crash*'
E          with: "E       NameError: name 'crash' is not defined"
E       nomatch: '*= 4 failed, 1 error in *'
E           and: ''
E           and: 'test_trial_error.py:11: NameError'
E           and: '=============================== warnings summary ==============================='
E           and: 'test_trial_error.py::TC::test_four'
E           and: 'test_trial_error.py::TC::test_two'
E           and: '  ...pytest/.tox/py310-unittestextras/lib/python3.10/site-packages/twisted/python/threadable.py:107: DeprecationWarning: currentThread() is deprecated, use current_thread() instead'
E           and: '    return threadingmodule.currentThread().ident'
E           and: ''
E           and: '-- Docs: https://docs.pytest.org/en/stable/warnings.html'
E           and: '=========================== short test summary info ============================'
E           and: "FAILED test_trial_error.py::TC::test_four - NameError: name 'crash' is not de..."
E           and: "FAILED test_trial_error.py::TC::test_one - NameError: name 'crash' is not def..."
E           and: 'FAILED test_trial_error.py::TC::test_three'
E           and: "FAILED test_trial_error.py::TC::test_two - NameError: name 'crash' is not def..."
E           and: 'ERROR test_trial_error.py::TC::test_four'
E           and: '==================== 4 failed, 2 warnings, 1 error in 0.64s ===================='
E       remains unmatched: '*= 4 failed, 1 error in *'

...pytest/testing/test_unittest.py:574: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.10.0b1, pytest-6.3.0.dev440+g045ad5ac2, py-1.10.0, pluggy-0.13.1 -- ...pytest/.tox/py310-unittestextras/bin/python
cachedir: .pytest_cache
rootdir: /tmp/pytest-of-churchyard/pytest-6/test_trial_error0
collecting ... collected 4 items

test_trial_error.py::TC::test_four FAILED
test_trial_error.py::TC::test_four ERROR
test_trial_error.py::TC::test_one FAILED
test_trial_error.py::TC::test_three FAILED
test_trial_error.py::TC::test_two FAILED

==================================== ERRORS ====================================
______________________ ERROR at teardown of TC.test_four _______________________
'NoneType' object is not iterable

During handling of the above exception, another exception occurred:
NOTE: Incompatible Exception Representation, displaying natively:

twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
<DelayedCall 0x7f61f1fa61d0 [0.2993643283843994s] called=0 cancelled=0 TC.test_four.<locals>.f()>
=================================== FAILURES ===================================
_________________________________ TC.test_four _________________________________

_ = None

    def f(_):
        reactor.callLater(0.3, f)
>       crash
E       NameError: name 'crash' is not defined

test_trial_error.py:27: NameError
_________________________________ TC.test_one __________________________________

self = <test_trial_error.TC testMethod=test_one>

    def test_one(self):
>       crash
E       NameError: name 'crash' is not defined

test_trial_error.py:7: NameError
________________________________ TC.test_three _________________________________
'NoneType' object is not iterable

During handling of the above exception, another exception occurred:
NOTE: Incompatible Exception Representation, displaying natively:

twisted.trial.util.DirtyReactorAggregateError: Reactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
<DelayedCall 0x7f61f1fe0340 [0.29947805404663086s] called=0 cancelled=0 TC.test_three.<locals>.f()>
_________________________________ TC.test_two __________________________________

_ = None

    def f(_):
>       crash
E       NameError: name 'crash' is not defined

test_trial_error.py:11: NameError
=============================== warnings summary ===============================
test_trial_error.py::TC::test_four
test_trial_error.py::TC::test_two
  ...pytest/.tox/py310-unittestextras/lib/python3.10/site-packages/twisted/python/threadable.py:107: DeprecationWarning: currentThread() is deprecated, use current_thread() instead
    return threadingmodule.currentThread().ident

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED test_trial_error.py::TC::test_four - NameError: name 'crash' is not de...
FAILED test_trial_error.py::TC::test_one - NameError: name 'crash' is not def...
FAILED test_trial_error.py::TC::test_three
FAILED test_trial_error.py::TC::test_two - NameError: name 'crash' is not def...
ERROR test_trial_error.py::TC::test_four
==================== 4 failed, 2 warnings, 1 error in 0.64s ====================
=========================== short test summary info ============================
FAILED testing/test_unittest.py::TestTrialUnittest::test_trial_error - Failed...
=================== 1 failed, 67 passed, 1 skipped in 5.40s ====================
ERROR: InvocationError for command ...pytest/.tox/py310-unittestextras/bin/pytest testing/test_unittest.py (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py310-unittestextras: commands failed
hroncok added a commit to hroncok/pytest that referenced this issue May 12, 2021
@hroncok
Copy link
Member Author

hroncok commented May 12, 2021

#8664

hroncok added a commit to hroncok/pytest that referenced this issue May 12, 2021
@Zac-HD Zac-HD added the type: selftests a problem in the tests of pytest label May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: selftests a problem in the tests of pytest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants