MCPcopy Index your code
hub / github.com/ipython/ipython / test_cpaste

Function test_cpaste

tests/test_magic_terminal.py:68–97  ·  view source on GitHub ↗

Test cpaste magic

()

Source from the content-addressed store, hash-verified

66
67
68def test_cpaste():
69 """Test cpaste magic"""
70
71 def runf():
72 """Marker function: sets a flag when executed."""
73 ip.user_ns["code_ran"] = True
74 return "runf" # return string so '+ runf()' doesn't result in success
75
76 tests = {
77 "pass": [
78 "runf()",
79 "In [1]: runf()",
80 "In [1]: if 1:\n ...: runf()",
81 "> > > runf()",
82 ">>> runf()",
83 " >>> runf()",
84 ],
85 "fail": [
86 "1 + runf()",
87 "++ runf()",
88 ],
89 }
90
91 ip.user_ns["runf"] = runf
92
93 for code in tests["pass"]:
94 check_cpaste(code)
95
96 for code in tests["fail"]:
97 check_cpaste(code, should_fail=True)
98
99
100class PasteTestCase(TestCase):

Callers

nothing calls this directly

Calls 1

check_cpasteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…