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

Method test_package_without_a_main

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

Source from the content-addressed store, hash-verified

4213 self.assertIn("ImportError: No module named t_main.__main__;", stdout)
4214
4215 def test_package_without_a_main(self):
4216 pkg_name = 't_pkg'
4217 module_name = 't_main'
4218 os_helper.rmtree(pkg_name)
4219 modpath = pkg_name + '/' + module_name
4220 os.makedirs(modpath)
4221 with open(modpath + '/__init__.py', 'w'):
4222 pass
4223 self.addCleanup(os_helper.rmtree, pkg_name)
4224 stdout, stderr = self._run_pdb(
4225 ['-m', modpath.replace('/', '.')], "", expected_returncode=1
4226 )
4227 self.assertIn(
4228 "'t_pkg.t_main' is a package and cannot be directly executed",
4229 stdout)
4230
4231 def test_nonexistent_module(self):
4232 assert not os.path.exists(os_helper.TESTFN)

Callers

nothing calls this directly

Calls 5

_run_pdbMethod · 0.95
addCleanupMethod · 0.80
assertInMethod · 0.80
openFunction · 0.50
replaceMethod · 0.45

Tested by

no test coverage detected