Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54fd455

Browse files
lajarreserhiy-storchaka
authored andcommitted
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.
1 parent 34c7f0c commit 54fd455

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
@@ -549,11 +549,11 @@ def create_modules(modules):
549549
def break_in_func(funcname, fname=__file__, temporary=False, cond=None):
550550
return 'break', (fname, None, temporary, cond, funcname)
551551

552-
TEST_MODULE = 'test_module'
552+
TEST_MODULE = 'test_module_for_bdb'
553553
TEST_MODULE_FNAME = TEST_MODULE + '.py'
554554
def tfunc_import():
555-
import test_module
556-
test_module.main()
555+
import test_module_for_bdb
556+
test_module_for_bdb.main()
557557

558558
def tfunc_main():
559559
lno = 2
@@ -971,9 +971,9 @@ def main():
971971
('return', 3, 'main'), ('step', ),
972972
('return', 1, '<module>'), ('quit', ),
973973
]
974-
import test_module
974+
import test_module_for_bdb
975975
with TracerRun(self) as tracer:
976-
tracer.runeval('test_module.main()', globals(), locals())
976+
tracer.runeval('test_module_for_bdb.main()', globals(), locals())
977977

978978
class IssuesTestCase(BaseTestCase):
979979
"""Test fixed bdb issues."""
@@ -983,7 +983,7 @@ def test_step_at_return_with_no_trace_in_caller(self):
983983
# Check that the tracer does step into the caller frame when the
984984
# trace function is not set in that frame.
985985
code_1 = """
986-
from test_module_2 import func
986+
from test_module_for_bdb_2 import func
987987
def main():
988988
func()
989989
lno = 5
@@ -994,12 +994,12 @@ def func():
994994
"""
995995
modules = {
996996
TEST_MODULE: code_1,
997-
'test_module_2': code_2,
997+
'test_module_for_bdb_2': code_2,
998998
}
999999
with create_modules(modules):
10001000
self.expect_set = [
10011001
('line', 2, 'tfunc_import'),
1002-
break_in_func('func', 'test_module_2.py'),
1002+
break_in_func('func', 'test_module_for_bdb_2.py'),
10031003
('None', 2, 'tfunc_import'), ('continue', ),
10041004
('line', 3, 'func', ({1:1}, [])), ('step', ),
10051005
('return', 3, 'func'), ('step', ),

0 commit comments

Comments
 (0)