Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

test_interpreters misses tests with all pickle protocols #136285

Copy link
Copy link
@sobolevn

Description

@sobolevn
Issue body actions

There are multiple places in test_interpreters where pickle only tests the default protocol.

Like:

def test_pickle(self):
interp = interpreters.create()
data = pickle.dumps(interp)
unpickled = pickle.loads(data)
self.assertEqual(unpickled, interp)

I guess that we can improve the tests with more protocols.

But, when I do that protocols 0 and 1 fail for all objects.
I decided to just limit the tests for now, because I am not sure if this is actually an intended behavior:

======================================================================
ERROR: test_pickle (test.test_interpreters.test_channels.TestRecvChannelAttrs.test_pickle) (protocol=0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_channels.py", line 128, in test_pickle
    self.assertEqual(unpickled, ch)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 925, in assertEqual
    assertion_func(first, second, msg=msg)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 915, in _baseAssertEqual
    if not first == second:
           ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/support/channels.py", line 105, in __eq__
    return other._id == self._id
                        ^^^^^^^^
AttributeError: 'RecvChannel' object has no attribute '_id'. Did you mean: 'id'?

======================================================================
ERROR: test_pickle (test.test_interpreters.test_channels.TestRecvChannelAttrs.test_pickle) (protocol=1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_channels.py", line 128, in test_pickle
    self.assertEqual(unpickled, ch)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 925, in assertEqual
    assertion_func(first, second, msg=msg)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 915, in _baseAssertEqual
    if not first == second:
           ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/support/channels.py", line 105, in __eq__
    return other._id == self._id
                        ^^^^^^^^
AttributeError: 'RecvChannel' object has no attribute '_id'. Did you mean: 'id'?

======================================================================
ERROR: test_pickle (test.test_interpreters.test_channels.TestSendChannelAttrs.test_pickle) (protocol=0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_channels.py", line 161, in test_pickle
    self.assertEqual(unpickled, ch)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 925, in assertEqual
    assertion_func(first, second, msg=msg)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 915, in _baseAssertEqual
    if not first == second:
           ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/support/channels.py", line 105, in __eq__
    return other._id == self._id
                        ^^^^^^^^
AttributeError: 'SendChannel' object has no attribute '_id'. Did you mean: 'id'?

======================================================================
ERROR: test_pickle (test.test_interpreters.test_channels.TestSendChannelAttrs.test_pickle) (protocol=1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_channels.py", line 161, in test_pickle
    self.assertEqual(unpickled, ch)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 925, in assertEqual
    assertion_func(first, second, msg=msg)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/case.py", line 915, in _baseAssertEqual
    if not first == second:
           ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/support/channels.py", line 105, in __eq__
    return other._id == self._id
                        ^^^^^^^^
AttributeError: 'SendChannel' object has no attribute '_id'. Did you mean: 'id'?

======================================================================
FAIL: test_pickle (test.test_interpreters.test_api.InterpreterObjectTests.test_pickle) (protocol=0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_api.py", line 419, in test_pickle
    self.assertEqual(unpickled, interp)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
AssertionError: <concurrent.interpreters.Interpreter object at 0x102928d60> != Interpreter(22)

======================================================================
FAIL: test_pickle (test.test_interpreters.test_api.InterpreterObjectTests.test_pickle) (protocol=1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_api.py", line 419, in test_pickle
    self.assertEqual(unpickled, interp)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
AssertionError: <concurrent.interpreters.Interpreter object at 0x10293e9e0> != Interpreter(22)

======================================================================
FAIL: test_pickle (test.test_interpreters.test_queues.QueueTests.test_pickle) (protocol=0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_queues.py", line 195, in test_pickle
    self.assertEqual(unpickled, queue)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
AssertionError: <concurrent.interpreters._queues.Queue object at 0x1026fc8d0> != Queue(17)

======================================================================
FAIL: test_pickle (test.test_interpreters.test_queues.QueueTests.test_pickle) (protocol=1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_interpreters/test_queues.py", line 195, in test_pickle
    self.assertEqual(unpickled, queue)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
AssertionError: <concurrent.interpreters._queues.Queue object at 0x102709800> != Queue(17)

----------------------------------------------------------------------
Ran 165 tests in 6.277s

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirTests in the Lib/test dirtopic-subprocessSubprocess issues.Subprocess issues.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.