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

Method testElse

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

Source from the content-addressed store, hash-verified

71 'detached': {}})
72
73 def testElse(self):
74 self.maxDiff = None
75 splootFile = splootFromPython('''
76x = 10
77if x != 10:
78 print('hi')
79else:
80 print('bye')
81''')
82
83 f = io.StringIO()
84 f.write = wrapStdout(f.write)
85 with contextlib.redirect_stdout(f):
86 cap, _ = executePythonFile(splootFile)
87
88 self.assertEqual(cap, {
89 'root': {
90 'type': 'PYTHON_FILE',
91 'data': {
92 'body': [
93 {'type': 'PYTHON_ASSIGNMENT', 'data': {'result': '10', 'resultType': 'int'}},
94 {
95 'type': 'PYTHON_IF_STATEMENT',
96 'data': {
97 'condition': [{'data': {'result': 'False', 'resultType': 'bool'}}],
98 'elseblocks': [{
99 'type': 'PYTHON_ELSE_STATEMENT',
100 'data': {
101 'block': [
102 {'type': 'PYTHON_EXPRESSION',
103 'data': {'result': 'None', 'resultType': 'NoneType'},
104 'sideEffects': [{'type': 'stdout', 'value':'bye'},{'type': 'stdout', 'value':'\n'}]}
105 ]
106 }}
107 ]}
108 },
109 ]
110 }
111 },
112 'detached': {}})
113
114
115 def testFunctionDeclaration(self):

Callers

nothing calls this directly

Calls 3

splootFromPythonFunction · 0.90
wrapStdoutFunction · 0.90
executePythonFileFunction · 0.90

Tested by

no test coverage detected