Debian Codegraph @

tests/test_splitinput.py

raw
1 # coding: utf-8
2
3 from IPython.core.splitinput import split_user_input, LineInfo
4
5 import pytest
6
7 tests = [
8 ("x=1", ("", "", "x", "=1")),
9 ("?", ("", "?", "", "")),
10 ("??", ("", "??", "", "")),
11 (" ?", (" ", "?", "", "")),
12 (" ??", (" ", "??", "", "")),
13 ("??x", ("", "??", "x", "")),
14 ("?x=1", ("", "?", "x", "=1")),
15 ("!ls", ("", "!", "ls", "")),
16 (" !ls", (" ", "!", "ls", "")),
17 ("!!ls", ("", "!!", "ls", "")),
18 (" !!ls", (" ", "!!", "ls", "")),
19 (",ls", ("", ",", "ls", "")),
20 (";ls", ("", ";", "ls", "")),
21 (" ;ls", (" ", ";", "ls", "")),
22 ("f.g(x)", ("", "", "f.g", "(x)")),
23 ("f.g (x)", ("", "", "f.g", " (x)")),
24 ("?%hist1", ("", "?", "%hist1", "")),
25 ("?%%hist2", ("", "?", "%%hist2", "")),
26 ("??%hist3", ("", "??", "%hist3", "")),
27 ("??%%hist4", ("", "??", "%%hist4", "")),
28 ("?x*", ("", "?", "x*", "")),
29 ("Pérez Fernando", ("", "", "Pérez", " Fernando")),
30 ]
31
32
33 @pytest.mark.parametrize("input, output", tests)
34 def test_split_user_input(input, output):
35 assert split_user_input(input) == output
36
37
38 def test_LineInfo():
39 """Simple test for LineInfo construction and str()"""
40 linfo = LineInfo(" %cd /home")
41 assert str(linfo) == "LineInfo [ |%|cd|/home]"