@@ -514,6 +514,36 @@ def test_pdb_breakpoint_with_filename():
514514 (Pdb) continue
515515 """
516516
517+ def test_pdb_breakpoint_in_package ():
518+ """Breakpoints for package.module.function should work even if the module is not yet imported.
519+
520+ >>> def test_function():
521+ ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
522+ ... import multiprocessing.util # Now import the module
523+ ... multiprocessing.util.is_abstract_socket_namespace(None) # We should break here
524+
525+ >>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
526+ ... 'multiprocessing.util.is_abstract_socket_namespace', # Make sure the module is not imported yet
527+ ... 'break multiprocessing.util.is_abstract_socket_namespace', # We can still set a bp on it
528+ ... 'continue', # will stop at the function call
529+ ... 'clear 1',
530+ ... 'continue',
531+ ... ]):
532+ ... test_function()
533+ > <doctest test.test_pdb.test_pdb_breakpoint_in_package[0]>(2)test_function()
534+ -> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
535+ (Pdb) multiprocessing.util.is_abstract_socket_namespace
536+ *** NameError: name 'multiprocessing' is not defined. Did you forget to import 'multiprocessing'?
537+ (Pdb) break multiprocessing.util.is_abstract_socket_namespace
538+ Breakpoint 1 at ...util.py:...
539+ (Pdb) continue
540+ > ...util.py(...)is_abstract_socket_namespace()
541+ -> if not address:
542+ (Pdb) clear 1
543+ Deleted breakpoint 1 at ...util.py:...
544+ (Pdb) continue
545+ """
546+
517547def test_pdb_breakpoint_on_disabled_line ():
518548 """New breakpoint on once disabled line should work
519549
0 commit comments