-
- Notifications
You must be signed in to change notification settings - Fork 33.3k
bpo-32691: Use mod_spec.parent when running modules with pdb #5474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -1417,7 +1417,7 @@ def test_blocks_at_first_code_line(self): | |
| def test_relative_imports(self): | ||
| Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we do want to explicitly test both paths through Alternatively, you could add some unit tests for Contributor Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've duplicated the test (added one for the plain modules situation). Additionally, if you find interesting the idea of making _get_module_details public I can file an issue and draft something out, as it will be useful for the other PRs on running as module | ||
| self.module_name = 't_main' | ||
| support.rmtree(self.module_name) | ||
| main_file = self.module_name + '/__main__.py' | ||
| main_file = self.module_name + '/runme.py' | ||
| init_file = self.module_name + '/__init__.py' | ||
| module_file = self.module_name + '/module.py' | ||
| self.addCleanup(support.rmtree, self.module_name) | ||
| | @@ -1446,8 +1446,8 @@ def test_relative_imports(self): | |
| p module.var2 | ||
| quit | ||
| """ | ||
| stdout, _ = self._run_pdb(['-m', self.module_name], commands) | ||
| self.assertTrue(any("VAR from module" in l for l in stdout.splitlines())) | ||
| stdout, _ = self._run_pdb(['-m', self.module_name + '.runme'], commands) | ||
| self.assertTrue(any("VAR from module" in l for l in stdout.splitlines()), stdout) | ||
| self.assertTrue(any("VAR from top" in l for l in stdout.splitlines())) | ||
| self.assertTrue(any("second var" in l for l in stdout.splitlines())) | ||
| | ||
| | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Use mod_spec.parent when running modules with pdb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I initially thought this was wrong, but I'd forgotten that it's
runpy._get_module_detailsthat handles the recursive search forpkg.__main__, somod_spec.parent == module_namein those cases.