Skip to content

Commit db68195

Browse files
committed
TST: use xdist for multiple cpu testing
1 parent 43039e4 commit db68195

File tree

8 files changed

+62
-16
lines changed

8 files changed

+62
-16
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ before_script:
320320
script:
321321
- echo "script start"
322322
- ci/run_build_docs.sh
323-
- ci/script.sh
323+
- ci/script_single.sh
324+
- ci/script_multi.sh
324325
- ci/lint.sh
325326
- echo "script done"
326327

ci/script_multi.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
echo "[script multi]"
4+
5+
source activate pandas
6+
7+
# don't run the tests for the doc build
8+
if [ x"$DOC_BUILD" != x"" ]; then
9+
exit 0
10+
fi
11+
12+
if [ -n "$LOCALE_OVERRIDE" ]; then
13+
export LC_ALL="$LOCALE_OVERRIDE";
14+
echo "Setting LC_ALL to $LOCALE_OVERRIDE"
15+
16+
pycmd='import pandas; print("pandas detected console encoding: %s" % pandas.get_option("display.encoding"))'
17+
python -c "$pycmd"
18+
fi
19+
20+
if [ "$BUILD_TEST" ]; then
21+
echo "We are not running pytest as this is simply a build test."
22+
elif [ "$COVERAGE" ]; then
23+
echo pytest -s -n 2 -m "not single" --cov=pandas --cov-append --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
24+
pytest -s -n 2 -m "not single" --cov=pandas --cov-append --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
25+
else
26+
echo pytest -n 2 -m "not single" $TEST_ARGS pandas
27+
pytest -n 2 -m "not single" $TEST_ARGS pandas # TODO: doctest
28+
fi
29+
30+
RET="$?"
31+
32+
exit "$RET"

ci/script.sh renamed to ci/script_single.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
echo "inside $0"
3+
echo "[script_single]"
44

55
source activate pandas
66

@@ -20,11 +20,11 @@ fi
2020
if [ "$BUILD_TEST" ]; then
2121
echo "We are not running pytest as this is simply a build test."
2222
elif [ "$COVERAGE" ]; then
23-
echo pytest -s --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
24-
pytest -s --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
23+
echo pytest -s -m "single" --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
24+
pytest -s -m "single" --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
2525
else
26-
echo pytest $TEST_ARGS pandas
27-
pytest $TEST_ARGS pandas # TODO: doctest
26+
echo pytest -m "single" $TEST_ARGS pandas
27+
pytest -m "single" $TEST_ARGS pandas # TODO: doctest
2828
fi
2929

3030
RET="$?"

pandas/tests/io/test_clipboard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
_DEPS_INSTALLED = 0
2121

2222

23+
@pytest.mark.single
2324
@pytest.mark.skipif(not _DEPS_INSTALLED,
2425
reason="clipboard primitives not installed")
2526
class TestClipboard(tm.TestCase):

pandas/tests/io/test_pytables.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@
3636
from pandas import concat, Timestamp
3737
from pandas import compat
3838
from pandas.compat import range, lrange, u
39-
40-
try:
41-
import tables
42-
except ImportError:
43-
pytest.skip('no pytables')
44-
4539
from distutils.version import LooseVersion
4640

