Visitar URL original
Fix crashing monkeypatch in `test_pandas_cow` by Ayskin · Pull Request #3571 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Changes from all commits
Commits
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
replace crashing monkeypatch in pd options
  • Loading branch information
Ayskin committed Oct 29, 2026
commit 12140e2d83e5e6c58a18106f0e8cb7ddb461ea4f
14 changes: 12 additions & 2 deletions tests/utils/test_pandas_cow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,20 @@
# ---------------------------------------------------------------------------


@pytest.fixture(autouse=True)
def _restore_pandas_options():
"""Globally avoid pandas options change leak."""
with pd.option_context(
"future.infer_string",
pd.get_option("future.infer_string"),
"mode.copy_on_write",
pd.get_option("mode.copy_on_write"),
):
yield


def _configure_cow_true(monkeypatch) -> None:
"""Configure pandas CoW via the DLC future-mode machinery."""
monkeypatch.setattr(pd.options.future, "infer_string", pd.options.future.infer_string)
monkeypatch.setattr(pd.options.mode, "copy_on_write", pd.options.mode.copy_on_write)
monkeypatch.setenv("DLC_PANDAS_FUTURE", "1")
configure_pandas_future_if_enabled()

Expand Down
Loading