MCPcopy Index your code
hub / github.com/python/cpython / test_relative_imports_on_plain_module

Method test_relative_imports_on_plain_module

Lib/test/test_pdb.py:4418–4447  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
4420 self.module_name = 't_main'
4421 os_helper.rmtree(self.module_name)
4422 main_file = self.module_name + '/runme.py'
4423 init_file = self.module_name + '/__init__.py'
4424 module_file = self.module_name + '/module.py'
4425 self.addCleanup(os_helper.rmtree, self.module_name)
4426 os.mkdir(self.module_name)
4427 with open(init_file, 'w') as f:
4428 f.write(textwrap.dedent("""
4429 top_var = "VAR from top"
4430 """))
4431 with open(main_file, 'w') as f:
4432 f.write(textwrap.dedent("""
4433 from . import module
4434 pass # We'll stop here and print the vars
4435 """))
4436 with open(module_file, 'w') as f:
4437 f.write(textwrap.dedent("""
4438 var = "VAR from module"
4439 """))
4440 commands = """
4441 b 3
4442 c
4443 p module.var
4444 quit
4445 """
4446 stdout, _ = self._run_pdb(['-m', self.module_name + '.runme'], commands)
4447 self.assertTrue(any("VAR from module" in l for l in stdout.splitlines()), stdout)
4448
4449 def test_errors_in_command(self):
4450 commands = "\n".join([

Callers

nothing calls this directly

Calls 9

_run_pdbMethod · 0.95
addCleanupMethod · 0.80
assertTrueMethod · 0.80
openFunction · 0.50
anyFunction · 0.50
mkdirMethod · 0.45
writeMethod · 0.45
dedentMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected