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

Function test_cpaste

IPython/core/tests/test_magic_terminal.py:49–76  ·  view source on GitHub ↗

Test cpaste magic

()

Source from the content-addressed store, hash-verified

47 sys.stdin = stdin_save
48
49def test_cpaste():
50 """Test cpaste magic"""
51
52 def runf():
53 """Marker function: sets a flag when executed.
54 """
55 ip.user_ns['code_ran'] = True
56 return 'runf' # return string so '+ runf()' doesn't result in success
57
58 tests = {'pass': ["runf()",
59 "In [1]: runf()",
60 "In [1]: if 1:\n ...: runf()",
61 "> > > runf()",
62 ">>> runf()",
63 " >>> runf()",
64 ],
65
66 'fail': ["1 + runf()",
67 "++ runf()",
68 ]}
69
70 ip.user_ns['runf'] = runf
71
72 for code in tests['pass']:
73 check_cpaste(code)
74
75 for code in tests['fail']:
76 check_cpaste(code, should_fail=True)
77
78
79class PasteTestCase(TestCase):

Callers

nothing calls this directly

Calls 1

check_cpasteFunction · 0.85

Tested by

no test coverage detected