Repository navigation
test_pickle tests failing when invoked directly #131031
Copy link
Copy link
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
I ran separate tests for the pickle module on main branch:
./python ./Lib/test/test_pickle.py
I got 24 failures
Judging by the output, the problem is in the mismatch of error messages:
test_nested_lookup_error (__main__.CPicklingErrorTests.test_nested_lookup_error) ...
test_nested_lookup_error (__main__.CPicklingErrorTests.test_nested_lookup_error) (proto=0) ... FAIL
test_nested_lookup_error (__main__.CPicklingErrorTests.test_nested_lookup_error) (proto=1) ... FAIL
test_nested_lookup_error (__main__.CPicklingErrorTests.test_nested_lookup_error) (proto=2) ... FAIL
test_nested_lookup_error (__main__.CPicklingErrorTests.test_nested_lookup_error) (proto=3) ... FAIL
test_nested_lookup_error (__main__.CPicklingErrorTests.test_nested_lookup_error) (proto=4) ... FAIL
test_nested_lookup_error (__main__.CPicklingErrorTests.test_nested_lookup_error) (proto=5) ... FAIL
...
test_wrong_object_lookup_error (__main__.CPicklingErrorTests.test_wrong_object_lookup_error) ...
test_wrong_object_lookup_error (__main__.CPicklingErrorTests.test_wrong_object_lookup_error) (proto=0) ... FAIL
test_wrong_object_lookup_error (__main__.CPicklingErrorTests.test_wrong_object_lookup_error) (proto=1) ... FAIL
test_wrong_object_lookup_error (__main__.CPicklingErrorTests.test_wrong_object_lookup_error) (proto=2) ... FAIL
test_wrong_object_lookup_error (__main__.CPicklingErrorTests.test_wrong_object_lookup_error) (proto=3) ... FAIL
test_wrong_object_lookup_error (__main__.CPicklingErrorTests.test_wrong_object_lookup_error) (proto=4) ... FAIL
test_wrong_object_lookup_error (__main__.CPicklingErrorTests.test_wrong_object_lookup_error) (proto=5) ... FAIL
...
test_nested_lookup_error (__main__.PyPicklingErrorTests.test_nested_lookup_error) ...
test_nested_lookup_error (__main__.PyPicklingErrorTests.test_nested_lookup_error) (proto=0) ... FAIL
test_nested_lookup_error (__main__.PyPicklingErrorTests.test_nested_lookup_error) (proto=1) ... FAIL
test_nested_lookup_error (__main__.PyPicklingErrorTests.test_nested_lookup_error) (proto=2) ... FAIL
test_nested_lookup_error (__main__.PyPicklingErrorTests.test_nested_lookup_error) (proto=3) ... FAIL
test_nested_lookup_error (__main__.PyPicklingErrorTests.test_nested_lookup_error) (proto=4) ... FAIL
test_nested_lookup_error (__main__.PyPicklingErrorTests.test_nested_lookup_error) (proto=5) ... FAIL
...
test_wrong_object_lookup_error (__main__.PyPicklingErrorTests.test_wrong_object_lookup_error) ...
test_wrong_object_lookup_error (__main__.PyPicklingErrorTests.test_wrong_object_lookup_error) (proto=0) ... FAIL
test_wrong_object_lookup_error (__main__.PyPicklingErrorTests.test_wrong_object_lookup_error) (proto=1) ... FAIL
test_wrong_object_lookup_error (__main__.PyPicklingErrorTests.test_wrong_object_lookup_error) (proto=2) ... FAIL
test_wrong_object_lookup_error (__main__.PyPicklingErrorTests.test_wrong_object_lookup_error) (proto=3) ... FAIL
test_wrong_object_lookup_error (__main__.PyPicklingErrorTests.test_wrong_object_lookup_error) (proto=4) ... FAIL
test_wrong_object_lookup_error (__main__.PyPicklingErrorTests.test_wrong_object_lookup_error) (proto=5) ... FAIL
Examples of mismatches:
AssertionError: "type object 'AbstractPickleTests' has no attribute 'spam'" != "module '__main__' has no attribute 'AbstractPickleTests'"
- type object 'AbstractPickleTests' has no attribute 'spam'
+ module '__main__' has no attribute 'AbstractPickleTests'
...
AssertionError: "Can'[53 chars]4b0>: it's not the same object as __main__.AbstractPickleTests" != "Can'[53 chars]4b0>: it's not found as __main__.AbstractPickleTests"
- Can't pickle <test.pickletester.REX object at 0x79fcb255a4b0>: it's not the same object as __main__.AbstractPickleTests
? ^^^^^^^^^ ^^^^^
+ Can't pickle <test.pickletester.REX object at 0x79fcb255a4b0>: it's not found as __main__.AbstractPickleTests
?
I'm going to send PR after we decide what the messages should look like
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
[-]tests `test_pickle` failed due to error message mismatch[/-][+]`test_pickle` tests failing when invoked directly[/+]pythongh-131031: Fix test_pickle when invoked directly
serhiy-storchaka commentedon May 3, 2025
Good catch @donbarbos! Thank you.
Your PR fixes tests, but I think that it would be better to not use
AbstractPickleTestsin these tests. For these tests we need an existing global class which does not exist in__main__. Running tests as a script fails becauseAbstractPickleTestsis imported intest_pickle.pywhich becomes__main__. #133356 uses this approach.gh-131031: Fix test_pickle when invoked directly (GH-133356)
pythongh-131031: Fix test_pickle when invoked directly (pythonGH-133356)
[3.13] pythongh-131031: Fix test_pickle when invoked directly (python…
[3.14] gh-131031: Fix test_pickle when invoked directly (GH-133356) (G…
[3.13] gh-131031: Fix test_pickle when invoked directly (GH-133356) (G…
pythongh-131031: Fix test_pickle when invoked directly (pythonGH-133356)
pythongh-131031: Fix test_pickle when invoked directly (pythonGH-133356)