(self)
| 4379 | self.assertIn("Restarting", stdout) |
| 4380 | |
| 4381 | def test_relative_imports(self): |
| 4382 | self.module_name = 't_main' |
| 4383 | os_helper.rmtree(self.module_name) |
| 4384 | main_file = self.module_name + '/__main__.py' |
| 4385 | init_file = self.module_name + '/__init__.py' |
| 4386 | module_file = self.module_name + '/module.py' |
| 4387 | self.addCleanup(os_helper.rmtree, self.module_name) |
| 4388 | os.mkdir(self.module_name) |
| 4389 | with open(init_file, 'w') as f: |
| 4390 | f.write(textwrap.dedent(""" |
| 4391 | top_var = "VAR from top" |
| 4392 | """)) |
| 4393 | with open(main_file, 'w') as f: |
| 4394 | f.write(textwrap.dedent(""" |
| 4395 | from . import top_var |
| 4396 | from .module import var |
| 4397 | from . import module |
| 4398 | pass # We'll stop here and print the vars |
| 4399 | """)) |
| 4400 | with open(module_file, 'w') as f: |
| 4401 | f.write(textwrap.dedent(""" |
| 4402 | var = "VAR from module" |
| 4403 | var2 = "second var" |
| 4404 | """)) |
| 4405 | commands = """ |
| 4406 | b 5 |
| 4407 | c |
| 4408 | p top_var |
| 4409 | p var |
| 4410 | p module.var2 |
| 4411 | quit |
| 4412 | """ |
| 4413 | stdout, _ = self._run_pdb(['-m', self.module_name], commands) |
| 4414 | self.assertTrue(any("VAR from module" in l for l in stdout.splitlines()), stdout) |
| 4415 | self.assertTrue(any("VAR from top" in l for l in stdout.splitlines())) |
| 4416 | self.assertTrue(any("second var" in l for l in stdout.splitlines())) |
| 4417 | |
| 4418 | def test_relative_imports_on_plain_module(self): |
| 4419 | # Validates running a plain module. See bpo32691 |
nothing calls this directly
no test coverage detected