Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
jackh-ncl wants to merge 2 commits intopython:mainfrom
jackh-ncl:92886-dis
Closed

gh-92886: Fixing tests that fail when running with optimizations (-O) in test_dis.py#93238
jackh-ncl wants to merge 2 commits intopython:mainfrom
jackh-ncl:92886-dis

Conversation

@jackh-ncl
Copy link
Contributor

#92886

Before:

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

.....F...F..F....s.................................s.................................................
======================================================================
FAIL: test_info (test.test_dis.BytecodeTests.test_info)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_dis.py", line 1623, in test_info
    self.assertRegex(b.info(), expected)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'Name:              code_info\nFilename:          (.*)\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        \\d+\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x' not found in "Name:              code_info\nFilename:          /Users/.../dev/cpython/Lib/dis.py\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        5\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: 'Formatted details of methods, functions, or code.'\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x"

======================================================================
FAIL: test_code_info (test.test_dis.CodeInfoTests.test_code_info)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_dis.py", line 1212, in test_code_info
    self.assertRegex(dis.code_info(x), expected)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'Name:              code_info\nFilename:          (.*)\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        \\d+\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x' not found in "Name:              code_info\nFilename:          /Users/.../dev/cpython/Lib/dis.py\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        5\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: 'Formatted details of methods, functions, or code.'\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x"

======================================================================
FAIL: test_show_code (test.test_dis.CodeInfoTests.test_show_code)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/test_dis.py", line 1219, in test_show_code
    self.assertRegex(output.getvalue(), expected+"\n")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'Name:              code_info\nFilename:          (.*)\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        \\d+\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: None\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x\n' not found in "Name:              code_info\nFilename:          /Users/.../dev/cpython/Lib/dis.py\nArgument count:    1\nPositional-only arguments: 0\nKw-only arguments: 0\nNumber of locals:  1\nStack size:        5\nFlags:             OPTIMIZED, NEWLOCALS\nConstants:\n   0: 'Formatted details of methods, functions, or code.'\nNames:\n   0: _format_code_info\n   1: _get_code_object\nVariable names:\n   0: x\n"

----------------------------------------------------------------------
Ran 101 tests in 0.618s

FAILED (failures=3, skipped=2)

After:

./python.exe -Om unittest test.test_dis

.................s.................................s.................................................
----------------------------------------------------------------------
Ran 101 tests in 0.624s

OK (skipped=2)

@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 23:14
@iritkatriel
Copy link
Member

Sorry, this was done in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants