Skip to content

Correcting Warnings from IPython tab completion tests with async tests #29087

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

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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 doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ Other
- Bug in :meth:`Series.diff` where a boolean series would incorrectly raise a ``TypeError`` (:issue:`17294`)
- :meth:`Series.append` will no longer raise a ``TypeError`` when passed a tuple of ``Series`` (:issue:`28410`)
- Fix corrupted error message when calling ``pandas.libs._json.encode()`` on a 0d array (:issue:`18878`)
- Making tests async to skip IPython warnings (:issue:`29070`)

.. _whatsnew_1000.contributors:

Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/arrays/categorical/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@


class TestCategoricalWarnings:
def test_tab_complete_warning(self, ip):
@pytest.mark.asyncio
Copy link
Member

Choose a reason for hiding this comment

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

is asyncio a mark that pytest should always know about? it looks like the CI is failing because this mark isnt recognized. You may need to define it in conftest.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't added the asyncio to the CI files yet, I was waiting for a Tom to explain to me. Once I add to the files, the CI will probably pass.

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))
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,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):
@pytest.mark.asyncio
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))
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2413,13 +2413,14 @@ def test_get_duplicates_deprecated(self):
with tm.assert_produces_warning(FutureWarning):
index.get_duplicates()

def test_tab_complete_warning(self, ip):
@pytest.mark.asyncio
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
5 changes: 3 additions & 2 deletions pandas/tests/series/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,14 @@ def test_empty_method(self):
for full_series in [pd.Series([1]), pd.Series(index=[1])]:
assert not full_series.empty

def test_tab_complete_warning(self, ip):
@pytest.mark.asyncio
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