Skip to content

Commit 162c6f3

Browse files
datapythonistaPingviinituutti
authored andcommitted
TST: Skip db tests unless explicitly specified in -m pattern (pandas-dev#24492)
1 parent 164ee43 commit 162c6f3

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ matrix:
3434
include:
3535
- dist: trusty
3636
env:
37-
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="not slow and not network and not db"
37+
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="not slow and not network"
3838

3939
- dist: trusty
4040
env:
41-
- JOB="2.7" ENV_FILE="ci/deps/travis-27.yaml" PATTERN="not slow"
41+
- JOB="2.7" ENV_FILE="ci/deps/travis-27.yaml" PATTERN="not slow and db"
4242
addons:
4343
apt:
4444
packages:
4545
- python-gtk2
4646

4747
- dist: trusty
4848
env:
49-
- JOB="3.6, locale" ENV_FILE="ci/deps/travis-36-locale.yaml" PATTERN="not slow and not network" LOCALE_OVERRIDE="zh_CN.UTF-8"
49+
- JOB="3.6, locale" ENV_FILE="ci/deps/travis-36-locale.yaml" PATTERN="not slow and not network and db" LOCALE_OVERRIDE="zh_CN.UTF-8"
5050

5151
- dist: trusty
5252
env:
53-
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36.yaml" PATTERN="not slow and not network" PANDAS_TESTING_MODE="deprecate" COVERAGE=true
53+
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36.yaml" PATTERN="not slow and not network and db" PANDAS_TESTING_MODE="deprecate" COVERAGE=true
5454

5555
# In allow_failures
5656
- dist: trusty

ci/azure/posix.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@ jobs:
1212
py35_np_120:
1313
ENV_FILE: ci/deps/azure-macos-35.yaml
1414
CONDA_PY: "35"
15-
PATTERN: "not slow and not network and not db"
15+
PATTERN: "not slow and not network"
1616

1717
${{ if eq(parameters.name, 'Linux') }}:
1818
py27_np_120:
1919
ENV_FILE: ci/deps/azure-27-compat.yaml
2020
CONDA_PY: "27"
21-
PATTERN: "not slow and not network and not db"
21+
PATTERN: "not slow and not network"
2222

2323
py27_locale_slow_old_np:
2424
ENV_FILE: ci/deps/azure-27-locale.yaml
2525
CONDA_PY: "27"
26-
PATTERN: "slow and not db"
26+
PATTERN: "slow"
2727
LOCALE_OVERRIDE: "zh_CN.UTF-8"
2828
EXTRA_APT: "language-pack-zh-hans"
2929

3030
py36_locale_slow:
3131
ENV_FILE: ci/deps/azure-36-locale_slow.yaml
3232
CONDA_PY: "36"
33-
PATTERN: "not slow and not network and not db"
33+
PATTERN: "not slow and not network"
3434
LOCALE_OVERRIDE: "it_IT.UTF-8"
3535

3636
py37_locale:
3737
ENV_FILE: ci/deps/azure-37-locale.yaml
3838
CONDA_PY: "37"
39-
PATTERN: "not slow and not network and not db"
39+
PATTERN: "not slow and not network"
4040
LOCALE_OVERRIDE: "zh_CN.UTF-8"
4141

4242
py37_np_dev:
4343
ENV_FILE: ci/deps/azure-37-numpydev.yaml
4444
CONDA_PY: "37"
45-
PATTERN: "not slow and not network and not db"
45+
PATTERN: "not slow and not network"
4646
TEST_ARGS: "-W error"
4747
PANDAS_TESTING_MODE: "deprecate"
4848
EXTRA_APT: "xsel"

ci/azure/windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
displayName: 'Build'
3939
- script: |
4040
call activate pandas-dev
41-
pytest -m "not slow and not network and not db" --junitxml=test-data.xml pandas -n 2 -r sxX --strict --durations=10 %*
41+
pytest -m "not slow and not network" --junitxml=test-data.xml pandas -n 2 -r sxX --strict --durations=10 %*
4242
displayName: 'Test'
4343
- task: PublishTestResults@2
4444
inputs:

pandas/conftest.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import collections
12
from datetime import date, time, timedelta
23
from decimal import Decimal
34
import importlib
@@ -54,14 +55,22 @@ def pytest_runtest_setup(item):
5455
if 'network' in item.keywords and item.config.getoption("--skip-network"):
5556
pytest.skip("skipping due to --skip-network")
5657

57-
if 'db' in item.keywords and item.config.getoption("--skip-db"):
58-
pytest.skip("skipping due to --skip-db")
59-
6058
if 'high_memory' in item.keywords and not item.config.getoption(
6159
"--run-high-memory"):
6260
pytest.skip(
6361
"skipping high memory test since --run-high-memory was not set")
6462

63+
# if "db" not explicitly set in the -m pattern, we skip the db tests
64+
if 'db' in item.keywords:
65+
pattern = item.config.getoption('-m')
66+
markers = collections.defaultdict(bool)
67+
for marker in item.iter_markers():
68+
markers[marker.name] = True
69+
markers['db'] = False
70+
db_in_pattern = not eval(pattern, {}, markers)
71+
if not db_in_pattern:
72+
pytest.skip('skipping db unless -m "db" is specified')
73+
6574

6675
# Configurations for all tests and all test modules
6776

pandas/util/_tester.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test(extra_args=None):
1616
import hypothesis # noqa
1717
except ImportError:
1818
raise ImportError("Need hypothesis>=3.58 to run tests")
19-
cmd = ['--skip-slow', '--skip-network', '--skip-db']
19+
cmd = ['--skip-slow', '--skip-network']
2020
if extra_args:
2121
if not isinstance(extra_args, list):
2222
extra_args = [extra_args]

0 commit comments

Comments
 (0)