MCPcopy Create free account
hub / github.com/ipython/ipython / test_protect_filename

Function test_protect_filename

IPython/core/tests/test_completer.py:48–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46
47
48def test_protect_filename():
49 if sys.platform == "win32":
50 pairs = [
51 ("abc", "abc"),
52 (" abc", '" abc"'),
53 ("a bc", '"a bc"'),
54 ("a bc", '"a bc"'),
55 (" bc", '" bc"'),
56 ]
57 else:
58 pairs = [
59 ("abc", "abc"),
60 (" abc", r"\ abc"),
61 ("a bc", r"a\ bc"),
62 ("a bc", r"a\ \ bc"),
63 (" bc", r"\ \ bc"),
64 # On posix, we also protect parens and other special characters.
65 ("a(bc", r"a\(bc"),
66 ("a)bc", r"a\)bc"),
67 ("a( )bc", r"a\(\ \)bc"),
68 ("a[1]bc", r"a\[1\]bc"),
69 ("a{1}bc", r"a\{1\}bc"),
70 ("a#bc", r"a\#bc"),
71 ("a?bc", r"a\?bc"),
72 ("a=bc", r"a\=bc"),
73 ("a\\bc", r"a\\bc"),
74 ("a|bc", r"a\|bc"),
75 ("a;bc", r"a\;bc"),
76 ("a:bc", r"a\:bc"),
77 ("a'bc", r"a\'bc"),
78 ("a*bc", r"a\*bc"),
79 ('a"bc', r"a\"bc"),
80 ("a^bc", r"a\^bc"),
81 ("a&bc", r"a\&bc"),
82 ]
83 # run the actual tests
84 for s1, s2 in pairs:
85 s1p = completer.protect_filename(s1)
86 nt.assert_equal(s1p, s2)
87
88
89def check_line_split(splitter, test_specs):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected