def test_parserPythonComments(self): py = PythonParser() py.parse(code) obteined = [ref.name for ref in py.references] expected = ['bii://wololo'] self.assertEqual(expected, obteined)
def test_parserPythonImports(self): py = PythonParser() py.parse(code) obtained = [ref.name for ref in py.imports] expected = ['from biicode.hola.dos import espinte as pocoyo', 'from biicode.hola.dos import chorizos', 'import sys', 'import biicode.hola.dos as wololo'] self.assertEqual(expected, obtained)
def test_bug(self): py = PythonParser() py.parse(buggy_code) obtained = [ref.name for ref in py.imports] obteined2 = [ref.name for ref in py.references] expected = ['import re'] self.assertEqual(expected, obtained) expected2 = [] self.assertEqual(expected2, obteined2)
def test_parserPythonItems(self): py = PythonParser() py.parse(fileData) obtained = [ref.name for ref in py.imports] obteined2 = [ref.name for ref in py.references] expected = ['import sys', 'from re import match', 'import myBlock', 'from functions import LeerLista', 'import sys','import user.hive'] self.assertEqual(expected, obtained) expected2 = ['bii://user1/module1/user1', 'bii://user2/module2/file2'] self.assertEqual(expected2, obteined2)
def test_python_c_include(self): code = r''' import biipyc import my_block lib = link_clib("user/block/test.h") some_var = test("user/block/cosa.h") value = 3 libd = biipyc.link_clib("user/block/test2.h")''' py = PythonParser() py.parse(code) obtained_explicit_decs = py.explicit_declarations expected_explicit_decs = [CPPDeclaration("user/block/test.h"), CPPDeclaration("user/block/test2.h"), PythonDeclaration("import my_block"), PythonDeclaration("import biipyc")] self.assertItemsEqual(expected_explicit_decs, obtained_explicit_decs) self.assertTrue(py.has_main_function())