Skip to content

Commit 986675e

Browse files
committed
TST: Add conftest
TST: Ignore conftest Use pytest slow marker update conftest
1 parent e36d722 commit 986675e

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

pandas/api/tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestPDApi(Base, tm.TestCase):
2828

2929
# these are optionally imported based on testing
3030
# & need to be ignored
31-
ignored = ['tests', 'rpy', 'locale']
31+
ignored = ['tests', 'rpy', 'locale', 'conftest']
3232

3333
# top-level sub-packages
3434
lib = ['api', 'compat', 'computation', 'core',

pandas/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
3+
4+
def pytest_addoption(parser):
5+
parser.addoption("--skip-slow", action="store_true",
6+
help="skip slow tests")
7+
parser.addoption("--no-skip-disabled", action="store_false",
8+
help="run disabled tests")
9+
parser.addoption("--skip-network", action="store_true",
10+
help="skip networked tests")
11+
12+
13+
def pytest_runtest_setup(item):
14+
if 'slow' in item.keywords and item.config.getoption("--skip-slow"):
15+
pytest.skip("need --skip-slow=False option to run")
16+
if 'disabled' in item.keywords and item.config.getoption("--no-skip-disabled"):
17+
pytest.skip("need --no-skip-disabled option to run")
18+
if 'network' in item.keywords and item.config.getoption("--skip-network"):
19+
pytest.skip("need --skip-network=False option to run")

pandas/util/testing.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
import unittest
1414
import traceback
1515

16+
import pytest
1617
from datetime import datetime
1718
from functools import wraps, partial
1819
from contextlib import contextmanager
1920
from distutils.version import LooseVersion
2021

2122
from numpy.random import randn, rand
22-
from numpy.testing.decorators import slow # noqa
23+
# from numpy.testing.decorators import slow # noqa
2324
import numpy as np
2425

2526
import pandas as pd
@@ -35,7 +36,7 @@
3536
from pandas.core.algorithms import take_1d
3637

3738
import pandas.compat as compat
38-
from pandas.compat import(
39+
from pandas.compat import (
3940
filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter,
4041
raise_with_traceback, httplib, is_platform_windows, is_platform_32bit,
4142
PY3
@@ -50,6 +51,7 @@
5051
from pandas import _testing
5152
from pandas.io.common import urlopen
5253

54+
slow = pytest.mark.slow
5355
N = 30
5456
K = 4
5557
_RAISE_NETWORK_ERROR_DEFAULT = False
@@ -2248,7 +2250,8 @@ def network(t, url="http://www.google.com",
22482250
Errors not related to networking will always be raised.
22492251
"""
22502252
from nose import SkipTest
2251-
t.network = True
2253+
# pre-pytest we set t.network=bool, trying to reuse this decorator
2254+
t = pytest.mark.network(t)
22522255

22532256
@wraps(t)
22542257
def wrapper(*args, **kwargs):
@@ -2538,9 +2541,7 @@ def assert_produces_warning(expected_warning=Warning, filter_level="always",
25382541
% extra_warnings)
25392542

25402543

2541-
def disabled(t):
2542-
t.disabled = True
2543-
return t
2544+
disabled = pytest.mark.disabled
25442545

25452546

25462547
class RNGContext(object):

0 commit comments

Comments
 (0)