Skip to content

Commit 522cbbc

Browse files
committed
make tests pass when pandas isn't installed
1 parent a659a0c commit 522cbbc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

stringdtype/tests/test_stringdtype.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
import tempfile
66

77
import numpy as np
8-
import pandas as pd
8+
9+
try:
10+
from pandas import NA as pd_NA
11+
except ImportError:
12+
pd_NA = None
913
import pytest
1014

1115
from stringdtype import NA, StringDType, StringScalar, _memory_usage
@@ -16,8 +20,14 @@ def string_list():
1620
return ["abc", "def", "ghi", "A¢☃€ 😊", "Abc", "DEF"]
1721

1822

23+
pd_param = pytest.param(
24+
pd_NA,
25+
marks=pytest.mark.skipif(pd_NA is None, reason="pandas is not installed"),
26+
)
27+
28+
1929
@pytest.fixture(
20-
params=[None, NA, pd.NA], ids=["None", "stringdtype.NA", "pandas.NA"]
30+
params=[None, NA, pd_param], ids=["None", "stringdtype.NA", "pandas.NA"]
2131
)
2232
def dtype(request):
2333
return StringDType(na_object=request.param)

0 commit comments

Comments
 (0)