Skip to content
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
37150eb
ENH: add regression test for HTML repr of meta-objects (fixes #163)
arnavk23 Nov 19, 2025
b0ce58c
ENH: add test for all_objects tag filtering (regression for #161/#162)
arnavk23 Nov 19, 2025
b06f1fb
Delete skbase/base/_pretty_printing/tests/test_object_html_repr.py
arnavk23 Nov 19, 2025
b5c9c06
STYLE: wrap long docstring to satisfy flake8 E501
arnavk23 Nov 19, 2025
72a688c
tests(lookup): restrict package_name to skbase.tests to reduce scan s…
arnavk23 Nov 21, 2025
ef2a3de
tests(lookup): use dedicated mock_package fixtures; add fixtures and …
arnavk23 Nov 22, 2025
9dd4cd9
tests(mock_package): add public module, private module, and subpackag…
arnavk23 Nov 22, 2025
15b7935
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2025
d670fa2
style(tests): fix indentation (replace tabs with spaces) in mock_pack…
arnavk23 Nov 22, 2025
95db0d0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2025
08054cb
tests(mock_package): remove old files renamed to test_* counterparts
arnavk23 Nov 22, 2025
cfc4d14
correcting test file names
arnavk23 Nov 22, 2025
6e00981
fixing tags
arnavk23 Nov 28, 2025
0174af9
Fix flake8 B043 error: use variable for delattr attribute name
arnavk23 Dec 15, 2025
cea639d
Add arnavk23 (Arnav Kapoor) to contributors list
arnavk23 Dec 15, 2025
d36b14a
actual representation against the expected representation
arnavk23 Nov 23, 2025
a3f25fe
Fix test_get_package_metadata: remove imported classes from __all__ i…
arnavk23 Dec 15, 2025
5467010
Fix flake8 F401: add noqa comments for re-exported classes in mock_pa…
arnavk23 Dec 15, 2025
3a45ea6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 15, 2025
0d901dc
Merge branch 'main' into fix/issue-114-restrict-lookup-tests
arnavk23 Dec 21, 2025
31fcf6d
Merge branch 'main' into pr/476
fkiraly Jan 3, 2026
fac3d04
Update test_base.py
fkiraly Jan 3, 2026
20a572b
Merge branch 'main' into fix/issue-114-restrict-lookup-tests
arnavk23 Jan 4, 2026
a8946f8
Merge branch 'main' into fix/issue-114-restrict-lookup-tests
arnavk23 Jan 4, 2026
a1a97cb
Merge branch 'main' into fix/issue-114-restrict-lookup-tests
arnavk23 Jan 23, 2026
36e61c3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 23, 2026
b088695
Merge branch 'main' into fix/issue-114-restrict-lookup-tests
arnavk23 Jan 27, 2026
c86f4e4
removal of tests that are not relevant to the lookup tests, and to re…
arnavk23 Feb 14, 2026
3b74e86
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 14, 2026
46e0a8b
flake8
arnavk23 Feb 14, 2026
dc489fd
Merge branch 'main' into fix/issue-114-restrict-lookup-tests
arnavk23 Mar 5, 2026
e3e889e
Update test_lookup.py
arnavk23 Mar 6, 2026
acc90cd
Update .all-contributorsrc
arnavk23 Mar 6, 2026
188b76a
adding changes
arnavk23 Mar 6, 2026
e0cab6c
Merge branch 'main' into pr/476
fkiraly Apr 19, 2026
bd77634
added private class and function to mock package and added tests for …
arnavk23 Apr 19, 2026
b675afa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 19, 2026
69d395a
pre-commit
arnavk23 Apr 19, 2026
7761319
Merge branch 'fix/issue-114-restrict-lookup-tests' of https://www.git…
arnavk23 Apr 19, 2026
81bd3f9
Merge branch 'main' into fix/issue-114-restrict-lookup-tests
arnavk23 Apr 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@
]
},
{
"login": "arnavk23",
"name": "Arnav Kapoor",
"avatar_url": "https://avatars.githubusercontent.com/u/arnavk23?v=4",
"profile": "https://github.com/arnavk23",
"contributions": [
"bug",
"code",
"test"
]
},
"login": "RecreationalMath",
"name": "Nirbhai Singh",
"avatar_url": "https://avatars.githubusercontent.com/u/6928297?v=4",
Expand Down
140 changes: 70 additions & 70 deletions skbase/lookup/tests/test_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@
)
from skbase.tests.conftest import (
SKBASE_BASE_CLASSES,
SKBASE_CLASSES_BY_MODULE,
SKBASE_FUNCTIONS_BY_MODULE,
SKBASE_MODULES,
SKBASE_PUBLIC_CLASSES_BY_MODULE,
SKBASE_PUBLIC_FUNCTIONS_BY_MODULE,
SKBASE_PUBLIC_MODULES,
ClassWithABTrue,
Parent,
)
from skbase.tests.mock_package.test_mock_package import (
from skbase.tests.mock_package import (
MOCK_PACKAGE_CLASSES_BY_MODULE,
MOCK_PACKAGE_FUNCTIONS_BY_MODULE,
MOCK_PACKAGE_MODULES,
MOCK_PACKAGE_OBJECTS,
MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE,
MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE,
MOCK_PACKAGE_PUBLIC_MODULES,
ClassWithABTrue,
CompositionDummy,
NotABaseObject,
Parent,
)

__author__: List[str] = ["RNKuhns", "fkiraly"]
Expand Down Expand Up @@ -715,49 +715,75 @@ def test_get_package_metadata_tag_filter(tag_filter):
assert len(unfiltered_classes) > len(filtered_classes)


def test_get_return_tags():
"""Test _get_return_tags returns expected."""

def _test_get_return_tags_output(results, num_requested_tags):
return isinstance(results, tuple) and len(results) == num_requested_tags

# Verify return with tags that exist
tags = Parent.get_class_tags()
tag_names = [*tags.keys()]
results = _get_return_tags(Parent, tag_names)
assert (
_test_get_return_tags_output(results, len(tag_names))
and tuple(tags.values()) == results
)

# Verify results when some exist and some don't exist
tag_names += ["a_tag_that_does_not_exist"]
results = _get_return_tags(Parent, tag_names)
assert _test_get_return_tags_output(results, len(tag_names))

# Verify return when all tags don't exist
tag_names = ["a_tag_that_does_not_exist"]
results = _get_return_tags(Parent, tag_names)
assert _test_get_return_tags_output(results, len(tag_names)) and results[0] is None


@pytest.mark.parametrize("exclude_non_public_modules", [True, False])
@pytest.mark.parametrize("exclude_non_public_items", [True, False])
def test_get_package_metadata_returns_expected_results(
def test_get_package_metadata_returns_expected_results_mock_package(
exclude_non_public_modules, exclude_non_public_items
):
"""Test that get_package_metadata_returns expected results using skbase."""
"""Test that get_package_metadata returns expected results for mock package.

This test validates the lookup retrieval against configuration constants
that define the expected classes and functions for each module in the
mock package, checking both public and non-public items.
"""
results = get_package_metadata(
"skbase",
"skbase.tests.mock_package",
exclude_non_public_items=exclude_non_public_items,
exclude_non_public_modules=exclude_non_public_modules,
package_base_classes=SKBASE_BASE_CLASSES,
modules_to_ignore="tests",
classes_to_exclude=TagAliaserMixin,
suppress_import_stdout=False,
modules_to_ignore=None,
suppress_import_stdout=True,
)
public_modules_excluding_tests = [
module
for module in SKBASE_PUBLIC_MODULES
if not _is_ignored_module(module, modules_to_ignore="tests")
]
modules_excluding_tests = [
module
for module in SKBASE_MODULES
if not _is_ignored_module(module, modules_to_ignore="tests")
]

# Determine which modules to expect based on parameters
if exclude_non_public_modules:
assert tuple(results.keys()) == tuple(public_modules_excluding_tests)
expected_modules = MOCK_PACKAGE_PUBLIC_MODULES
else:
assert tuple(results.keys()) == tuple(modules_excluding_tests)
expected_modules = MOCK_PACKAGE_MODULES

# Verify we got the expected modules
assert set(results.keys()) == set(expected_modules)

# Verify each module has the expected classes and functions
for module in results:
if exclude_non_public_items:
module_funcs = SKBASE_PUBLIC_FUNCTIONS_BY_MODULE.get(module, ())
module_classes = SKBASE_PUBLIC_CLASSES_BY_MODULE.get(module, ())
module_funcs = MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE.get(module, ())
module_classes = MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE.get(module, ())
which_str = "public"
fun_str = "SKBASE_PUBLIC_FUNCTIONS_BY_MODULE"
cls_str = "SKBASE_PUBLIC_CLASSES_BY_MODULE"
fun_str = "MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE"
cls_str = "MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE"
else:
module_funcs = SKBASE_FUNCTIONS_BY_MODULE.get(module, ())
module_classes = SKBASE_CLASSES_BY_MODULE.get(module, ())
module_funcs = MOCK_PACKAGE_FUNCTIONS_BY_MODULE.get(module, ())
module_classes = MOCK_PACKAGE_CLASSES_BY_MODULE.get(module, ())
which_str = "all"
fun_str = "SKBASE_FUNCTIONS_BY_MODULE"
cls_str = "SKBASE_CLASSES_BY_MODULE"
fun_str = "MOCK_PACKAGE_FUNCTIONS_BY_MODULE"
cls_str = "MOCK_PACKAGE_CLASSES_BY_MODULE"

# Verify expected functions are returned
retrieved_funcs = set(results[module]["functions"].keys())
Expand All @@ -769,7 +795,7 @@ def test_get_package_metadata_returns_expected_results(
f"for {which_str} functions in module {module} do not match expected. "
f"Expected: {expected_funcs}; "
f"retrieved: {retrieved_funcs}. "
f"Expected functions are stored in {fun_str}, in test_lookup."
f"Expected functions are stored in {fun_str}, in mock_package."
)
raise AssertionError(msg)

Expand All @@ -783,11 +809,11 @@ def test_get_package_metadata_returns_expected_results(
f"for {which_str} classes in module {module} do not match expected. "
f"Expected: {expected_cls}; "
f"retrieved: {retrieved_cls}. "
f"Expected functions are stored in {cls_str}, in test_lookup."
f"Expected classes are stored in {cls_str}, in mock_package."
)
raise AssertionError(msg)

# Verify class metadata attributes correct
# Verify class metadata attributes are correct
for klass, klass_metadata in results[module]["classes"].items():
if klass_metadata["klass"] in SKBASE_BASE_CLASSES:
assert (
Expand All @@ -812,32 +838,6 @@ def test_get_package_metadata_returns_expected_results(
assert klass_metadata["is_concrete_implementation"] is False


def test_get_return_tags():
"""Test _get_return_tags returns expected."""

def _test_get_return_tags_output(results, num_requested_tags):
return isinstance(results, tuple) and len(results) == num_requested_tags

# Verify return with tags that exist
tags = Parent.get_class_tags()
tag_names = [*tags.keys()]
results = _get_return_tags(Parent, tag_names)
assert (
_test_get_return_tags_output(results, len(tag_names))
and tuple(tags.values()) == results
)

# Verify results when some exist and some don't exist
tag_names += ["a_tag_that_does_not_exist"]
results = _get_return_tags(Parent, tag_names)
assert _test_get_return_tags_output(results, len(tag_names))

# Verify return when all tags don't exist
tag_names = ["a_tag_that_does_not_exist"]
results = _get_return_tags(Parent, tag_names)
assert _test_get_return_tags_output(results, len(tag_names)) and results[0] is None


def test_get_package_metadata_matches_expected_representation_mock_package():
"""Verify get_package_metadata returns the expected representation for the
controlled `skbase.tests.mock_package` mock package.
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def test_all_objects_class_filter(class_filter):
"""Test all_objects filters by class type as expected."""
# Results applying filter
objs = all_objects(
package_name="skbase",
package_name="skbase.tests.mock_package",
return_names=True,
as_dataframe=True,
return_tags=None,
Expand All @@ -1047,7 +1047,7 @@ def test_all_objects_class_filter(class_filter):

# Results without filter
objs = all_objects(
package_name="skbase",
package_name="skbase.tests.mock_package",
return_names=True,
as_dataframe=True,
return_tags=None,
Expand All @@ -1073,7 +1073,7 @@ def test_all_object_tag_filter(tag_filter):
"""Test all_objects filters by tag as expected."""
# Results applying filter
objs = all_objects(
package_name="skbase",
package_name="skbase.tests.mock_package",
return_names=True,
as_dataframe=True,
return_tags=None,
Expand All @@ -1087,7 +1087,7 @@ def test_all_object_tag_filter(tag_filter):

# Results without filter
objs = all_objects(
package_name="skbase",
package_name="skbase.tests.mock_package",
return_names=True,
as_dataframe=True,
return_tags=None,
Expand Down Expand Up @@ -1148,7 +1148,7 @@ def test_all_object_class_lookup(class_lookup, class_filter):
"""Test all_objects class_lookup parameter works as expected.."""
# Results applying filter
objs = all_objects(
package_name="skbase",
package_name="skbase.tests.mock_package",
return_names=True,
as_dataframe=True,
return_tags=None,
Expand All @@ -1171,7 +1171,7 @@ def test_all_object_class_lookup_invalid_object_types_raises(
# Results applying filter
with pytest.raises(ValueError):
all_objects(
package_name="skbase",
package_name="skbase.tests.mock_package",
return_names=True,
as_dataframe=True,
return_tags=None,
Expand Down
2 changes: 1 addition & 1 deletion skbase/testing/test_all_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def test_object_tags(self, object_class):
assert isinstance(tags, dict), msg
assert len(tags) > 0, f"_tags dict of class {object_class} is empty"
if self.valid_tags is None:
invalid_tags = tags
invalid_tags = []
else:
invalid_tags = [
tag for tag in tags.keys() if tag not in self.valid_tags
Expand Down
Loading
Loading