MCPcopy Create free account
hub / github.com/SplootCode/splootcode / testIfElse

Method testIfElse

python/tests/test_execute.py:39–71  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

37
38
39 def testIfElse(self):
40 self.maxDiff = None
41 splootFile = splootFromPython('''
42x = 10
43if x == 10:
44 print('hi')
45else:
46 print('bye')
47''')
48
49 f = io.StringIO()
50 f.write = wrapStdout(f.write)
51 with contextlib.redirect_stdout(f):
52 cap, _ = executePythonFile(splootFile)
53
54 self.assertEqual(cap, {
55 'root': {
56 'type': 'PYTHON_FILE',
57 'data': {
58 'body': [
59 {'type': 'PYTHON_ASSIGNMENT', 'data': {'result': '10', 'resultType': 'int'}},
60 {'type': 'PYTHON_IF_STATEMENT', 'data': {
61 'condition': [{'data': {'result': 'True', 'resultType': 'bool'}}],
62 'trueblock': [{
63 'type': 'PYTHON_EXPRESSION',
64 'data': {'result': 'None', 'resultType': 'NoneType'},
65 'sideEffects': [{'type': 'stdout', 'value':'hi'},{'type': 'stdout', 'value':'\n'}]
66 }]
67 }},
68 ]
69 }
70 },
71 'detached': {}})
72
73 def testElse(self):
74 self.maxDiff = None

Callers

nothing calls this directly

Calls 3

splootFromPythonFunction · 0.90
wrapStdoutFunction · 0.90
executePythonFileFunction · 0.90

Tested by

no test coverage detected