Skip to content

TST: use env variable instead of pytest option for testing ArrayManager #40222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 18 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,25 @@ jobs:
uses: ./.github/actions/setup

- name: Run tests
env:
PANDAS_DATA_MANAGER: array
run: |
source activate pandas-dev
pytest pandas/tests/frame/methods --array-manager
pytest pandas/tests/frame/test_constructors.py --array-manager
pytest pandas/tests/frame/constructors/ --array-manager
pytest pandas/tests/frame/test_reductions.py --array-manager
pytest pandas/tests/reductions/ --array-manager
pytest pandas/tests/generic/test_generic.py --array-manager
pytest pandas/tests/arithmetic/ --array-manager
pytest pandas/tests/groupby/ --array-manager
pytest pandas/tests/resample/ --array-manager
pytest pandas/tests/reshape/merge --array-manager
pytest pandas/tests/frame/methods
pytest pandas/tests/frame/test_constructors.py
pytest pandas/tests/frame/constructors/
pytest pandas/tests/frame/test_reductions.py
pytest pandas/tests/reductions/
pytest pandas/tests/generic/test_generic.py
pytest pandas/tests/arithmetic/
pytest pandas/tests/groupby/
pytest pandas/tests/resample/
pytest pandas/tests/reshape/merge

# indexing subset (temporary since other tests don't pass yet)
pytest pandas/tests/frame/indexing/test_indexing.py::TestDataFrameIndexing::test_setitem_boolean --array-manager
pytest pandas/tests/frame/indexing/test_where.py --array-manager
pytest pandas/tests/frame/indexing/test_setitem.py::TestDataFrameSetItem::test_setitem_multi_index --array-manager
pytest pandas/tests/frame/indexing/test_setitem.py::TestDataFrameSetItem::test_setitem_listlike_indexer_duplicate_columns --array-manager
pytest pandas/tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_astype_assignment_with_dups --array-manager
pytest pandas/tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_frame_setitem_multi_column --array-manager
pytest pandas/tests/frame/indexing/test_indexing.py::TestDataFrameIndexing::test_setitem_boolean
pytest pandas/tests/frame/indexing/test_where.py
pytest pandas/tests/frame/indexing/test_setitem.py::TestDataFrameSetItem::test_setitem_multi_index
pytest pandas/tests/frame/indexing/test_setitem.py::TestDataFrameSetItem::test_setitem_listlike_indexer_duplicate_columns
pytest pandas/tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_astype_assignment_with_dups
pytest pandas/tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_frame_setitem_multi_column
8 changes: 7 additions & 1 deletion pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
module is imported, register them here rather than in the module.

"""
import os
import warnings

import pandas._config.config as cf
Expand Down Expand Up @@ -478,14 +479,19 @@ def use_inf_as_na_cb(key):
_use_inf_as_na(key)


# Get the default from an environment variable, if set, otherwise defaults to "block"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would just inline this on L494 (and add a 1-liner comment before) and/or update the option description with the text on how to control this

# This environment variable can be set for testing
_data_manager_default = os.environ.get("PANDAS_DATA_MANAGER", "block")


with cf.config_prefix("mode"):
cf.register_option("use_inf_as_na", False, use_inf_as_na_doc, cb=use_inf_as_na_cb)
cf.register_option(
"use_inf_as_null", False, use_inf_as_null_doc, cb=use_inf_as_na_cb
)
cf.register_option(
"data_manager",
"block",
_data_manager_default,
"Internal data manager type",
validator=is_one_of_factory(["block", "array"]),
)
Expand Down
11 changes: 4 additions & 7 deletions pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def test_foo():
import numpy as np
import pytest

from pandas._config import get_option

from pandas.compat import (
IS64,
is_platform_windows,
Expand Down Expand Up @@ -285,16 +287,11 @@ def async_mark():
return async_mark


# Note: we are using a string as condition (and not for example
# `get_option("mode.data_manager") == "array"`) because this needs to be
# evaluated at test time (otherwise this boolean condition gets evaluated
# at import time, when the pd.options.mode.data_manager has not yet been set)

skip_array_manager_not_yet_implemented = pytest.mark.skipif(
"config.getvalue('--array-manager')", reason="JSON C code relies on Blocks"
get_option("mode.data_manager") == "array", reason="JSON C code relies on Blocks"
)

skip_array_manager_invalid_test = pytest.mark.skipif(
"config.getvalue('--array-manager')",
get_option("mode.data_manager") == "array",
reason="Test that relies on BlockManager internals or specific behaviour",
)