Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit798ace5

Browse files
gh-93951: In test_bdb.StateTestCase.test_skip, avoid including auxiliary importers. (GH-93962) (GH-94119)
Co-authored-by: Brett Cannon <brett@python.org>(cherry picked from commitc029b55)Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
1 parent525ab8f commit798ace5

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

‎Lib/test/support/__init__.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,16 @@ def cleanup():
16811681
setattr(object_to_patch,attr_name,new_value)
16821682

16831683

1684+
@contextlib.contextmanager
1685+
defpatch_list(orig):
1686+
"""Like unittest.mock.patch.dict, but for lists."""
1687+
try:
1688+
saved=orig[:]
1689+
yield
1690+
finally:
1691+
orig[:]=saved
1692+
1693+
16841694
defrun_in_subinterp(code):
16851695
"""
16861696
Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc

‎Lib/test/test_bdb.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
fromitertoolsimportislice,repeat
6060
fromtest.supportimportimport_helper
6161
fromtest.supportimportos_helper
62+
fromtest.supportimportpatch_list
6263

6364

6465
classBdbException(Exception):pass
@@ -713,9 +714,18 @@ def test_until_in_caller_frame(self):
713714
withTracerRun(self)astracer:
714715
tracer.runcall(tfunc_main)
715716

717+
@patch_list(sys.meta_path)
716718
deftest_skip(self):
717719
# Check that tracing is skipped over the import statement in
718720
# 'tfunc_import()'.
721+
722+
# Remove all but the standard importers.
723+
sys.meta_path[:]= (
724+
item
725+
foriteminsys.meta_path
726+
ifitem.__module__.startswith('_frozen_importlib')
727+
)
728+
719729
code="""
720730
def main():
721731
lno = 3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In test_bdb.StateTestCase.test_skip, avoid including auxiliary importers.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp