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 3 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
11 changes: 11 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pytest
from pytz import FixedOffset, utc

from pandas.compat._optional import import_optional_dependency
import pandas.util._test_decorators as td

import pandas as pd
Expand Down Expand Up @@ -930,3 +931,13 @@ def __len__(self):
return self._data.__len__()

return TestNonDictMapping


def async_mark():
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
6 changes: 4 additions & 2 deletions pandas/tests/arrays/categorical/test_warnings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import pytest

import pandas._testing as tm
from pandas.conftest import async_mark


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 @@ -10,6 +10,7 @@
import pandas as pd
from pandas import Categorical, DataFrame, Series, compat, date_range, timedelta_range
import pandas._testing as tm
from pandas.conftest import async_mark


class TestDataFrameMisc:
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 @@ -33,6 +33,7 @@
period_range,
)
import pandas._testing as tm
from pandas.conftest import async_mark
from pandas.core.algorithms import safe_sort
from pandas.core.indexes.api import (
Index,
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
6 changes: 4 additions & 2 deletions pandas/tests/series/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
timedelta_range,
)
import pandas._testing as tm
from pandas.conftest import async_mark
from pandas.core.arrays import PeriodArray

import pandas.io.formats.printing as printing
Expand Down Expand Up @@ -491,13 +492,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
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