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

test_unittest failure in leaks searching mode #69932

Closed
serhiy-storchaka opened this issue Nov 27, 2015 · 4 comments
Closed

test_unittest failure in leaks searching mode #69932

serhiy-storchaka opened this issue Nov 27, 2015 · 4 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 25746
Nosy @vstinner, @rbtcollins, @ezio-melotti, @voidspace, @serhiy-storchaka, @zhangyangyu
Superseder
  • bpo-30813: test_unittest fails when hunting reference leaks
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-07-11.07:04:23.089>
    created_at = <Date 2015-11-27.18:07:31.437>
    labels = ['type-bug', 'tests']
    title = 'test_unittest failure in leaks searching mode'
    updated_at = <Date 2017-07-11.07:04:23.087>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-07-11.07:04:23.087>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-07-11.07:04:23.089>
    closer = 'serhiy.storchaka'
    components = ['Tests']
    creation = <Date 2015-11-27.18:07:31.437>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 25746
    keywords = []
    message_count = 4.0
    messages = ['255471', '273176', '273210', '298135']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'rbcollins', 'ezio.melotti', 'michael.foord', 'serhiy.storchaka', 'xiang.zhang']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '30813'
    type = 'behavior'
    url = 'https://bugs.python.org/issue25746'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    $ ./python -m test.regrtest -uall -R 3:3 test_unittest
    [1/1] test_unittest
    test test_unittest failed -- multiple errors occurred; run in verbose mode for details
    1 test failed:
        test_unittest
    
    $ ./python -m test.regrtest -vvuall -R 3:3 test_unittest
    ...

    ======================================================================
    ERROR: test_discover_with_init_module_that_raises_SkipTest_on_import (unittest.test.test_discovery.TestDiscovery)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/serhiy/py/cpython-debug/Lib/unittest/test/test_discovery.py", line 532, in test_discover_with_init_module_that_raises_SkipTest_on_import
        pickle.loads(pickle.dumps(suite, proto))
    _pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleSkipped'>: attribute lookup ModuleSkipped on unittest.loader failed

    ======================================================================
    ERROR: test_discover_with_module_that_raises_SkipTest_on_import (unittest.test.test_discovery.TestDiscovery)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/serhiy/py/cpython-debug/Lib/unittest/test/test_discovery.py", line 508, in test_discover_with_module_that_raises_SkipTest_on_import
        pickle.loads(pickle.dumps(suite, proto))
    _pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleSkipped'>: attribute lookup ModuleSkipped on unittest.loader failed

    @serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Nov 27, 2015
    @vstinner
    Copy link
    Member

    While checking that I didn't introduce a reference leak recently with my changes around _PyObject_FastCall(), I found the same issue: test_unittest doesn't work with regrtest -R.

    I get the same error:

    $ ./python -m test -R 0:1 -v test_unittest

    ======================================================================
    ERROR: test_discover_with_init_module_that_raises_SkipTest_on_import (unittest.test.test_discovery.TestDiscovery)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/haypo/prog/python/default/Lib/unittest/test/test_discovery.py", line 572, in test_discover_with_init_module_that_raises_SkipTest_on_import
        pickle.loads(pickle.dumps(suite, proto))
    _pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleSkipped'>: attribute lookup ModuleSkipped on unittest.loader failed

    ======================================================================
    ERROR: test_discover_with_module_that_raises_SkipTest_on_import (unittest.test.test_discovery.TestDiscovery)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/haypo/prog/python/default/Lib/unittest/test/test_discovery.py", line 548, in test_discover_with_module_that_raises_SkipTest_on_import
        pickle.loads(pickle.dumps(suite, proto))
    _pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleSkipped'>: attribute lookup ModuleSkipped on unittest.loader failed

    @zhangyangyu
    Copy link
    Member

    Simple reproduction:

    >>> pickle.dumps(unittest.loader._make_skipped_test('hello', RuntimeError, unittest.suite.TestSuite))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    _pickle.PicklingError: Can't pickle <class 'unittest.loader.ModuleSkipped'>: attribute lookup ModuleSkipped on unittest.loader failed

    Exporting ModuleSkipped in unittest.loader can solve this. But maybe any more elegant method?

    @serhiy-storchaka
    Copy link
    Member Author

    Fixed in duplicate bpo-30813.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants