Skip to content

TST: Skip db tests unless explicitly specified in -m pattern #24492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ matrix:
include:
- dist: trusty
env:
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="not slow and not network and not db"
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="not slow and not network"

- dist: trusty
env:
- JOB="2.7" ENV_FILE="ci/deps/travis-27.yaml" PATTERN="not slow"
- JOB="2.7" ENV_FILE="ci/deps/travis-27.yaml" PATTERN="not slow and db"
addons:
apt:
packages:
- python-gtk2

- dist: trusty
env:
- JOB="3.6, locale" ENV_FILE="ci/deps/travis-36-locale.yaml" PATTERN="not slow and not network" LOCALE_OVERRIDE="zh_CN.UTF-8"
- 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"

- dist: trusty
env:
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36.yaml" PATTERN="not slow and not network" PANDAS_TESTING_MODE="deprecate" COVERAGE=true
- 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

# In allow_failures
- dist: trusty
Expand Down
12 changes: 6 additions & 6 deletions ci/azure/posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ jobs:
py35_np_120:
ENV_FILE: ci/deps/azure-macos-35.yaml
CONDA_PY: "35"
PATTERN: "not slow and not network and not db"
PATTERN: "not slow and not network"

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

py27_locale_slow_old_np:
ENV_FILE: ci/deps/azure-27-locale.yaml
CONDA_PY: "27"
PATTERN: "slow and not db"
PATTERN: "slow"
LOCALE_OVERRIDE: "zh_CN.UTF-8"
EXTRA_APT: "language-pack-zh-hans"

py36_locale_slow:
ENV_FILE: ci/deps/azure-36-locale_slow.yaml
CONDA_PY: "36"
PATTERN: "not slow and not network and not db"
PATTERN: "not slow and not network"
LOCALE_OVERRIDE: "it_IT.UTF-8"

py37_locale:
ENV_FILE: ci/deps/azure-37-locale.yaml
CONDA_PY: "37"
PATTERN: "not slow and not network and not db"
PATTERN: "not slow and not network"
LOCALE_OVERRIDE: "zh_CN.UTF-8"

py37_np_dev:
ENV_FILE: ci/deps/azure-37-numpydev.yaml
CONDA_PY: "37"
PATTERN: "not slow and not network and not db"
PATTERN: "not slow and not network"
TEST_ARGS: "-W error"
PANDAS_TESTING_MODE: "deprecate"
EXTRA_APT: "xsel"
Expand Down
2 changes: 1 addition & 1 deletion ci/azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
displayName: 'Build'
- script: |
call activate pandas-dev
pytest -m "not slow and not network and not db" --junitxml=test-data.xml pandas -n 2 -r sxX --strict --durations=10 %*
pytest -m "not slow and not network" --junitxml=test-data.xml pandas -n 2 -r sxX --strict --durations=10 %*
displayName: 'Test'
- task: PublishTestResults@2
inputs:
Expand Down
15 changes: 12 additions & 3 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import collections
from datetime import date, time, timedelta
from decimal import Decimal
import importlib
Expand Down Expand Up @@ -54,14 +55,22 @@ def pytest_runtest_setup(item):
if 'network' in item.keywords and item.config.getoption("--skip-network"):
pytest.skip("skipping due to --skip-network")

if 'db' in item.keywords and item.config.getoption("--skip-db"):
pytest.skip("skipping due to --skip-db")

if 'high_memory' in item.keywords and not item.config.getoption(
"--run-high-memory"):
pytest.skip(
"skipping high memory test since --run-high-memory was not set")

# if "db" not explicitly set in the -m pattern, we skip the db tests
if 'db' in item.keywords:
pattern = item.config.getoption('-m')
markers = collections.defaultdict(bool)
for marker in item.iter_markers():
markers[marker.name] = True
markers['db'] = False
db_in_pattern = not eval(pattern, {}, markers)
if not db_in_pattern:
pytest.skip('skipping db unless -m "db" is specified')


# Configurations for all tests and all test modules

Expand Down
2 changes: 1 addition & 1 deletion pandas/util/_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test(extra_args=None):
import hypothesis # noqa
except ImportError:
raise ImportError("Need hypothesis>=3.58 to run tests")
cmd = ['--skip-slow', '--skip-network', '--skip-db']
cmd = ['--skip-slow', '--skip-network']
if extra_args:
if not isinstance(extra_args, list):
extra_args = [extra_args]
Expand Down