Skip to content

Commit 8af9bee

Browse files
committed
Update pandas_backports unittests to ensure coverage
1 parent 96a5e97 commit 8af9bee

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/unit/test_pandas_backports.py

+17
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,20 @@ def test_import_default_module_not_found(mock_import):
3535
default_class = type("OpsMixin", (), {}) # Dummy class
3636
result = pandas_backports.import_default("module_name", default=default_class)
3737
assert result == default_class
38+
39+
40+
@mock.patch("builtins.__import__")
41+
def test_import_default_force_true(mock_import):
42+
"""
43+
Test that when force=True, the default is returned immediately
44+
without attempting an import.
45+
"""
46+
default_class = type("ForcedMixin", (), {}) # A dummy class
47+
48+
result = pandas_backports.import_default(
49+
"any_module_name", force=True, default=default_class
50+
)
51+
52+
# Assert that the returned value is the default class itself
53+
assert result is default_class
54+

0 commit comments

Comments
 (0)