Skip to content

Commit

Permalink
Assertion Roulette::Detecting AssertCount in each method:v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Talismanic committed Aug 14, 2020
1 parent 735cfbf commit c51952b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions detecting_assertion_roulette.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def main():
print(detectAssertionRoulette("test_code_for_parsing.py"))


# In[68]:
# In[105]:


def detectAssertionRoulette(script_name):
Expand All @@ -39,9 +39,12 @@ def detectAssertionRoulette(script_name):
for body_item in node.body:
#checking if the function body has any assert statement
#and keeping the count of that
if isinstance(body_item, ast.Expr):
ops = body_item.value.func.attr
if ops.startswith('assert'):
fn['countAssert'] = fn['countAssert'] + 1
if isinstance(body_item, ast.Assert):
fn['countAssert'] = fn['countAssert'] + 1

fn['countAssert'] = fn['countAssert'] + 1
if fn['countAssert'] >1:
fn['hasSmell'] = True

Expand All @@ -50,7 +53,7 @@ def detectAssertionRoulette(script_name):
return fns


# In[71]:
# In[108]:


if __name__ == "__main__":
Expand Down

0 comments on commit c51952b

Please sign in to comment.