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

Method testElif

python/tests/test_convert_ast.py:394–438  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

392
393
394 def testElif(self):
395 self.maxDiff = None
396
397 fileNode = splootFromPython('''
398if True:
399 'hi'
400elif False:
401 'hi'
402else:
403 'hi'
404''')
405 self.assertEqual(fileNode, {
406 'type': 'PYTHON_FILE',
407 'childSets': {'body': [
408 {
409 'type': 'PYTHON_STATEMENT',
410 'meta': {'lineno': 1},
411 'childSets': {
412 'statement': [
413 {'type': 'PYTHON_IF_STATEMENT', 'childSets': {
414 'condition': [{'type': 'PYTHON_EXPRESSION', 'childSets': {'tokens': [{'type': 'PYTHON_BOOL', 'childSets': {}, 'properties': {'value': True}, }]}, 'properties': {}}],
415 'trueblock': [{'type': 'PYTHON_STATEMENT', 'meta': {'lineno': 2}, 'childSets': {'statement': [
416 {'type':'PYTHON_EXPRESSION', 'childSets': {'tokens': [{'type': 'STRING_LITERAL', 'childSets': {}, 'properties': {'value': 'hi'}}]}, 'properties': {} }
417 ]}, 'properties': {}}],
418 'elseblocks': [
419 {'type': 'PYTHON_ELIF_STATEMENT', 'childSets': {
420 'condition': [{'type': 'PYTHON_EXPRESSION', 'childSets': {'tokens': [{'type': 'PYTHON_BOOL', 'childSets': {}, 'properties': {'value': False}, }]}, 'properties': {}}],
421 'block': [{'type': 'PYTHON_STATEMENT', 'meta': {'lineno': 3}, 'childSets': {'statement': [
422 {'type':'PYTHON_EXPRESSION', 'childSets': {'tokens': [{'type': 'STRING_LITERAL', 'childSets': {}, 'properties': {'value': 'hi'}}]}, 'properties': {} }
423 ]}, 'properties': {}}]
424 }, 'properties': {}},
425 {'type': 'PYTHON_ELSE_STATEMENT', 'childSets': {
426 'block': [{'type': 'PYTHON_STATEMENT', 'meta': {'lineno': 4}, 'childSets': {'statement': [
427 {'type':'PYTHON_EXPRESSION', 'childSets': {'tokens': [{'type': 'STRING_LITERAL', 'childSets': {}, 'properties': {'value': 'hi'}}]}, 'properties': {} }
428 ]}, 'properties': {}}]
429 }, 'properties': {}},
430 ]
431 }, 'properties': {}}
432 ],
433 },
434 'properties': {},
435 }
436 ]},
437 'properties': {},
438 })

Callers

nothing calls this directly

Calls 1

splootFromPythonFunction · 0.90

Tested by

no test coverage detected