Skip to content

CI: Fix IPython Tab Completion test async warning #30689

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 9 commits into from
Jan 4, 2020
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
1 change: 1 addition & 0 deletions ci/deps/azure-36-locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- cython>=0.29.13
- pytest>=5.0.1
- pytest-xdist>=1.21
- pytest-asyncio
- hypothesis>=3.58.0
- pytest-azurepipelines

Expand Down
1 change: 1 addition & 0 deletions ci/deps/azure-37-locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- cython>=0.29.13
- pytest>=5.0.1
- pytest-xdist>=1.21
- pytest-asyncio
- hypothesis>=3.58.0
- pytest-azurepipelines

Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies:
- pytest>=5.0.1
- pytest-cov
- pytest-xdist>=1.21
- pytest-asyncio

# downstream tests
- seaborn
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/arrays/categorical/test_warnings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import pytest

from pandas.util._test_decorators import async_mark

import pandas._testing as tm


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

code = "import pandas as pd; c = Categorical([])"
ip.run_code(code)
await ip.run_code(code)
with tm.assert_produces_warning(None):
with provisionalcompleter("ignore"):
list(ip.Completer.completions("c.", 1))
6 changes: 4 additions & 2 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from pandas.compat import PY37
from pandas.util._test_decorators import async_mark

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

def test_tab_complete_warning(self, ip):
@async_mark()
async def test_tab_complete_warning(self, ip):
# GH 16409
pytest.importorskip("IPython", minversion="6.0.0")
from IPython.core.completer import provisionalcompleter

code = "import pandas as pd; df = pd.DataFrame()"
ip.run_code(code)
await ip.run_code(code)
with tm.assert_produces_warning(None):
with provisionalcompleter("ignore"):
list(ip.Completer.completions("df.", 1))
6 changes: 4 additions & 2 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from pandas._libs.tslib import Timestamp
from pandas.compat.numpy import np_datetime64_compat
from pandas.util._test_decorators import async_mark

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

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

code = "import pandas as pd; idx = pd.Index([1, 2])"
ip.run_code(code)
await ip.run_code(code)
with tm.assert_produces_warning(None):
with provisionalcompleter("ignore"):
list(ip.Completer.completions("idx.", 4))
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/resample/test_resampler_grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import numpy as np

from pandas.util._test_decorators import async_mark

import pandas as pd
from pandas import DataFrame, Series, Timestamp
import pandas._testing as tm
Expand All @@ -13,7 +15,8 @@
)


def test_tab_complete_ipython6_warning(ip):
@async_mark()
async def test_tab_complete_ipython6_warning(ip):
from IPython.core.completer import provisionalcompleter

code = dedent(
Expand All @@ -23,7 +26,7 @@ def test_tab_complete_ipython6_warning(ip):
rs = s.resample("D")
"""
)
ip.run_code(code)
await ip.run_code(code)

with tm.assert_produces_warning(None):
with provisionalcompleter("ignore"):
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/series/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import numpy as np
import pytest

from pandas.util._test_decorators import async_mark

import pandas as pd
from pandas import (
Categorical,
Expand Down Expand Up @@ -491,13 +493,14 @@ def test_empty_method(self):
for full_series in [pd.Series([1]), s2]:
assert not full_series.empty

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

code = "import pandas as pd; s = pd.Series()"
ip.run_code(code)
await ip.run_code(code)
with tm.assert_produces_warning(None):
with provisionalcompleter("ignore"):
list(ip.Completer.completions("s.", 1))
Expand Down
11 changes: 11 additions & 0 deletions pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_foo():
import pytest

from pandas.compat import is_platform_32bit, is_platform_windows
from pandas.compat._optional import import_optional_dependency
from pandas.compat.numpy import _np_version

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

return new_func


def async_mark():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a future PR can you type & add a doc-string

try:
import_optional_dependency("pytest_asyncio")
async_mark = pytest.mark.asyncio
except ImportError:
async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio")

return async_mark
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ moto
pytest>=5.0.1
pytest-cov
pytest-xdist>=1.21
pytest-asyncio
seaborn
statsmodels
ipywidgets
Expand Down