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

gh-92886: Fixing tests that fail when running with optimizations (-O) in test_sys_settrace.py #93234

Merged
merged 3 commits into from
Oct 18, 2022

Conversation

jackh-ncl
Copy link
Contributor

@jackh-ncl jackh-ncl commented May 25, 2022

#92886

Before:

$ ./python.exe -Om unittest test._test_sys_settrace

E
======================================================================
ERROR: _test_sys_settrace (unittest.loader._FailedTest._test_sys_settrace)
----------------------------------------------------------------------
ImportError: Failed to import test module: _test_sys_settrace
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'test._test_sys_settrace'


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
➜  cpython git:(92886-sys_settrace) ✗ ./python.exe -Om unittest test.test_sys_settrace

.....................................................................................................................F....F.........................................................F....F.......................................................F....F...............................
======================================================================
FAIL: test_break_through_finally (test.test_sys_settrace.SkipLineEventsTraceTestCase.test_break_through_finally)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 821, in test_break_through_finally
    self.run_and_compare(func,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 1587, in compare_events
    super().compare_events(line_offset, events, skip_line_events)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 350, in compare_events
    self.fail(
    ^^^^^^^^^^
AssertionError: events did not match expectation:
  (0, 'call')
- (13, 'return')
?   ^

+ (10, 'return')
?   ^


======================================================================
FAIL: test_continue_through_finally (test.test_sys_settrace.SkipLineEventsTraceTestCase.test_continue_through_finally)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 857, in test_continue_through_finally
    self.run_and_compare(func,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 1587, in compare_events
    super().compare_events(line_offset, events, skip_line_events)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 350, in compare_events
    self.fail(
    ^^^^^^^^^^
AssertionError: events did not match expectation:
  (0, 'call')
- (13, 'return')
?  -

+ (3, 'return')

======================================================================
FAIL: test_break_through_finally (test.test_sys_settrace.TraceOpcodesTestCase.test_break_through_finally)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 821, in test_break_through_finally
    self.run_and_compare(func,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 1603, in compare_events
    super().compare_events(line_offset, skip_opcode_events, expected_events)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 350, in compare_events
    self.fail(
    ^^^^^^^^^^
AssertionError: events did not match expectation:
  (0, 'call')
  (1, 'line')
  (2, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (8, 'line')
  (10, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (7, 'line')
  (10, 'line')
- (13, 'line')
- (13, 'return')
?   ^

+ (10, 'return')
?   ^


======================================================================
FAIL: test_continue_through_finally (test.test_sys_settrace.TraceOpcodesTestCase.test_continue_through_finally)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 857, in test_continue_through_finally
    self.run_and_compare(func,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 1603, in compare_events
    super().compare_events(line_offset, skip_opcode_events, expected_events)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 350, in compare_events
    self.fail(
    ^^^^^^^^^^
AssertionError: events did not match expectation:
  (0, 'call')
  (1, 'line')
  (2, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (8, 'line')
  (10, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (7, 'line')
  (10, 'line')
  (3, 'line')
- (13, 'line')
- (13, 'return')
?  -

+ (3, 'return')

======================================================================
FAIL: test_break_through_finally (test.test_sys_settrace.TraceTestCase.test_break_through_finally)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 821, in test_break_through_finally
    self.run_and_compare(func,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 350, in compare_events
    self.fail(
    ^^^^^^^^^^
AssertionError: events did not match expectation:
  (0, 'call')
  (1, 'line')
  (2, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (8, 'line')
  (10, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (7, 'line')
  (10, 'line')
- (13, 'line')
- (13, 'return')
?   ^

+ (10, 'return')
?   ^


======================================================================
FAIL: test_continue_through_finally (test.test_sys_settrace.TraceTestCase.test_continue_through_finally)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 857, in test_continue_through_finally
    self.run_and_compare(func,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
    self.compare_events(func.__code__.co_firstlineno,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_sys_settrace.py", line 350, in compare_events
    self.fail(
    ^^^^^^^^^^
AssertionError: events did not match expectation:
  (0, 'call')
  (1, 'line')
  (2, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (8, 'line')
  (10, 'line')
  (3, 'line')
  (4, 'line')
  (5, 'line')
  (6, 'line')
  (7, 'line')
  (10, 'line')
  (3, 'line')
- (13, 'line')
- (13, 'return')
?  -

+ (3, 'return')

----------------------------------------------------------------------
Ran 278 tests in 0.089s

FAILED (failures=6)

After:

$ ./python.exe -Om unittest test.test_sys_settrace

......................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 278 tests in 0.085s

OK

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot bedevere-bot added tests Tests in the Lib/test dir awaiting review labels May 25, 2022
@jackh-ncl jackh-ncl marked this pull request as ready for review May 25, 2022 22:43
Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@iritkatriel iritkatriel merged commit debacd9 into python:main Oct 18, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants