We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 96a5e97 commit 8af9beeCopy full SHA for 8af9bee
tests/unit/test_pandas_backports.py
@@ -35,3 +35,20 @@ def test_import_default_module_not_found(mock_import):
35
default_class = type("OpsMixin", (), {}) # Dummy class
36
result = pandas_backports.import_default("module_name", default=default_class)
37
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