Skip to content

test_sys_settrace tests are not independent #108982

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

Running any of TraceOpcodesTestCase tests from test_sys_settrace always fails. For example:

$ ./python -m test -v test_sys_settrace -m test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic
...
test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic) ... FAIL

======================================================================
FAIL: test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 388, in test_01_basic
    self.run_test(basic)
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 364, in run_test
    self.run_and_compare(func, func.events)
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
  File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 1745, in compare_events
    self.assertLess(len(skip_opcode_events), len(events),
AssertionError: 3 not less than 3 : No 'opcode' events received by the tracer
...

Running several of TraceOpcodesTestCase tests only fails the first of them.

Running also RaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event makes the tests passing successfully.

$ ./python -m test -v test_sys_settrace -m test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic -m test_line_event_raises_before_opcode_event
...
test_line_event_raises_before_opcode_event (test.test_sys_settrace.RaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event) ... ok
test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic) ... ok
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions