Skip to content

Commit f9e524c

Browse files
alimcmaster1jreback
authored andcommitted
CI: Fix IPython Tab Completion test async warning (#30689)
1 parent be1a62d commit f9e524c

File tree

10 files changed

+38
-10
lines changed

10 files changed

+38
-10
lines changed

ci/deps/azure-36-locale.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies:
99
- cython>=0.29.13
1010
- pytest>=5.0.1
1111
- pytest-xdist>=1.21
12+
- pytest-asyncio
1213
- hypothesis>=3.58.0
1314
- pytest-azurepipelines
1415

ci/deps/azure-37-locale.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies:
88
- cython>=0.29.13
99
- pytest>=5.0.1
1010
- pytest-xdist>=1.21
11+
- pytest-asyncio
1112
- hypothesis>=3.58.0
1213
- pytest-azurepipelines
1314

environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ dependencies:
5555
- pytest>=5.0.1
5656
- pytest-cov
5757
- pytest-xdist>=1.21
58+
- pytest-asyncio
5859

5960
# downstream tests
6061
- seaborn
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import pytest
22

3+
from pandas.util._test_decorators import async_mark
4+
35
import pandas._testing as tm
46

57

68
class TestCategoricalWarnings:
7-
def test_tab_complete_warning(self, ip):
9+
@async_mark()
10+
async def test_tab_complete_warning(self, ip):
811
# https://github.com/pandas-dev/pandas/issues/16409
912
pytest.importorskip("IPython", minversion="6.0.0")
1013
from IPython.core.completer import provisionalcompleter
1114

1215
code = "import pandas as pd; c = Categorical([])"
13-
ip.run_code(code)
16+
await ip.run_code(code)
1417
with tm.assert_produces_warning(None):
1518
with provisionalcompleter("ignore"):
1619
list(ip.Completer.completions("c.", 1))

pandas/tests/frame/test_api.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77

88
from pandas.compat import PY37
9+
from pandas.util._test_decorators import async_mark
910

1011
import pandas as pd
1112
from pandas import Categorical, DataFrame, Series, compat, date_range, timedelta_range
@@ -539,13 +540,14 @@ def _check_f(base, f):
539540
f = lambda x: x.rename({1: "foo"}, inplace=True)
540541
_check_f(d.copy(), f)
541542

542-
def test_tab_complete_warning(self, ip):
543+
@async_mark()
544+
async def test_tab_complete_warning(self, ip):
543545
# GH 16409
544546
pytest.importorskip("IPython", minversion="6.0.0")
545547
from IPython.core.completer import provisionalcompleter
546548

547549
code = "import pandas as pd; df = pd.DataFrame()"
548-
ip.run_code(code)
550+
await ip.run_code(code)
549551
with tm.assert_produces_warning(None):
550552
with provisionalcompleter("ignore"):
551553
list(ip.Completer.completions("df.", 1))

pandas/tests/indexes/test_base.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from pandas._libs.tslib import Timestamp
1414
from pandas.compat.numpy import np_datetime64_compat
15+
from pandas.util._test_decorators import async_mark
1516

1617
from pandas.core.dtypes.common import is_unsigned_integer_dtype
1718
from pandas.core.dtypes.generic import ABCIndex
@@ -2397,13 +2398,14 @@ def test_cached_properties_not_settable(self):
23972398
with pytest.raises(AttributeError, match="Can't set attribute"):
23982399
index.is_unique = False
23992400

2400-
def test_tab_complete_warning(self, ip):
2401+
@async_mark()
2402+
async def test_tab_complete_warning(self, ip):
24012403
# https://github.com/pandas-dev/pandas/issues/16409
24022404
pytest.importorskip("IPython", minversion="6.0.0")
24032405
from IPython.core.completer import provisionalcompleter
24042406

24052407
code = "import pandas as pd; idx = pd.Index([1, 2])"
2406-
ip.run_code(code)
2408+
await ip.run_code(code)
24072409
with tm.assert_produces_warning(None):
24082410
with provisionalcompleter("ignore"):
24092411
list(ip.Completer.completions("idx.", 4))

pandas/tests/resample/test_resampler_grouper.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import numpy as np
44

5+
from pandas.util._test_decorators import async_mark
6+
57
import pandas as pd
68
from pandas import DataFrame, Series, Timestamp
79
import pandas._testing as tm
@@ -13,7 +15,8 @@
1315
)
1416

1517

16-
def test_tab_complete_ipython6_warning(ip):
18+
@async_mark()
19+
async def test_tab_complete_ipython6_warning(ip):
1720
from IPython.core.completer import provisionalcompleter
1821

1922
code = dedent(
@@ -23,7 +26,7 @@ def test_tab_complete_ipython6_warning(ip):
2326
rs = s.resample("D")
2427
"""
2528
)
26-
ip.run_code(code)
29+
await ip.run_code(code)
2730

2831
with tm.assert_produces_warning(None):
2932
with provisionalcompleter("ignore"):

pandas/tests/series/test_api.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import numpy as np
66
import pytest
77

8+
from pandas.util._test_decorators import async_mark
9+
810
import pandas as pd
911
from pandas import (
1012
Categorical,
@@ -491,13 +493,14 @@ def test_empty_method(self):
491493
for full_series in [pd.Series([1]), s2]:
492494
assert not full_series.empty
493495

494-
def test_tab_complete_warning(self, ip):
496+
@async_mark()
497+
async def test_tab_complete_warning(self, ip):
495498
# https://github.com/pandas-dev/pandas/issues/16409
496499
pytest.importorskip("IPython", minversion="6.0.0")
497500
from IPython.core.completer import provisionalcompleter
498501

499502
code = "import pandas as pd; s = pd.Series()"
500-
ip.run_code(code)
503+
await ip.run_code(code)
501504
with tm.assert_produces_warning(None):
502505
with provisionalcompleter("ignore"):
503506
list(ip.Completer.completions("s.", 1))

pandas/util/_test_decorators.py

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def test_foo():
3232
import pytest
3333

3434
from pandas.compat import is_platform_32bit, is_platform_windows
35+
from pandas.compat._optional import import_optional_dependency
3536
from pandas.compat.numpy import _np_version
3637

3738
from pandas.core.computation.expressions import _NUMEXPR_INSTALLED, _USE_NUMEXPR
@@ -251,3 +252,13 @@ def new_func(*args, **kwargs):
251252
assert flist2 == flist
252253

253254
return new_func
255+
256+
257+
def async_mark():
258+
try:
259+
import_optional_dependency("pytest_asyncio")
260+
async_mark = pytest.mark.asyncio
261+
except ImportError:
262+
async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio")
263+
264+
return async_mark

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ moto
3636
pytest>=5.0.1
3737
pytest-cov
3838
pytest-xdist>=1.21
39+
pytest-asyncio
3940
seaborn
4041
statsmodels
4142
ipywidgets

0 commit comments

Comments
 (0)