Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral committed Dec 2, 2024
1 parent 950534f commit 3f1002b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion monkay/_monkay_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def find_missing(
]
],
]:
"""Debug method to check"""
"""Debug method to check missing imports"""
self._init_global_getter_hook()

assert self.getter is not None
missing: dict[
Expand Down
48 changes: 48 additions & 0 deletions tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,51 @@ def test_add(monkay_fn, export, in_all):
if in_all:
assert export in mod.__all__
assert mod.monkay.getter(export, no_warn_deprecated=True, check_globals_dict=True) is not None


@pytest.mark.parametrize(
"monkay_fn,export",
[
(lambda m: m.add_lazy_import("bar", ".fn_module:bar"), "bar"),
(
lambda m: m.add_deprecated_lazy_import(
"deprecated",
{
"path": "tests.targets.fn_module:deprecated",
"reason": "old.",
"new_attribute": "super_new",
},
),
"deprecated",
),
(
lambda m: m.add_lazy_import(
"bar2",
".fn_module:bar",
no_hooks=True,
),
"bar2",
),
(
lambda m: m.add_deprecated_lazy_import(
"deprecated2",
{
"path": "tests.targets.fn_module:deprecated",
"reason": "old.",
"new_attribute": "super_new",
},
no_hooks=True,
),
"deprecated2",
),
],
)
def test_none_add(monkay_fn, export):
import tests.targets.module_none as mod

monkay_fn(mod.monkay)
mod.__all__ = mod.monkay.update_all_var([])
assert export in mod.__all__
assert (
mod.monkay.getter(export, no_warn_deprecated=True, check_globals_dict="fail") is not None
)

0 comments on commit 3f1002b

Please sign in to comment.