Skip to content

Commit

Permalink
tests: fix on windows for python>=3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
bretello committed Apr 18, 2024
1 parent 6424b16 commit 6b18fb6
Showing 1 changed file with 75 additions and 8 deletions.
83 changes: 75 additions & 8 deletions testing/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,8 +1227,14 @@ def c():
-> b()
# f 0
[ 0] > .*()
-> .*
# f -1
"""
+ (
"""-> .*
"""
if sys.platform == "win32" and sys.version_info < (3, 11)
else ""
)
+ f"""# f -1
[{len(traceback.extract_stack())}] > .*c()
-> return
# c
Expand Down Expand Up @@ -1367,14 +1373,20 @@ def c():

check(
a,
f"""
"""
[NUM] > .*c()
-> return
5 frames hidden .*
# top
[ 0] > .*()
-> .*
# bottom
"""
+ (
"""-> .*
"""
if sys.platform == "win32" and sys.version_info < (3, 11)
else ""
)
+ f"""# bottom
[{len(traceback.extract_stack())}] > .*c()
-> return
# c
Expand Down Expand Up @@ -5482,10 +5494,29 @@ def fn():
set_trace()

expected_bt = []
_entry: traceback.FrameSummary
for i, _entry in enumerate(traceback.extract_stack()[:-3]):
expected_bt.append(" [%2d] .*" % i)
expected_bt.append(f" [{i:2d}] .*")

if sys.platform == "win32" and sys.version_info >= (3, 11) and (
_entry.filename == "<frozen runpy>" and
any(
_entry.name == name for name in
(
"_run_module_as_main",
"_run_code",
)
)
):
# In this case, the first two frames of the traceback look like this:
# [ 0] <frozen runpy>(198)_run_module_as_main()
# [ 1] <frozen runpy>(88)_run_code()
# meaning we will not need the .* regex to match code for these frames
continue

expected_bt.append(" .*")


check(fn, r"""
--Return--
[NUM] > .*fn()->None
Expand All @@ -5506,8 +5537,26 @@ def fn():
set_trace(Config=ConfigWithHighlight)

expected_bt = []
_entry: traceback.FrameSummary
for i, _entry in enumerate(traceback.extract_stack()[:-3]):
expected_bt.append(" [%2d] .*" % i)
expected_bt.append(f" [{i:2d}] .*")

if sys.platform == "win32" and sys.version_info >= (3, 11) and (
_entry.filename == "<frozen runpy>" and
any(
_entry.name == name for name in
(
"_run_module_as_main",
"_run_code",
)
)
):
# In this case, the first two frames of the traceback look like this:
# [ 0] <frozen runpy>(198)_run_module_as_main()
# [ 1] <frozen runpy>(88)_run_code()
# meaning we will not need the .* regex to match code for these frames
continue

expected_bt.append(" .*")

check(fn, r"""
Expand All @@ -5530,8 +5579,26 @@ def fn():
set_trace(Config=ConfigWithPygments)

expected_bt = []
_entry: traceback.FrameSummary
for i, _entry in enumerate(traceback.extract_stack()[:-3]):
expected_bt.append(" [%2d] .*" % i)
expected_bt.append(f" [{i:2d}] .*")

if sys.platform == "win32" and sys.version_info >= (3, 11) and (
_entry.filename == "<frozen runpy>" and
any(
_entry.name == name for name in
(
"_run_module_as_main",
"_run_code",
)
)
):
# In this case, the first two frames of the traceback look like this:
# [ 0] <frozen runpy>(198)_run_module_as_main()
# [ 1] <frozen runpy>(88)_run_code()
# meaning we will not need the .* regex to match code for these frames
continue

expected_bt.append(" .*")

check(fn, r"""
Expand Down

0 comments on commit 6b18fb6

Please sign in to comment.