Skip to content

Conversation

@tirkarthi
Copy link
Member

@tirkarthi tirkarthi commented Apr 13, 2021

@bedevere-bot bedevere-bot added tests Tests in the Lib/test dir awaiting core review labels Apr 13, 2021
@tirkarthi tirkarthi changed the title bpo41515: Fix assert in test which throws SyntaxWarning. bpo-41515: Fix assert in test which throws SyntaxWarning. Apr 13, 2021
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Did you verify this using the test strategy Victor gave?

@tirkarthi
Copy link
Member Author

Yes, I have verified that the PR fixes the warning.

On master branch

➜  cpython git:(master) ./python -m test test___all__
0:00:00 load avg: 0.10 Run tests sequentially
0:00:00 load avg: 0.10 [1/1] test___all__
test test___all__ failed -- Traceback (most recent call last):
  File "/root/cpython/Lib/test/test___all__.py", line 104, in test_all
    self.check_all(modname)
  File "/root/cpython/Lib/test/test___all__.py", line 25, in check_all
    exec("import %s" % modname, names)
  File "/root/cpython/Lib/contextlib.py", line 140, in __exit__
    next(self.gen)
  File "/root/cpython/Lib/test/support/warnings_helper.py", line 177, in _filterwarnings
    raise AssertionError("unhandled warning %s" % reraise[0])
AssertionError: unhandled warning {message : SyntaxWarning('assertion is always true, perhaps remove parentheses?'), category : 'SyntaxWarning', filename : '/root/cpython/Lib/test/test_typing.py', lineno : 2275, line : None}

test___all__ failed

== Tests result: FAILURE ==

1 test failed:
    test___all__

Total duration: 2.1 sec
Tests result: FAILURE

With patch

➜  cpython git:(fix-deprecation-warnings) ./python -m test test___all__
0:00:00 load avg: 0.16 Run tests sequentially
0:00:00 load avg: 0.16 [1/1] test___all__

== Tests result: SUCCESS ==

1 test OK.

Total duration: 1.4 sec
Tests result: SUCCESS

Additionally this can be reproduced on test_typing by turning on -Werror

On master

➜  cpython git:(master) ./python -Werror -m test test_typing
0:00:00 load avg: 0.15 Run tests sequentially
0:00:00 load avg: 0.15 [1/1] test_typing
test test_typing crashed -- Traceback (most recent call last):
  File "/root/cpython/Lib/test/libregrtest/runtest.py", line 282, in _runtest_inner
    refleak = _runtest_inner2(ns, test_name)
  File "/root/cpython/Lib/test/libregrtest/runtest.py", line 229, in _runtest_inner2
    the_module = importlib.import_module(abstest)
  File "/root/cpython/Lib/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 876, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1014, in get_code
  File "<frozen importlib._bootstrap_external>", line 944, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/root/cpython/Lib/test/test_typing.py", line 2275
    assert(get_type_hints(BadModule), {})
    ^
SyntaxError: assertion is always true, perhaps remove parentheses?

test_typing failed

== Tests result: FAILURE ==

1 test failed:
    test_typing

Total duration: 107 ms
Tests result: FAILURE

With patch

➜  cpython git:(bpo41515-assert) ./python -Werror -m test test_typing
0:00:00 load avg: 0.13 Run tests sequentially
0:00:00 load avg: 0.13 [1/1] test_typing

== Tests result: SUCCESS ==

1 test OK.

Total duration: 378 ms
Tests result: SUCCESS

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Apr 13, 2021

Sorry I didn't catch this when reviewing the original :(, and thanks for the quick fix!

@gvanrossum gvanrossum merged commit eb77133 into python:master Apr 13, 2021
@bedevere-bot
Copy link

@gvanrossum: Please replace # with GH- in the commit message next time. Thanks!

@vstinner
Copy link
Member

@Fidget-Spinner:

Sorry I didn't catch this when reviewing the original :(, and thanks for the quick fix!

Don't worry. As I explained, it was silently ignored by the CI: https://bugs.python.org/issue41515#msg390893

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

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants