usagitoneko97 / klara

Automatic test case generation for python and static analysis library
https://klara-py.readthedocs.io
Other
261 stars 15 forks source link

Many Errors #7

Closed erezsh closed 3 years ago

erezsh commented 3 years ago
  1. When I run klara on https://github.com/erezsh/runtype/blob/master/runtype/dataclass.py, I get AttributeError: 'JoinedStr' object has no attribute 'statement' :
  File "c:\python38\lib\site-packages\klara\core\cfg.py", line 354, in rename
    super(ParentScopeBlock, self).rename()
  File "c:\python38\lib\site-packages\klara\core\cfg.py", line 191, in rename
    blk.enumerate()
  File "c:\python38\lib\site-packages\klara\core\cfg.py", line 156, in enumerate
    AttributeEnumerator.enumerate(ast_stmt, False, False)
  File "c:\python38\lib\site-packages\klara\core\ssa.py", line 115, in enumerate
    var.convert_to_ssa()
  File "c:\python38\lib\site-packages\klara\core\node_classes.py", line 399, in convert_to_ssa
    stmt = field.statement()
AttributeError: 'JoinedStr' object has no attribute 'statement'
  1. When I run it on https://github.com/lark-parser/lark/blob/master/lark/utils.py, I get KeyError: 'is not'
...
  File "c:\python38\lib\site-packages\klara\core\inference.py", line 1146, in infer_compare
    for result in calc_compare(comp, self.ops, context):
  File "c:\python38\lib\site-packages\klara\core\inference.py", line 1195, in calc_compare
    methods = _comp_op_methods(left, comp, op, context)
  File "c:\python38\lib\site-packages\klara\core\inference.py", line 1161, in _comp_op_methods
    method_name=COMP_OP_DUNDER_METHOD[op],
KeyError: 'is not'
  1. When I run it on https://github.com/lark-parser/lark/blob/master/lark/tree.py I get AttributeError: type object 'Del' has no attribute 'targets'
...
    return [self._visit_generic(child) for child in node]
  File "c:\python38\lib\site-packages\klara\core\transform.py", line 36, in _visit_generic
    return self._visit(node)
  File "c:\python38\lib\site-packages\klara\core\transform.py", line 24, in _visit
    returned = self._visit_generic(value)
  File "c:\python38\lib\site-packages\klara\core\transform.py", line 36, in _visit_generic
    return self._visit(node)
  File "c:\python38\lib\site-packages\klara\core\transform.py", line 23, in _visit
    value = getattr(node, name)
AttributeError: type object 'Del' has no attribute 'targets'

I'm sure I can keep going, but let's stop here for now :)

usagitoneko97 commented 3 years ago

Reopen since there are more error to handle.

usagitoneko97 commented 3 years ago

Hi @erezsh . Thanks for trying out. There are still a lot of unhandled errors if it's used in real world python file. The goal is to clean up the errors, or at least, emit helpful log message for unsupported features.

On another note, looking at the sample files, Klara wouldn't be able to generate any tests due to missing functions annotation. At least one argument need to be annotated.

erezsh commented 3 years ago

I have no problem adding annotations. I'm at the stage of waiting to see if it even works :)

usagitoneko97 commented 3 years ago

The errors from those 3 files has been fixed in 0.6.3..

erezsh commented 3 years ago

That may be, but it also doesn't generate a single test for any of them.

Not even utils.py, which is filled with simple standalone functions.