##// END OF EJS Templates
test_completer tests resurrection...
Nikita Kniazev -
Show More
@@ -34,7 +34,7 b' jobs:'
34 python -m pip install --upgrade pip setuptools wheel
34 python -m pip install --upgrade pip setuptools wheel
35 python -m pip install --upgrade -e file://$PWD#egg=ipython[test]
35 python -m pip install --upgrade -e file://$PWD#egg=ipython[test]
36 python -m pip install --upgrade --upgrade-strategy eager trio curio
36 python -m pip install --upgrade --upgrade-strategy eager trio curio
37 python -m pip install --upgrade pytest pytest-cov pytest-trio 'matplotlib!=3.2.0'
37 python -m pip install --upgrade pytest pytest-cov pytest-trio 'matplotlib!=3.2.0' pandas
38 python -m pip install --upgrade check-manifest pytest-cov anyio
38 python -m pip install --upgrade check-manifest pytest-cov anyio
39 - name: Check manifest
39 - name: Check manifest
40 run: check-manifest
40 run: check-manifest
@@ -328,20 +328,18 b' class TestCompleter(unittest.TestCase):'
328 name, matches = ip.complete("\\" + letter)
328 name, matches = ip.complete("\\" + letter)
329 self.assertEqual(matches, [])
329 self.assertEqual(matches, [])
330
330
331 class CompletionSplitterTestCase(unittest.TestCase):
332 def setUp(self):
333 self.sp = completer.CompletionSplitter()
334
335 def test_delim_setting(self):
331 def test_delim_setting(self):
336 self.sp.delims = " "
332 sp = completer.CompletionSplitter()
337 self.assertEqual(self.sp.delims, " ")
333 sp.delims = " "
338 self.assertEqual(self.sp._delim_expr, r"[\ ]")
334 self.assertEqual(sp.delims, " ")
335 self.assertEqual(sp._delim_expr, r"[\ ]")
339
336
340 def test_spaces(self):
337 def test_spaces(self):
341 """Test with only spaces as split chars."""
338 """Test with only spaces as split chars."""
342 self.sp.delims = " "
339 sp = completer.CompletionSplitter()
340 sp.delims = " "
343 t = [("foo", "", "foo"), ("run foo", "", "foo"), ("run foo", "bar", "foo")]
341 t = [("foo", "", "foo"), ("run foo", "", "foo"), ("run foo", "bar", "foo")]
344 check_line_split(self.sp, t)
342 check_line_split(sp, t)
345
343
346 def test_has_open_quotes1(self):
344 def test_has_open_quotes1(self):
347 for s in ["'", "'''", "'hi' '"]:
345 for s in ["'", "'''", "'hi' '"]:
@@ -462,7 +460,7 b' class TestCompleter(unittest.TestCase):'
462 ip.Completer.use_jedi = True
460 ip.Completer.use_jedi = True
463 completions = set(ip.Completer.completions(s, l))
461 completions = set(ip.Completer.completions(s, l))
464 ip.Completer.use_jedi = False
462 ip.Completer.use_jedi = False
465 assert_in(Completion(start, end, comp), completions, reason)
463 assert Completion(start, end, comp) in completions, reason
466
464
467 def _test_not_complete(reason, s, comp):
465 def _test_not_complete(reason, s, comp):
468 l = len(s)
466 l = len(s)
@@ -470,18 +468,18 b' class TestCompleter(unittest.TestCase):'
470 ip.Completer.use_jedi = True
468 ip.Completer.use_jedi = True
471 completions = set(ip.Completer.completions(s, l))
469 completions = set(ip.Completer.completions(s, l))
472 ip.Completer.use_jedi = False
470 ip.Completer.use_jedi = False
473 assert_not_in(Completion(l, l, comp), completions, reason)
471 assert Completion(l, l, comp) not in completions, reason
474
472
475 import jedi
473 import jedi
476
474
477 jedi_version = tuple(int(i) for i in jedi.__version__.split(".")[:3])
475 jedi_version = tuple(int(i) for i in jedi.__version__.split(".")[:3])
478 if jedi_version > (0, 10):
476 if jedi_version > (0, 10):
479 yield _test_complete, "jedi >0.9 should complete and not crash", "a=1;a.", "real"
477 _test_complete("jedi >0.9 should complete and not crash", "a=1;a.", "real")
480 yield _test_complete, "can infer first argument", 'a=(1,"foo");a[0].', "real"
478 _test_complete("can infer first argument", 'a=(1,"foo");a[0].', "real")
481 yield _test_complete, "can infer second argument", 'a=(1,"foo");a[1].', "capitalize"
479 _test_complete("can infer second argument", 'a=(1,"foo");a[1].', "capitalize")
482 yield _test_complete, "cover duplicate completions", "im", "import", 0, 2
480 _test_complete("cover duplicate completions", "im", "import", 0, 2)
483
481
484 yield _test_not_complete, "does not mix types", 'a=(1,"foo");a[0].', "capitalize"
482 _test_not_complete("does not mix types", 'a=(1,"foo");a[0].', "capitalize")
485
483
486 def test_completion_have_signature(self):
484 def test_completion_have_signature(self):
487 """
485 """
@@ -548,15 +546,27 b' class TestCompleter(unittest.TestCase):'
548 self.assertIn(completion, completions)
546 self.assertIn(completion, completions)
549
547
550 with provisionalcompleter():
548 with provisionalcompleter():
551 yield _, "a[0].", 5, "a[0].real", "Should have completed on a[0].: %s", Completion(
549 _(
552 5, 5, "real"
550 "a[0].",
551 5,
552 "a[0].real",
553 "Should have completed on a[0].: %s",
554 Completion(5, 5, "real"),
553 )
555 )
554 yield _, "a[0].r", 6, "a[0].real", "Should have completed on a[0].r: %s", Completion(
556 _(
555 5, 6, "real"
557 "a[0].r",
558 6,
559 "a[0].real",
560 "Should have completed on a[0].r: %s",
561 Completion(5, 6, "real"),
556 )
562 )
557
563
558 yield _, "a[0].from_", 10, "a[0].from_bytes", "Should have completed on a[0].from_: %s", Completion(
564 _(
559 5, 10, "from_bytes"
565 "a[0].from_",
566 10,
567 "a[0].from_bytes",
568 "Should have completed on a[0].from_: %s",
569 Completion(5, 10, "from_bytes"),
560 )
570 )
561
571
562 def test_omit__names(self):
572 def test_omit__names(self):
@@ -23,7 +23,7 b' init:'
23 install:
23 install:
24 - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
24 - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
25 - python -m pip install --upgrade setuptools pip
25 - python -m pip install --upgrade setuptools pip
26 - pip install nose coverage pytest pytest-cov pytest-trio pywin32 matplotlib
26 - pip install nose coverage pytest pytest-cov pytest-trio pywin32 matplotlib pandas
27 - pip install .[test]
27 - pip install .[test]
28 - mkdir results
28 - mkdir results
29 - cd results
29 - cd results
General Comments 0
You need to be logged in to leave comments. Login now