4741
_default_compressor = ('blosc' if LooseVersion(tables.__version__) >= '2.2'
@@ -165,6 +159,7 @@ def tearDown(self):
165159
pass
166160

167161

162+
@pytest.mark.single
168163
class TestHDFStore(Base, tm.TestCase):
169164

170165
def test_factory_fun(self):
@@ -5086,6 +5081,7 @@ def test_query_long_float_literal(self):
50865081
tm.assert_frame_equal(expected, result)
50875082

50885083

5084+
@pytest.mark.single
50895085
class TestHDFComplexValues(Base):
50905086
# GH10447
50915087

@@ -5231,6 +5227,7 @@ def test_complex_append(self):
52315227
assert_frame_equal(pd.concat([df, df], 0), result)
52325228

52335229

5230+
@pytest.mark.single
52345231
class TestTimezones(Base, tm.TestCase):
52355232

52365233
def _compare_with_tz(self, a, b):

pandas/tests/io/test_sql.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919

2020
from __future__ import print_function
21+
import pytest
2122
import unittest
2223
import sqlite3
2324
import csv
@@ -839,6 +840,7 @@ def test_unicode_column_name(self):
839840
df.to_sql('test_unicode', self.conn, index=False)
840841

841842

843+
@pytest.mark.single
842844
class TestSQLApi(SQLAlchemyMixIn, _TestSQLApi, unittest.TestCase):
843845
"""
844846
Test the public API as it would be used directly
@@ -1024,10 +1026,12 @@ def tearDown(self):
10241026
super(_EngineToConnMixin, self).tearDown()
10251027

10261028

1029+
@pytest.mark.single
10271030
class TestSQLApiConn(_EngineToConnMixin, TestSQLApi, unittest.TestCase):
10281031
pass
10291032

10301033

1034+
@pytest.mark.single
10311035
class TestSQLiteFallbackApi(SQLiteMixIn, _TestSQLApi, unittest.TestCase):
10321036
"""
10331037
Test the public sqlite connection fallback API
@@ -1875,30 +1879,36 @@ def test_schema_support(self):
18751879
tm.assert_frame_equal(res1, res2)
18761880

18771881

1882+
@pytest.mark.single
18781883
class TestMySQLAlchemy(_TestMySQLAlchemy, _TestSQLAlchemy, unittest.TestCase):
18791884
pass
18801885

18811886

1887+
@pytest.mark.single
18821888
class TestMySQLAlchemyConn(_TestMySQLAlchemy, _TestSQLAlchemyConn,
18831889
unittest.TestCase):
18841890
pass
18851891

18861892

1893+
@pytest.mark.single
18871894
class TestPostgreSQLAlchemy(_TestPostgreSQLAlchemy, _TestSQLAlchemy,
18881895
unittest.TestCase):
18891896
pass
18901897

18911898

1899+
@pytest.mark.single
18921900
class TestPostgreSQLAlchemyConn(_TestPostgreSQLAlchemy, _TestSQLAlchemyConn,
18931901
unittest.TestCase):
18941902
pass
18951903

18961904

1905+
@pytest.mark.single
18971906
class TestSQLiteAlchemy(_TestSQLiteAlchemy, _TestSQLAlchemy,
18981907
unittest.TestCase):
18991908
pass
19001909

19011910

1911+
@pytest.mark.single
19021912
class TestSQLiteAlchemyConn(_TestSQLiteAlchemy, _TestSQLAlchemyConn,
19031913
unittest.TestCase):
19041914
pass
@@ -1907,6 +1917,7 @@ class TestSQLiteAlchemyConn(_TestSQLiteAlchemy, _TestSQLAlchemyConn,
19071917
# -----------------------------------------------------------------------------
19081918
# -- Test Sqlite / MySQL fallback
19091919

1920+
@pytest.mark.single
19101921
class TestSQLiteFallback(SQLiteMixIn, PandasSQLTest, unittest.TestCase):
19111922
"""
19121923
Test the fallback mode against an in-memory sqlite database.
@@ -2133,6 +2144,7 @@ def _skip_if_no_pymysql():
21332144
pytest.skip('pymysql not installed, skipping')
21342145

21352146

2147+
@pytest.mark.single
21362148
class TestXSQLite(SQLiteMixIn, tm.TestCase):
21372149

21382150
def setUp(self):
@@ -2343,6 +2355,7 @@ def clean_up(test_table_to_drop):
23432355
clean_up(table_name)
23442356

23452357

2358+
@pytest.mark.single
23462359
class TestSQLFlavorDeprecation(tm.TestCase):
23472360
"""
23482361
gh-13611: test that the 'flavor' parameter
@@ -2367,8 +2380,9 @@ def test_deprecated_flavor(self):
23672380
getattr(sql, func)(self.con, flavor='sqlite')
23682381

23692382

2370-
@unittest.skip("gh-13611: there is no support for MySQL "
2371-
"if SQLAlchemy is not installed")
2383+
@pytest.mark.single
2384+
@pytest.mark.skip(reason="gh-13611: there is no support for MySQL "
2385+
"if SQLAlchemy is not installed")
23722386
class TestXMySQL(MySQLMixIn, tm.TestCase):
23732387

23742388
@classmethod

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ split_penalty_logical_operator = 30
2525
# Silencing the warning until then
2626
addopts = --disable-pytest-warnings
2727
testpaths = pandas
28+
markers =
29+
single: mark a test as single cpu only

test_fast.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# nosetests -A "not slow and not network" pandas --with-id $*
2-
pytest pandas --skip-slow
1+
pytest pandas --skip-slow --skip-network -m "not single" -n 4

0 commit comments

Comments
 (0)