Skip to content

Commit 20d7c27

Browse files
committed
make doctest conftest available everywhere
1 parent 5d23dee commit 20d7c27

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

bigframes/conftest.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,23 @@
2222
import bigframes._config
2323

2424

25-
@pytest.fixture(scope="session")
26-
def polars_session():
27-
pytest.importorskip("polars")
28-
29-
from bigframes.testing import polars_session
30-
31-
return polars_session.TestSession()
32-
33-
3425
@pytest.fixture(autouse=True)
35-
def default_doctest_imports(doctest_namespace, polars_session):
26+
def default_doctest_imports(doctest_namespace):
3627
"""
3728
Avoid some boilerplate in pandas-inspired tests.
3829
3930
See: https://docs.pytest.org/en/stable/how-to/doctest.html#doctest-namespace-fixture
4031
"""
32+
try:
33+
from bigframes.testing import polars_session
34+
35+
bpd = polars_session.TestSession()
36+
except ImportError:
37+
# Don't skip doctest if polars isn't available.
38+
import bigframes.pandas as bpd # type: ignore
39+
4140
doctest_namespace["np"] = np
4241
doctest_namespace["pd"] = pd
4342
doctest_namespace["pa"] = pa
44-
doctest_namespace["bpd"] = polars_session
43+
doctest_namespace["bpd"] = bpd
4544
bigframes._config.options.display.progress_bar = None

third_party/bigframes_vendored/pandas/conftest.py renamed to third_party/bigframes_vendored/conftest.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,23 @@
2222
import bigframes._config
2323

2424

25-
@pytest.fixture(scope="session")
26-
def polars_session():
27-
pytest.importorskip("polars")
28-
29-
from bigframes.testing import polars_session
30-
31-
return polars_session.TestSession()
32-
33-
3425
@pytest.fixture(autouse=True)
35-
def default_doctest_imports(doctest_namespace, polars_session):
26+
def default_doctest_imports(doctest_namespace):
3627
"""
3728
Avoid some boilerplate in pandas-inspired tests.
3829
3930
See: https://docs.pytest.org/en/stable/how-to/doctest.html#doctest-namespace-fixture
4031
"""
32+
try:
33+
from bigframes.testing import polars_session
34+
35+
bpd = polars_session.TestSession()
36+
except ImportError:
37+
# Don't skip doctest if polars isn't available.
38+
import bigframes.pandas as bpd
39+
4140
doctest_namespace["np"] = np
4241
doctest_namespace["pd"] = pd
4342
doctest_namespace["pa"] = pa
44-
doctest_namespace["bpd"] = polars_session
43+
doctest_namespace["bpd"] = bpd
4544
bigframes._config.options.display.progress_bar = None

0 commit comments

Comments
 (0)