Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92296e1

Browse files
committed
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
1 parent f198d8a commit 92296e1

3 files changed

Lines changed: 39 additions & 29 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
python -m pip install --upgrade pip setuptools wheel
3535
python -m pip install --upgrade -e file://$PWD#egg=ipython[test]
3636
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
3838
python -m pip install --upgrade check-manifest pytest-cov anyio
3939
- name: Check manifest
4040
run: check-manifest

IPython/core/tests/test_completer.py

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -328,20 +328,18 @@ def test_no_ascii_back_completion(self):
328328
name, matches = ip.complete("\\" + letter)
329329
self.assertEqual(matches, [])
330330

331-
class CompletionSplitterTestCase(unittest.TestCase):
332-
def setUp(self):
333-
self.sp = completer.CompletionSplitter()
334-
335-
def test_delim_setting(self):
336-
self.sp.delims = " "
337-
self.assertEqual(self.sp.delims, " ")
338-
self.assertEqual(self.sp._delim_expr, r"[\ ]")
339-
340-
def test_spaces(self):
341-
"""Test with only spaces as split chars."""
342-
self.sp.delims = " "
343-
t = [("foo", "", "foo"), ("run foo", "", "foo"), ("run foo", "bar", "foo")]
344-
check_line_split(self.sp, t)
331+
def test_delim_setting(self):
332+
sp = completer.CompletionSplitter()
333+
sp.delims = " "
334+
self.assertEqual(sp.delims, " ")
335+
self.assertEqual(sp._delim_expr, r"[\ ]")
336+
337+
def test_spaces(self):
338+
"""Test with only spaces as split chars."""
339+
sp = completer.CompletionSplitter()
340+
sp.delims = " "
341+
t = [("foo", "", "foo"), ("run foo", "", "foo"), ("run foo", "bar", "foo")]
342+
check_line_split(sp, t)
345343

346344
def test_has_open_quotes1(self):
347345
for s in ["'", "'''", "'hi' '"]:
@@ -462,26 +460,26 @@ def _test_complete(reason, s, comp, start=None, end=None):
462460
ip.Completer.use_jedi = True
463461
completions = set(ip.Completer.completions(s, l))
464462
ip.Completer.use_jedi = False
465-
assert_in(Completion(start, end, comp), completions, reason)
463+
assert Completion(start, end, comp) in completions, reason
466464

467465
def _test_not_complete(reason, s, comp):
468466
l = len(s)
469467
with provisionalcompleter():
470468
ip.Completer.use_jedi = True
471469
completions = set(ip.Completer.completions(s, l))
472470
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
474472

475473
import jedi
476474

477475
jedi_version = tuple(int(i) for i in jedi.__version__.split(".")[:3])
478476
if jedi_version > (0, 10):
479-
yield _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"
481-
yield _test_complete, "can infer second argument", 'a=(1,"foo");a[1].', "capitalize"
482-
yield _test_complete, "cover duplicate completions", "im", "import", 0, 2
477+
_test_complete("jedi >0.9 should complete and not crash", "a=1;a.", "real")
478+
_test_complete("can infer first argument", 'a=(1,"foo");a[0].', "real")
479+
_test_complete("can infer second argument", 'a=(1,"foo");a[1].', "capitalize")
480+
_test_complete("cover duplicate completions", "im", "import", 0, 2)
483481

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")
485483

486484
def test_completion_have_signature(self):
487485
"""
@@ -548,15 +546,27 @@ def _(line, cursor_pos, expect, message, completion):
548546
self.assertIn(completion, completions)
549547

550548
with provisionalcompleter():
551-
yield _, "a[0].", 5, "a[0].real", "Should have completed on a[0].: %s", Completion(
552-
5, 5, "real"
549+
_(
550+
"a[0].",
551+
5,
552+
"a[0].real",
553+
"Should have completed on a[0].: %s",
554+
Completion(5, 5, "real"),
553555
)
554-
yield _, "a[0].r", 6, "a[0].real", "Should have completed on a[0].r: %s", Completion(
555-
5, 6, "real"
556+
_(
557+
"a[0].r",
558+
6,
559+
"a[0].real",
560+
"Should have completed on a[0].r: %s",
561+
Completion(5, 6, "real"),
556562
)
557563

558-
yield _, "a[0].from_", 10, "a[0].from_bytes", "Should have completed on a[0].from_: %s", Completion(
559-
5, 10, "from_bytes"
564+
_(
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"),
560570
)
561571

562572
def test_omit__names(self):

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ init:
2323
install:
2424
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
2525
- 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
2727
- pip install .[test]
2828
- mkdir results
2929
- cd results

0 commit comments

Comments
 (0)