@@ -31,33 +31,34 @@ def delete_multiple_if_name_main(test_ast: ast.Module) -> ast.Module:
3131
3232
3333class ModifyInspiredTests (ast .NodeTransformer ):
34- """This isn't being used right now"""
34+ """Transformer for modifying inspired test classes.
3535
36- def __init__ (self , import_list , test_framework ):
36+ Class is currently not in active use.
37+ """
38+
39+ def __init__ (self , import_list : list [ast .AST ], test_framework : str ) -> None :
3740 self .import_list = import_list
3841 self .test_framework = test_framework
3942
40- def visit_Import (self , node : ast .Import ):
43+ def visit_Import (self , node : ast .Import ) -> None :
4144 self .import_list .append (node )
4245
43- def visit_ImportFrom (self , node : ast .ImportFrom ):
46+ def visit_ImportFrom (self , node : ast .ImportFrom ) -> None :
4447 self .import_list .append (node )
4548
46- def visit_ClassDef (self , node : ast .ClassDef ):
49+ def visit_ClassDef (self , node : ast .ClassDef ) -> ast . ClassDef :
4750 if self .test_framework != "unittest" :
4851 return node
4952 found = False
5053 if node .bases :
5154 for base in node .bases :
52- if isinstance (base , ast .Attribute ):
53- if base .attr == "TestCase" and base .value .id == "unittest" :
54- found = True
55- break
56- if isinstance (base , ast .Name ):
57- # TODO: Possibility that this is not a unittest.TestCase
58- if base .id == "TestCase" :
59- found = True
60- break
55+ if isinstance (base , ast .Attribute ) and base .attr == "TestCase" and base .value .id == "unittest" :
56+ found = True
57+ break
58+ # TODO: Check if this is actually a unittest.TestCase
59+ if isinstance (base , ast .Name ) and base .id == "TestCase" :
60+ found = True
61+ break
6162 if not found :
6263 return node
6364 node .name = node .name + "Inspired"
0 commit comments