Skip to content
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

Warnings from IPython tab completion tests #29070

Closed
TomAugspurger opened this issue Oct 18, 2019 · 1 comment · Fixed by #30689
Closed

Warnings from IPython tab completion tests #29070

TomAugspurger opened this issue Oct 18, 2019 · 1 comment · Fixed by #30689
Labels
Testing pandas testing functions or related to the test suite
Milestone

Comments

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Oct 18, 2019

At some point, IPython changed their code to be async. Now, our tests using their tab completion stuff causes warnings.

$ pytest pandas/tests/ -k test_tab_complete_warning 

================================================================================= warnings summary =================================================================================
pandas/tests/arrays/categorical/test_warnings.py::TestCategoricalWarnings::test_tab_complete_warning
  /Users/taugspurger/sandbox/pandas/pandas/tests/arrays/categorical/test_warnings.py:14: RuntimeWarning: coroutine 'InteractiveShell.run_code' was never awaited
    ip.run_code(code)

pandas/tests/frame/test_api.py::TestDataFrameMisc::test_tab_complete_warning
  /Users/taugspurger/sandbox/pandas/pandas/tests/frame/test_api.py:575: RuntimeWarning: coroutine 'InteractiveShell.run_code' was never awaited
    ip.run_code(code)

pandas/tests/indexes/test_base.py::TestIndex::test_tab_complete_warning
  /Users/taugspurger/sandbox/pandas/pandas/tests/indexes/test_base.py:2420: RuntimeWarning: coroutine 'InteractiveShell.run_code' was never awaited
    ip.run_code(code)

pandas/tests/series/test_api.py::TestSeriesMisc::test_tab_complete_warning
  /Users/taugspurger/sandbox/pandas/pandas/tests/series/test_api.py:508: RuntimeWarning: coroutine 'InteractiveShell.run_code' was never awaited
    ip.run_code(code)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================================== 4 passed, 11 skipped, 62860 deselected, 4 warnings in 29.50s ===========================================================

There's a race condition between the completion of the ip.run_code(code) calls and the asserts later on. We need to explicitly wait for the ip.run_code(code) to finish before moving on with the test. The easiest way is to

  1. Mark the tests as async with the 3rd-party pytest-asyncio (need to add to the CI)
  2. Rewrite the tests to use async def.
  3. Add an await to the ip.run_code
diff --git a/pandas/tests/series/test_api.py b/pandas/tests/series/test_api.py
index 998f8b6f7d..b471e1dc1e 100644
--- a/pandas/tests/series/test_api.py
+++ b/pandas/tests/series/test_api.py
@@ -499,13 +499,15 @@ class TestSeriesMisc(TestData, SharedWithSparse):
         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))

This is currently blocked by #29034. Once we drop 3.5, we can use the async and await syntax. I forgot 3.5 had async / await.

@TomAugspurger TomAugspurger added the Testing pandas testing functions or related to the test suite label Oct 18, 2019
@TomAugspurger TomAugspurger changed the title IPython tab completion warnings. Warnings from IPython tab completion tests Oct 18, 2019
@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Oct 18, 2019
@gabriellm1
Copy link
Contributor

Not totally certain if I can solved, but since I used asyncio in an another project not so long ago I'm confident I can help with a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
4 participants