Skip to content

Commit bacc272

Browse files
bpo-34185: Fix test module collision in test_bdb when ran as script. (GH-8537)
When running test_bdb.py as a script, `import test_module` would be importing the existing Lib/test/test_modules.py instead of the tempcwd/test_module.py module which was dynamically created by test_bdb.py itself. (cherry picked from commit 54fd455) Co-authored-by: Alex H <1884912+lajarre@users.noreply.github.com>
1 parent c7976da commit bacc272

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Lib/test/test_bdb.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,11 @@ def create_modules(modules):
569569
def break_in_func(funcname, fname=__file__, temporary=False, cond=None):
570570
return 'break', (fname, None, temporary, cond, funcname)
571571

572-
TEST_MODULE = 'test_module'
572+
TEST_MODULE = 'test_module_for_bdb'
573573
TEST_MODULE_FNAME = TEST_MODULE + '.py'
574574
def tfunc_import():
575-
import test_module
576-
test_module.main()
575+
import test_module_for_bdb
576+
test_module_for_bdb.main()
577577

578578
def tfunc_main():
579579
lno = 2
@@ -985,9 +985,9 @@ def main():
985985
('return', 3, 'main'), ('step', ),
986986
('return', 1, '<module>'), ('quit', ),
987987
]
988-
import test_module
988+
import test_module_for_bdb
989989
with TracerRun(self) as tracer:
990-
tracer.runeval('test_module.main()', globals(), locals())
990+
tracer.runeval('test_module_for_bdb.main()', globals(), locals())
991991

992992
class IssuesTestCase(BaseTestCase):
993993
"""Test fixed bdb issues."""
@@ -997,7 +997,7 @@ def test_step_at_return_with_no_trace_in_caller(self):
997997
# Check that the tracer does step into the caller frame when the
998998
# trace function is not set in that frame.
999999
code_1 = """
1000-
from test_module_2 import func
1000+
from test_module_for_bdb_2 import func
10011001
def main():
10021002
func()
10031003
lno = 5
@@ -1008,12 +1008,12 @@ def func():
10081008
"""
10091009
modules = {
10101010
TEST_MODULE: code_1,
1011-
'test_module_2': code_2,
1011+
'test_module_for_bdb_2': code_2,
10121012
}
10131013
with create_modules(modules):
10141014
self.expect_set = [
10151015
('line', 2, 'tfunc_import'),
1016-
break_in_func('func', 'test_module_2.py'),
1016+
break_in_func('func', 'test_module_for_bdb_2.py'),
10171017
('None', 2, 'tfunc_import'), ('continue', ),
10181018
('line', 3, 'func', ({1:1}, [])), ('step', ),
10191019
('return', 3, 'func'), ('step', ),

0 commit comments

Comments
 (0)