Skip to content

Commit 91dd86c

Browse files
committed
Fix 4/6 failing tests
1 parent 2695bb7 commit 91dd86c

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

Lib/test/test_embed.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import tempfile
1919
import textwrap
2020

21+
import _testinternalcapi
22+
2123
if not support.has_subprocess_support:
2224
raise unittest.SkipTest("test module requires subprocess")
2325

@@ -1777,6 +1779,8 @@ def test_frozenmain(self):
17771779

17781780
@unittest.skipUnless(support.Py_DEBUG,
17791781
'-X showrefcount requires a Python debug build')
1782+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
1783+
'There are known leaks in the optimizer')
17801784
def test_no_memleak(self):
17811785
# bpo-1635741: Python must release all memory at exit
17821786
tests = (

Lib/test/test_monitoring.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import types
1010
import unittest
1111

12+
import _testinternalcapi
13+
1214

1315
PAIR = (0,1)
1416

@@ -497,6 +499,8 @@ def test_two_with_disable(self):
497499

498500
class LineMonitoringTest(MonitoringTestBase, unittest.TestCase):
499501

502+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
503+
"The optimizer changes the test behavior")
500504
def test_lines_single(self):
501505
try:
502506
self.assertEqual(sys.monitoring._all_events(), {})
@@ -515,6 +519,8 @@ def test_lines_single(self):
515519
self.assertEqual(sys.monitoring._all_events(), {})
516520
sys.monitoring.restart_events()
517521

522+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
523+
"The optimizer changes the test behavior")
518524
def test_lines_loop(self):
519525
try:
520526
self.assertEqual(sys.monitoring._all_events(), {})
@@ -533,6 +539,8 @@ def test_lines_loop(self):
533539
self.assertEqual(sys.monitoring._all_events(), {})
534540
sys.monitoring.restart_events()
535541

542+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
543+
"The optimizer changes the test behavior")
536544
def test_lines_two(self):
537545
try:
538546
self.assertEqual(sys.monitoring._all_events(), {})

Lib/test/test_sys_settrace.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import asyncio
1010
from test.support import import_helper
1111

12+
import _testinternalcapi
13+
1214
support.requires_working_socket(module=True)
1315

1416
class tracecontext:
@@ -326,6 +328,8 @@ def traceWithGenexp(self, frame, event, arg):
326328
return self.trace
327329

328330

331+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
332+
"The optimizer changes the test behavior")
329333
class TraceTestCase(unittest.TestCase):
330334

331335
# Disable gc collection when tracing, otherwise the

Lib/test/test_trace.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from test.tracedmodules import testmod
1414

15+
import _testinternalcapi
16+
1517
##
1618
## See also test_sys_settrace.py, which contains tests that cover
1719
## tracing of many more code blocks.
@@ -141,6 +143,8 @@ def test_traced_func_linear(self):
141143

142144
self.assertEqual(self.tracer.results().counts, expected)
143145

146+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
147+
"Test doesn't work when tracing optimizer is active")
144148
def test_traced_func_loop(self):
145149
self.tracer.runfunc(traced_func_loop, 2, 3)
146150

@@ -165,6 +169,8 @@ def test_traced_func_importing(self):
165169

166170
self.assertEqual(self.tracer.results().counts, expected)
167171

172+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
173+
"Test doesn't work when tracing optimizer is active")
168174
def test_trace_func_generator(self):
169175
self.tracer.runfunc(traced_func_calling_generator)
170176

@@ -235,6 +241,8 @@ def setUp(self):
235241
self.my_py_filename = fix_ext_py(__file__)
236242
self.addCleanup(sys.settrace, sys.gettrace())
237243

244+
@unittest.skipIf(_testinternalcapi.get_optimizer(),
245+
"Test doesn't work when tracing optimizer is active")
238246
def test_exec_counts(self):
239247
self.tracer = Trace(count=1, trace=0, countfuncs=0, countcallers=0)
240248
code = r'''traced_func_loop(2, 5)'''

0 commit comments

Comments
 (0)