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-104584: Fix test_capi.test_counter_optimizer() when run twice #106171

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 28, 2023

test_counter_optimizer() and test_long_loop() of test_capi now create a new function at each call. Otherwise, the optimizer counters are not the expected values when the test is run more than once.

test_counter_optimizer() and test_long_loop() of test_capi now create
a new function at each call. Otherwise, the optimizer counters are
not the expected values when the test is run more than once.
@bedevere-bot bedevere-bot added awaiting core review tests Tests in the Lib/test dir labels Jun 28, 2023
@vstinner vstinner added skip news and removed tests Tests in the Lib/test dir awaiting core review labels Jun 28, 2023
@vstinner
Copy link
Member Author

test_capi currently fails on the Refleaks buildbots:

0:45:19 load avg: 1.15 Re-running test_capi in verbose mode (matching: test_counter_optimizer, test_long_loop)
beginning 6 repetitions
123456
test_counter_optimizer (test.test_capi.test_misc.TestOptimizerAPI.test_counter_optimizer) ... ok
test_long_loop (test.test_capi.test_misc.TestOptimizerAPI.test_long_loop)
Check that we aren't confused by EXTENDED_ARG ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.001s

OK
test_counter_optimizer (test.test_capi.test_misc.TestOptimizerAPI.test_counter_optimizer) ... FAIL
test_long_loop (test.test_capi.test_misc.TestOptimizerAPI.test_long_loop)
Check that we aren't confused by EXTENDED_ARG ... FAIL

======================================================================
FAIL: test_counter_optimizer (test.test_capi.test_misc.TestOptimizerAPI.test_counter_optimizer)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/test/test_capi/test_misc.py", line 2386, in test_counter_optimizer
    self.assertEqual(opt.get_count(), 1000)
AssertionError: 0 != 1000

======================================================================
FAIL: test_long_loop (test.test_capi.test_misc.TestOptimizerAPI.test_long_loop)
Check that we aren't confused by EXTENDED_ARG
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/test/test_capi/test_misc.py", line 2408, in test_long_loop
    self.assertEqual(opt.get_count(), 10)
AssertionError: 0 != 10

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (failures=2)
.test test_capi failed

cc @markshannon

@vstinner
Copy link
Member Author

vstinner commented Jun 28, 2023

Reproduce the issue with: ./python -m test -m test_counter_optimizer -m test_long_loop -v test_capi test_capi command.

@vstinner vstinner merged commit adaacf2 into python:main Jun 28, 2023
19 checks passed
@vstinner vstinner deleted the test_counter_optimizer branch June 28, 2023 02:41
@vstinner
Copy link
Member Author

Note: Python 3.12 is not affected.

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

Successfully merging this pull request may close these issues.

2 participants