Skip to content

Commit 70ae817

Browse files
TomAugspurgerjreback
authored andcommitted
REF: Refactor pandas.util.testing to not use pytest at top-level (#16088)
Closes #16088
1 parent 2f9c854 commit 70ae817

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

pandas/tests/io/parser/test_network.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def salaries_table():
2222
@pytest.mark.parametrize(
2323
"compression,extension",
2424
[('gzip', '.gz'), ('bz2', '.bz2'), ('zip', '.zip'),
25-
tm._mark_skipif_no_lzma(('xz', '.xz'))])
25+
pytest.mark.skipif(not tm._check_if_lzma(),
26+
reason='need backports.lzma to run')(('xz', '.xz'))])
2627
@pytest.mark.parametrize('mode', ['explicit', 'infer'])
2728
@pytest.mark.parametrize('engine', ['python', 'c'])
2829
def test_compressed_urls(salaries_table, compression, extension, mode, engine):

pandas/util/testing.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from distutils.version import LooseVersion
2020

2121
from numpy.random import randn, rand
22-
import pytest
2322
import numpy as np
2423

2524
import pandas as pd
@@ -52,7 +51,13 @@
5251

5352
from pandas.util import libtesting
5453
from pandas.io.common import urlopen
55-
slow = pytest.mark.slow
54+
try:
55+
import pytest
56+
slow = pytest.mark.slow
57+
except ImportError:
58+
# Should be ok to just ignore. If you actually need
59+
# slow then you'll hit an import error long before getting here.
60+
pass
5661

5762

5863
N = 30
@@ -347,15 +352,10 @@ def _check_if_lzma():
347352

348353

349354
def _skip_if_no_lzma():
355+
import pytest
350356
return _check_if_lzma() or pytest.skip('need backports.lzma to run')
351357

352358

353-
_mark_skipif_no_lzma = pytest.mark.skipif(
354-
not _check_if_lzma(),
355-
reason='need backports.lzma to run'
356-
)
357-
358-
359359
def _skip_if_no_xarray():
360360
try:
361361
import xarray

0 commit comments

Comments
 (0)