(self)
| 113 | |
| 114 | |
| 115 | def testFunctionDeclaration(self): |
| 116 | self.maxDiff = None |
| 117 | splootFile = splootFromPython(''' |
| 118 | def add(a, b): |
| 119 | print(a + b) |
| 120 | add(3, 4) |
| 121 | add(123, 45) |
| 122 | ''') |
| 123 | # Set ID on function node: |
| 124 | self.assertIsNone(splootFile['childSets']['body'][0]['childSets']['statement'][0]['properties']['id']) |
| 125 | splootFile['childSets']['body'][0]['childSets']['statement'][0]['properties']['id'] = "TEST_FUNC_ID" |
| 126 | |
| 127 | f = io.StringIO() |
| 128 | f.write = wrapStdout(f.write) |
| 129 | with contextlib.redirect_stdout(f): |
| 130 | cap, _ = executePythonFile(splootFile) |
| 131 | |
| 132 | self.assertEqual(cap, { |
| 133 | 'root': { |
| 134 | 'type': 'PYTHON_FILE', |
| 135 | 'data': { |
| 136 | 'body': [ |
| 137 | {'type': 'PYTHON_EXPRESSION', 'data': {'result': 'None','resultType': 'NoneType'}}, |
| 138 | {'type': 'PYTHON_EXPRESSION', 'data': {'result': 'None','resultType': 'NoneType'}}, |
| 139 | ] |
| 140 | } |
| 141 | }, |
| 142 | 'detached': { |
| 143 | 'TEST_FUNC_ID': { |
| 144 | 'count': 2, |
| 145 | 'frames': [ |
| 146 | { |
| 147 | 'type': 'PYTHON_FUNCTION_CALL', |
| 148 | 'data': { |
| 149 | 'body': [{ |
| 150 | 'type': 'PYTHON_EXPRESSION', |
| 151 | 'data': {'result': 'None','resultType': 'NoneType'}, |
| 152 | 'sideEffects': [{'type': 'stdout', 'value': '7'}, {'type': 'stdout', 'value': '\n'}], |
| 153 | }] |
| 154 | }, |
| 155 | }, |
| 156 | { |
| 157 | 'type': 'PYTHON_FUNCTION_CALL', |
| 158 | 'data': { |
| 159 | 'body': [{ |
| 160 | 'type': 'PYTHON_EXPRESSION', |
| 161 | 'data': {'result': 'None','resultType': 'NoneType'}, |
| 162 | 'sideEffects': [{'type': 'stdout', 'value': '168'}, {'type': 'stdout', 'value': '\n'}], |
| 163 | }] |
| 164 | }, |
| 165 | } |
| 166 | ] |
| 167 | } |
| 168 | }}) |
| 169 | |
| 170 | def testList(self): |
| 171 | self.maxDiff = None |
nothing calls this directly
no test coverage detected