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

Skip to content

Commit ff1ba77

Browse files
committed
Add test for shadowing
1 parent 39cb11b commit ff1ba77

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_completer.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,29 @@ def test_line_magics_with_code_argument(self):
942942
text, matches = c.complete("%debug --invalid float.as_integer")
943943
self.assertEqual(matches, [])
944944

945+
def test_line_magics_with_code_argument_shadowing(self):
946+
ip = get_ipython()
947+
c = ip.Completer
948+
c.use_jedi = False
949+
950+
# shadow
951+
ip.run_cell("timeit = 1")
952+
953+
# should not suggest on implict magic when shadowed
954+
text, matches = c.complete("timeit -n 2 -r 1 flo")
955+
self.assertEqual(matches, [])
956+
957+
# should suggest on explicit magic
958+
text, matches = c.complete("%timeit -n 2 -r 1 flo")
959+
self.assertEqual(matches, ["float"])
960+
961+
# remove shadow
962+
del ip.user_ns["timeit"]
963+
964+
# should suggest on implicit magic after shadow removal
965+
text, matches = c.complete("timeit -n 2 -r 1 flo")
966+
self.assertEqual(matches, ["float"])
967+
945968
def test_magic_completion_order(self):
946969
ip = get_ipython()
947970
c = ip.Completer

0 commit comments

Comments
 (0)