Skip to content

Commit b979816

Browse files
authored
TST: release testing of downstream packages (pandas-dev#16261)
1 parent 8809b04 commit b979816

7 files changed

+67
-38
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ after_success:
123123

124124
after_script:
125125
- echo "after_script start"
126-
- source activate pandas && python -c "import pandas; pandas.show_versions();"
126+
- source activate pandas && cd /tmp && python -c "import pandas; pandas.show_versions();"
127127
- if [ -e /tmp/single.xml ]; then
128128
ci/print_skipped.py /tmp/single.xml;
129129
fi

ci/install_travis.sh

+16-11
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,7 @@ if [ "$COVERAGE" ]; then
119119
fi
120120

121121
echo
122-
if [ "$BUILD_TEST" ]; then
123-
124-
# build & install testing
125-
echo ["Starting installation test."]
126-
bash ci/install_release_build.sh
127-
conda uninstall -y cython
128-
time pip install dist/*tar.gz || exit 1
129-
130-
else
122+
if [ -z "$BUILD_TEST" ]; then
131123

132124
# build but don't install
133125
echo "[build em]"
@@ -163,9 +155,22 @@ fi
163155
# w/o removing anything else
164156
echo
165157
echo "[removing installed pandas]"
166-
conda remove pandas --force
158+
conda remove pandas -y --force
167159

168-
if [ -z "$BUILD_TEST" ]; then
160+
if [ "$BUILD_TEST" ]; then
161+
162+
# remove any installation
163+
pip uninstall -y pandas
164+
conda list pandas
165+
pip list --format columns |grep pandas
166+
167+
# build & install testing
168+
echo ["building release"]
169+
bash scripts/build_dist_for_release.sh
170+
conda uninstall -y cython
171+
time pip install dist/*tar.gz || exit 1
172+
173+
else
169174

170175
# install our pandas
171176
echo

ci/script_multi.sh

+13-7
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,26 @@ export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 429496
1919
echo PYTHONHASHSEED=$PYTHONHASHSEED
2020

2121
if [ "$BUILD_TEST" ]; then
22-
echo "build-test"
22+
echo "[build-test]"
23+
24+
echo "[env]"
25+
pip list --format columns |grep pandas
26+
27+
echo "[running]"
2328
cd /tmp
24-
pwd
25-
conda list pandas
26-
echo "running"
27-
python -c "import pandas; pandas.test(['-n 2'])"
29+
unset PYTHONPATH
30+
python -c "import pandas; pandas.test(['-n 2', '--skip-slow', '--skip-network', '-r xX'])"
31+
2832
elif [ "$DOC" ]; then
2933
echo "We are not running pytest as this is a doc-build"
34+
3035
elif [ "$COVERAGE" ]; then
3136
echo pytest -s -n 2 -m "not single" --cov=pandas --cov-report xml:/tmp/cov-multiple.xml --junitxml=/tmp/multiple.xml $TEST_ARGS pandas
3237
pytest -s -n 2 -m "not single" --cov=pandas --cov-report xml:/tmp/cov-multiple.xml --junitxml=/tmp/multiple.xml $TEST_ARGS pandas
38+
3339
else
34-
echo pytest -n 2 -m "not single" --junitxml=/tmp/multiple.xml $TEST_ARGS pandas
35-
pytest -n 2 -m "not single" --junitxml=/tmp/multiple.xml $TEST_ARGS pandas # TODO: doctest
40+
echo pytest -n 2 -r xX -m "not single" --junitxml=/tmp/multiple.xml $TEST_ARGS pandas
41+
pytest -n 2 -r xX -m "not single" --junitxml=/tmp/multiple.xml $TEST_ARGS pandas # TODO: doctest
3642
fi
3743

3844
RET="$?"

ci/script_single.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ elif [ "$COVERAGE" ]; then
2020
echo pytest -s -m "single" --cov=pandas --cov-report xml:/tmp/cov-single.xml --junitxml=/tmp/single.xml $TEST_ARGS pandas
2121
pytest -s -m "single" --cov=pandas --cov-report xml:/tmp/cov-single.xml --junitxml=/tmp/single.xml $TEST_ARGS pandas
2222
else
23-
echo pytest -m "single" --junitxml=/tmp/single.xml $TEST_ARGS pandas
24-
pytest -m "single" --junitxml=/tmp/single.xml $TEST_ARGS pandas # TODO: doctest
23+
echo pytest -m "single" -r xX --junitxml=/tmp/single.xml $TEST_ARGS pandas
24+
pytest -m "single" -r xX --junitxml=/tmp/single.xml $TEST_ARGS pandas # TODO: doctest
2525
fi
2626

2727
RET="$?"

pandas/tests/test_downstream.py

+33-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,28 @@
44
import pytest
55
import numpy as np # noqa
66
from pandas import DataFrame
7+
from pandas.compat import PY36
78
from pandas.util import testing as tm
9+
import importlib
10+
11+
12+
def import_module(name):
13+
# we *only* want to skip if the module is truly not available
14+
# and NOT just an actual import error because of pandas changes
15+
16+
if PY36:
17+
try:
18+
return importlib.import_module(name)
19+
except ModuleNotFoundError: # noqa
20+
pytest.skip("skipping as {} not available".format(name))
21+
22+
else:
23+
try:
24+
return importlib.import_module(name)
25+
except ImportError as e:
26+
if "No module named" in str(e) and name in str(e):
27+
pytest.skip("skipping as {} not available".format(name))
28+
raise
829

930

1031
@pytest.fixture
@@ -14,8 +35,8 @@ def df():
1435

1536
def test_dask(df):
1637

17-
toolz = pytest.importorskip('toolz') # noqa
18-
dask = pytest.importorskip('dask') # noqa
38+
toolz = import_module('toolz') # noqa
39+
dask = import_module('dask') # noqa
1940

2041
import dask.dataframe as dd
2142

@@ -26,14 +47,14 @@ def test_dask(df):
2647

2748
def test_xarray(df):
2849

29-
xarray = pytest.importorskip('xarray') # noqa
50+
xarray = import_module('xarray') # noqa
3051

3152
assert df.to_xarray() is not None
3253

3354

3455
def test_statsmodels():
3556

36-
statsmodels = pytest.importorskip('statsmodels') # noqa
57+
statsmodels = import_module('statsmodels') # noqa
3758
import statsmodels.api as sm
3859
import statsmodels.formula.api as smf
3960
df = sm.datasets.get_rdataset("Guerry", "HistData").data
@@ -42,7 +63,7 @@ def test_statsmodels():
4263

4364
def test_scikit_learn(df):
4465

45-
sklearn = pytest.importorskip('sklearn') # noqa
66+
sklearn = import_module('sklearn') # noqa
4667
from sklearn import svm, datasets
4768

4869
digits = datasets.load_digits()
@@ -53,33 +74,34 @@ def test_scikit_learn(df):
5374

5475
def test_seaborn():
5576

56-
seaborn = pytest.importorskip('seaborn')
77+
seaborn = import_module('seaborn')
5778
tips = seaborn.load_dataset("tips")
5879
seaborn.stripplot(x="day", y="total_bill", data=tips)
5980

6081

6182
def test_pandas_gbq(df):
6283

63-
pandas_gbq = pytest.importorskip('pandas-gbq') # noqa
84+
pandas_gbq = import_module('pandas_gbq') # noqa
6485

6586

66-
@tm.network
87+
@pytest.mark.xfail(reason=("pandas_datareader<=0.3.0 "
88+
"broken w.r.t. pandas >= 0.20.0"))
6789
def test_pandas_datareader():
6890

69-
pandas_datareader = pytest.importorskip('pandas-datareader') # noqa
91+
pandas_datareader = import_module('pandas_datareader') # noqa
7092
pandas_datareader.get_data_yahoo('AAPL')
7193

7294

7395
def test_geopandas():
7496

75-
geopandas = pytest.importorskip('geopandas') # noqa
97+
geopandas = import_module('geopandas') # noqa
7698
fp = geopandas.datasets.get_path('naturalearth_lowres')
7799
assert geopandas.read_file(fp) is not None
78100

79101

80102
def test_pyarrow(df):
81103

82-
pyarrow = pytest.importorskip('pyarrow') # noqa
104+
pyarrow = import_module('pyarrow') # noqa
83105
table = pyarrow.Table.from_pandas(df)
84106
result = table.to_pandas()
85107
tm.assert_frame_equal(result, df)

scripts/build_dist.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ read -p "Ok to continue (y/n)? " answer
1010
case ${answer:0:1} in
1111
y|Y )
1212
echo "Building distribution"
13-
rm -rf dist
14-
git clean -xfd
15-
python setup.py clean
16-
python setup.py cython
17-
python setup.py sdist --formats=gztar
13+
./build_dist_for_release.sh
1814
;;
1915
* )
2016
echo "Not building distribution"

ci/install_release_build.sh scripts/build_dist_for_release.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# this requires cython to be installed
44

5-
# this builds the release cleanly
5+
# this builds the release cleanly & is building on the current checkout
66
rm -rf dist
77
git clean -xfd
88
python setup.py clean

0 commit comments

Comments
 (0)