Skip to content

Commit

Permalink
maybe this will work?
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz committed Dec 28, 2024
1 parent 59567ef commit a610c0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
28 changes: 12 additions & 16 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# Minimal tests for dis module
#
# Do NOT change the order of the imports since it could lead to a timeout for
# test_embed.test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE
# on Windows 32-bits.

import contextlib
import dis
import io
import opcode
import re
import sys
import tempfile
import types
import unittest
from test.support import (captured_stdout, requires_debug_ranges,
requires_specialization, cpython_only)
requires_specialization, cpython_only,
os_helper)
from test.support.bytecode_helper import BytecodeTestCase

import opcode


def get_tb():
def _error():
Expand Down Expand Up @@ -2074,17 +2071,16 @@ def get_disassembly(self, tb):


class TestDisCLI(unittest.TestCase):
pass

# def setUp(self):
# self.filename = tempfile.mktemp()
# self.addCleanup(os_helper.unlink, self.filename)
def setUp(self):
self.filename = tempfile.mktemp()
self.addCleanup(os_helper.unlink, self.filename)

# def test_invocation(self):
# with self.assertRaises(SystemExit):
# # suppress argparse error message
# with contextlib.redirect_stderr(io.StringIO()):
# dis.main(args=['--unknown', self.filename])
def test_invocation(self):
with self.assertRaises(SystemExit):
# suppress argparse error message
with contextlib.redirect_stderr(io.StringIO()):
dis.main(args=['--unknown', self.filename])


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@ def test_simple_initialization_api(self):
@support.requires_specialization
def test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE(self):
# https://github.com/python/cpython/issues/92031
from test.test_dis import ADAPTIVE_WARMUP_DELAY

code = textwrap.dedent("""\
code = textwrap.dedent(f"""\
import dis
import importlib._bootstrap
import opcode
import test.test_dis
def is_specialized(f):
for instruction in dis.get_instructions(f, adaptive=True):
Expand All @@ -373,7 +373,7 @@ def is_specialized(f):
assert not is_specialized(func), "specialized instructions found"
for i in range(test.test_dis.ADAPTIVE_WARMUP_DELAY):
for i in range({ADAPTIVE_WARMUP_DELAY}):
func(importlib._bootstrap, ["x"], lambda *args: None)
assert is_specialized(func), "no specialized instructions found"
Expand Down

0 comments on commit a610c0e

Please sign in to comment.