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

Running test_dataclasses file directly fails #104015

Closed
wookie184 opened this issue Apr 30, 2023 · 2 comments · Fixed by #104017
Closed

Running test_dataclasses file directly fails #104015

wookie184 opened this issue Apr 30, 2023 · 2 comments · Fixed by #104017
Assignees
Labels
3.12 bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@wookie184
Copy link
Contributor

wookie184 commented Apr 30, 2023

Bug report

Running ./python Lib/test/test_dataclasses.py gives me these test fails:

[root@codespaces-44977f cpython]# ./python Lib/test/test_dataclasses.py
....................................................................................................................................................................................EEEEEE...................................................
======================================================================
ERROR: test_pickle_support (__main__.TestMakeDataclass.test_pickle_support) (proto=0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/test_dataclasses.py", line 3802, in test_pickle_support
    pickle.loads(pickle.dumps(klass, proto)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <class 'test.test_dataclasses.ManualModuleMakeDataClass'>: it's not the same object as test.test_dataclasses.ManualModuleMakeDataClass

======================================================================
ERROR: test_pickle_support (__main__.TestMakeDataclass.test_pickle_support) (proto=1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/test_dataclasses.py", line 3802, in test_pickle_support
    pickle.loads(pickle.dumps(klass, proto)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <class 'test.test_dataclasses.ManualModuleMakeDataClass'>: it's not the same object as test.test_dataclasses.ManualModuleMakeDataClass

======================================================================
ERROR: test_pickle_support (__main__.TestMakeDataclass.test_pickle_support) (proto=2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/test_dataclasses.py", line 3802, in test_pickle_support
    pickle.loads(pickle.dumps(klass, proto)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <class 'test.test_dataclasses.ManualModuleMakeDataClass'>: it's not the same object as test.test_dataclasses.ManualModuleMakeDataClass

======================================================================
ERROR: test_pickle_support (__main__.TestMakeDataclass.test_pickle_support) (proto=3)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/test_dataclasses.py", line 3802, in test_pickle_support
    pickle.loads(pickle.dumps(klass, proto)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <class 'test.test_dataclasses.ManualModuleMakeDataClass'>: it's not the same object as test.test_dataclasses.ManualModuleMakeDataClass

======================================================================
ERROR: test_pickle_support (__main__.TestMakeDataclass.test_pickle_support) (proto=4)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/test_dataclasses.py", line 3802, in test_pickle_support
    pickle.loads(pickle.dumps(klass, proto)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <class 'test.test_dataclasses.ManualModuleMakeDataClass'>: it's not the same object as test.test_dataclasses.ManualModuleMakeDataClass

======================================================================
ERROR: test_pickle_support (__main__.TestMakeDataclass.test_pickle_support) (proto=5)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/workspaces/cpython/Lib/test/test_dataclasses.py", line 3802, in test_pickle_support
    pickle.loads(pickle.dumps(klass, proto)),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <class 'test.test_dataclasses.ManualModuleMakeDataClass'>: it's not the same object as test.test_dataclasses.ManualModuleMakeDataClass

----------------------------------------------------------------------
Ran 232 tests in 0.408s

FAILED (errors=6)

When running ./python -m test test_dataclasses, the tests all pass successfully. My understanding is that python -m test is the recommended way of running tests, but it's confusing to have it support running the file directly, but have the tests fail.

I'm not sure what the cause of the failure is.

Your environment

  • CPython versions tested on: main (ed95e8c)
  • Operating system and architecture: GitHub Codespaces

Linked PRs

@wookie184 wookie184 added the type-bug An unexpected behavior, bug, or error label Apr 30, 2023
@AlexWaygood AlexWaygood added the tests Tests in the Lib/test dir label Apr 30, 2023
@AlexWaygood
Copy link
Member

The problematic tests were added relatively recently, in b48be8f (cc. @sobolevn)

@AlexWaygood AlexWaygood added the 3.12 bugs and security fixes label Apr 30, 2023
@sobolevn
Copy link
Member

I will take a look, thanks!

@sobolevn sobolevn self-assigned this Apr 30, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Apr 30, 2023
AlexWaygood pushed a commit that referenced this issue Apr 30, 2023
Previously, `python -m test test_dataclasses` passed, but `./python.exe Lib/test/test_dataclasses.py` failed
carljm added a commit to carljm/cpython that referenced this issue May 1, 2023
* main: (26 commits)
  pythongh-104028: Reduce object creation while calling callback function from gc (pythongh-104030)
  pythongh-104036: Fix direct invocation of test_typing (python#104037)
  pythongh-102213: Optimize the performance of `__getattr__` (pythonGH-103761)
  pythongh-103895: Improve how invalid `Exception.__notes__` are displayed (python#103897)
  Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (pythonGH-104021)
  pythongh-88496: Fix IDLE test hang on macOS (python#104025)
  Improve int test coverage (python#104024)
  pythongh-88773: Added teleport method to Turtle library (python#103974)
  pythongh-104015: Fix direct invocation of `test_dataclasses` (python#104017)
  pythongh-104012: Ensure test_calendar.CalendarTestCase.test_deprecation_warning consistently passes (python#104014)
  pythongh-103977: compile re expressions in platform.py only if required (python#103981)
  pythongh-98003: Inline call frames for CALL_FUNCTION_EX (pythonGH-98004)
  Replace Netlify with Read the Docs build previews (python#103843)
  Update name in acknowledgements and add mailmap (python#103696)
  pythongh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (python#103927)
  Remove non-existing tools from Sundry skiplist (python#103991)
  pythongh-103793: Defer formatting task name (python#103767)
  pythongh-87092: change assembler to use instruction sequence instead of CFG (python#103933)
  pythongh-103636: issue warning for deprecated calendar constants (python#103833)
  Various small fixes to dis docs (python#103923)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants