From 92296e1c40367166d8b99b0d4e383920c5e02de9 2021-10-31 14:56:09 From: Nikita Kniazev Date: 2021-10-31 14:56:09 Subject: [PATCH] test_completer tests resurrection * Class in class tests never was a thing. * Generating methods seems to not work even in nose, they report no coverage. * Installed pandas in CI to run test_dataframe_key_completion --- diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8095b87..0704f37 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: python -m pip install --upgrade pip setuptools wheel python -m pip install --upgrade -e file://$PWD#egg=ipython[test] python -m pip install --upgrade --upgrade-strategy eager trio curio - python -m pip install --upgrade pytest pytest-cov pytest-trio 'matplotlib!=3.2.0' + python -m pip install --upgrade pytest pytest-cov pytest-trio 'matplotlib!=3.2.0' pandas python -m pip install --upgrade check-manifest pytest-cov anyio - name: Check manifest run: check-manifest diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py index 319bc2d..b39818d 100644 --- a/IPython/core/tests/test_completer.py +++ b/IPython/core/tests/test_completer.py @@ -328,20 +328,18 @@ class TestCompleter(unittest.TestCase): name, matches = ip.complete("\\" + letter) self.assertEqual(matches, []) - class CompletionSplitterTestCase(unittest.TestCase): - def setUp(self): - self.sp = completer.CompletionSplitter() - - def test_delim_setting(self): - self.sp.delims = " " - self.assertEqual(self.sp.delims, " ") - self.assertEqual(self.sp._delim_expr, r"[\ ]") - - def test_spaces(self): - """Test with only spaces as split chars.""" - self.sp.delims = " " - t = [("foo", "", "foo"), ("run foo", "", "foo"), ("run foo", "bar", "foo")] - check_line_split(self.sp, t) + def test_delim_setting(self): + sp = completer.CompletionSplitter() + sp.delims = " " + self.assertEqual(sp.delims, " ") + self.assertEqual(sp._delim_expr, r"[\ ]") + + def test_spaces(self): + """Test with only spaces as split chars.""" + sp = completer.CompletionSplitter() + sp.delims = " " + t = [("foo", "", "foo"), ("run foo", "", "foo"), ("run foo", "bar", "foo")] + check_line_split(sp, t) def test_has_open_quotes1(self): for s in ["'", "'''", "'hi' '"]: @@ -462,7 +460,7 @@ class TestCompleter(unittest.TestCase): ip.Completer.use_jedi = True completions = set(ip.Completer.completions(s, l)) ip.Completer.use_jedi = False - assert_in(Completion(start, end, comp), completions, reason) + assert Completion(start, end, comp) in completions, reason def _test_not_complete(reason, s, comp): l = len(s) @@ -470,18 +468,18 @@ class TestCompleter(unittest.TestCase): ip.Completer.use_jedi = True completions = set(ip.Completer.completions(s, l)) ip.Completer.use_jedi = False - assert_not_in(Completion(l, l, comp), completions, reason) + assert Completion(l, l, comp) not in completions, reason import jedi jedi_version = tuple(int(i) for i in jedi.__version__.split(".")[:3]) if jedi_version > (0, 10): - yield _test_complete, "jedi >0.9 should complete and not crash", "a=1;a.", "real" - yield _test_complete, "can infer first argument", 'a=(1,"foo");a[0].', "real" - yield _test_complete, "can infer second argument", 'a=(1,"foo");a[1].', "capitalize" - yield _test_complete, "cover duplicate completions", "im", "import", 0, 2 + _test_complete("jedi >0.9 should complete and not crash", "a=1;a.", "real") + _test_complete("can infer first argument", 'a=(1,"foo");a[0].', "real") + _test_complete("can infer second argument", 'a=(1,"foo");a[1].', "capitalize") + _test_complete("cover duplicate completions", "im", "import", 0, 2) - yield _test_not_complete, "does not mix types", 'a=(1,"foo");a[0].', "capitalize" + _test_not_complete("does not mix types", 'a=(1,"foo");a[0].', "capitalize") def test_completion_have_signature(self): """ @@ -548,15 +546,27 @@ class TestCompleter(unittest.TestCase): self.assertIn(completion, completions) with provisionalcompleter(): - yield _, "a[0].", 5, "a[0].real", "Should have completed on a[0].: %s", Completion( - 5, 5, "real" + _( + "a[0].", + 5, + "a[0].real", + "Should have completed on a[0].: %s", + Completion(5, 5, "real"), ) - yield _, "a[0].r", 6, "a[0].real", "Should have completed on a[0].r: %s", Completion( - 5, 6, "real" + _( + "a[0].r", + 6, + "a[0].real", + "Should have completed on a[0].r: %s", + Completion(5, 6, "real"), ) - yield _, "a[0].from_", 10, "a[0].from_bytes", "Should have completed on a[0].from_: %s", Completion( - 5, 10, "from_bytes" + _( + "a[0].from_", + 10, + "a[0].from_bytes", + "Should have completed on a[0].from_: %s", + Completion(5, 10, "from_bytes"), ) def test_omit__names(self): diff --git a/appveyor.yml b/appveyor.yml index 514da8e..031ba7f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,7 +23,7 @@ init: install: - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - python -m pip install --upgrade setuptools pip - - pip install nose coverage pytest pytest-cov pytest-trio pywin32 matplotlib + - pip install nose coverage pytest pytest-cov pytest-trio pywin32 matplotlib pandas - pip install .[test] - mkdir results - cd results