8000 maybe this will work? · python/cpython@a610c0e · GitHub
[go: up one dir, main page]

Skip to content

Commit a610c0e

Browse files
committed
maybe this will work?
1 parent 59567ef commit a610c0e

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

Lib/test/test_dis.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
# Minimal tests for dis module
2-
#
3-
# Do NOT change the order of the imports since it could lead to a timeout for
4-
# test_embed.test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE
5-
# on Windows 32-bits.
62

73
import contextlib
84
import dis
95
import io
6+
import opcode
107
import re
118
import sys
9+
import tempfile
1210
import types
1311
import unittest
1412
from test.support import (captured_stdout, requires_debug_ranges,
15-
requires_specialization, cpython_only)
13+
requires_specialization, cpython_only,
14+
os_helper)
1615
from test.support.bytecode_helper import BytecodeTestCase
1716

18-
import opcode
19-
2017

2118
def get_tb():
2219
def _error():
@@ -2074,17 +2071,16 @@ def get_disassembly(self, tb):
20742071

20752072

20762073
class TestDisCLI(unittest.TestCase):
2077-
pass
20782074

2079-
# def setUp(self):
2080-
# self.filename = tempfile.mktemp()
2081-
# self.addCleanup(os_helper.unlink, self.filename)
2075+
def setUp(self):
2076+
self.filename = tempfile.mktemp()
2077+
self.addCleanup(os_helper.unlink, self.filename)
20822078

2083-
# def test_invocation(self):
2084-
# with self.assertRaises(SystemExit):
2085-
# # suppress argparse error message
2086-
# with contextlib.redirect_stderr(io.StringIO()):
2087-
# dis.main(args=['--unknown', self.filename])
2079+
def test_invocation(self):
2080+
with self.assertRaises(SystemExit):
2081+
# suppress argparse error message
2082+
with contextlib.redirect_stderr(io.StringIO()):
2083+
dis.main(args=['--unknown', self.filename])
20882084

20892085

20902086
if __name__ == "__main__":

Lib/test/test_embed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ def test_simple_initialization_api(self):
348348
@support.requires_specialization
349349
def test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE(self):
350350
# https://github.com/python/cpython/issues/92031
351+
from test.test_dis import ADAPTIVE_WARMUP_DELAY
351352

352-
code = textwrap.dedent("""\
353+
code = textwrap.dedent(f"""\
353354
import dis
354355
import importlib._bootstrap
355356
import opcode
356-
import test.test_dis
357357
358358
def is_specialized(f):
359359
for instruction in dis.get_instructions(f, adaptive=True):
@@ -373,7 +373,7 @@ def is_specialized(f):
373373
374374
assert not is_specialized(func), "specialized instructions found"
375375
376-
for i in range(test.test_dis.ADAPTIVE_WARMUP_DELAY):
376+
for i in range({ADAPTIVE_WARMUP_DELAY}):
377377
func(importlib._bootstrap, ["x"], lambda *args: None)
378378
379379
assert is_specialized(func), "no specialized instructions found"

0 commit comments

Comments
 (0)
0