Skip to content

Commit

Permalink
all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
duelingbenjos committed May 21, 2024
1 parent 502c985 commit 0dfa1f7
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 104 deletions.
2 changes: 1 addition & 1 deletion src/contracting/compilation/whitelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ast.Subscript, ast.Compare, ast.Return, ast.NameConstant, ast.Expr, ast.keyword, ast.Sub,
ast.arguments, ast.List, ast.Set, ast.Str, ast.UnaryOp, ast.Pass, ast.Tuple, ast.Div, ast.In,
ast.NotIn, ast.Gt, ast.Lt, ast.Starred, ast.Mod, ast.NotEq, ast.For, ast.While, ast.ListComp,
ast.comprehension, ast.Slice, ast.USub, ast.BoolOp, ast.And, ast.Or, ast.Mult, ast.IsNot, ast.Is}
ast.comprehension, ast.Slice, ast.USub, ast.BoolOp, ast.And, ast.Or, ast.Mult, ast.IsNot, ast.Is, ast.Constant}

ILLEGAL_AST_TYPES = {
ast.AsyncFor,
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ def a():

# TODO - Verify this tetst is working as expected.
def test_good_ast_type(self):
# Dictionary to handle special cases of AST nodes that require arguments
special_cases = {
ast.Index: lambda: ast.Index(value=ast.Str(s='test')),
}

for t in ALLOWED_AST_TYPES:
_t = t()
if t in special_cases:
_t = special_cases[t]()
else:
_t = t()

self.l.ast_types(_t, 1)
self.assertListEqual([], self.l._violations)

Expand Down
Loading

0 comments on commit 0dfa1f7

Please sign in to comment.