MCPcopy
hub / github.com/caronc/apprise / test_module_detection_reload_existing

Function test_module_detection_reload_existing

tests/test_notification_manager.py:871–898  ·  view source on GitHub ↗

_import_module clears and re-registers a custom module that was previously loaded into _custom_module_map.

(tmpdir)

Source from the content-addressed store, hash-verified

869
870
871def test_module_detection_reload_existing(tmpdir):
872 """_import_module clears and re-registers a custom module that was
873 previously loaded into _custom_module_map."""
874 N_MGR.unload_modules()
875
876 hook = tmpdir.mkdir("reloadpkg_xyz").join("__init__.py")
877 hook.write(
878 cleandoc("""
879 from apprise.decorators import notify
880
881 @notify(on="reloadhookxyz")
882 def handler(body, title, notify_type, *args, **kwargs):
883 pass
884 """)
885 )
886
887 # First load — populates _custom_module_map
888 N_MGR.module_detection(str(hook))
889 assert "reloadhookxyz" in N_MGR
890
891 # Remove path from cache so the same file is processed a second time
892 N_MGR._paths_previously_scanned.discard(str(hook))
893
894 # Second load -> _import_module finds module_pyname already in
895 # _custom_module_map -> clear + re-register
896 N_MGR.module_detection(str(hook))
897 assert "reloadhookxyz" in N_MGR
898 N_MGR.unload_modules()
899
900
901def test_build_dep_counter_empty_map():

Callers

nothing calls this directly

Calls 4

unload_modulesMethod · 0.80
module_detectionMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…