[Python-checkins] bpo-34185: Fix test module collision in test_bdb when ran as script. (GH-8537)

Miss Islington (bot) webhook-mailer at python.org
Wed Dec 5 14:54:47 EST 2018


https://github.com/python/cpython/commit/c7c4e938b98068e8e4e5fe56d441db696d47de78
commit: c7c4e938b98068e8e4e5fe56d441db696d47de78
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-12-05T11:54:42-08:00
summary:

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 54fd45505b3a365e6d53441e6dd7e0d1ec13b46f)

Co-authored-by: Alex H <1884912+lajarre at users.noreply.github.com>

files:
M Lib/test/test_bdb.py

diff --git a/Lib/test/test_bdb.py b/Lib/test/test_bdb.py
index 616c3a864984..55f42e2535b7 100644
--- a/Lib/test/test_bdb.py
+++ b/Lib/test/test_bdb.py
@@ -549,11 +549,11 @@ def create_modules(modules):
 def break_in_func(funcname, fname=__file__, temporary=False, cond=None):
     return 'break', (fname, None, temporary, cond, funcname)
 
-TEST_MODULE = 'test_module'
+TEST_MODULE = 'test_module_for_bdb'
 TEST_MODULE_FNAME = TEST_MODULE + '.py'
 def tfunc_import():
-    import test_module
-    test_module.main()
+    import test_module_for_bdb
+    test_module_for_bdb.main()
 
 def tfunc_main():
     lno = 2
@@ -971,9 +971,9 @@ def main():
                 ('return', 3, 'main'),     ('step', ),
                 ('return', 1, '<module>'), ('quit', ),
             ]
-            import test_module
+            import test_module_for_bdb
             with TracerRun(self) as tracer:
-                tracer.runeval('test_module.main()', globals(), locals())
+                tracer.runeval('test_module_for_bdb.main()', globals(), locals())
 
 class IssuesTestCase(BaseTestCase):
     """Test fixed bdb issues."""
@@ -983,7 +983,7 @@ def test_step_at_return_with_no_trace_in_caller(self):
         # Check that the tracer does step into the caller frame when the
         # trace function is not set in that frame.
         code_1 = """
-            from test_module_2 import func
+            from test_module_for_bdb_2 import func
             def main():
                 func()
                 lno = 5
@@ -994,12 +994,12 @@ def func():
         """
         modules = {
             TEST_MODULE: code_1,
-            'test_module_2': code_2,
+            'test_module_for_bdb_2': code_2,
         }
         with create_modules(modules):
             self.expect_set = [
                 ('line', 2, 'tfunc_import'),
-                    break_in_func('func', 'test_module_2.py'),
+                    break_in_func('func', 'test_module_for_bdb_2.py'),
                 ('None', 2, 'tfunc_import'),      ('continue', ),
                 ('line', 3, 'func', ({1:1}, [])), ('step', ),
                 ('return', 3, 'func'),            ('step', ),



More information about the Python-checkins mailing list