_import_module clears and re-registers a custom module that was previously loaded into _custom_module_map.
(tmpdir)
| 869 | |
| 870 | |
| 871 | def 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 | |
| 901 | def test_build_dep_counter_empty_map(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…