Skip to content

Commit

Permalink
Merge 5fba65e into effe1d2
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium committed May 1, 2020
2 parents effe1d2 + 5fba65e commit e12360d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions deal/linter/_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ class CheckAsserts:
required = Required.FUNC

def __call__(self, func: Func, stubs: StubsManager = None) -> Iterator[Error]:
# do not validate asserts in tests
if func.name.startswith('test_'):
return
for token in get_asserts(body=func.body):
yield Error(
code=self.code,
Expand Down
16 changes: 15 additions & 1 deletion tests/test_linter/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test(a):
def test_check_asserts():
checker = CheckAsserts()
text = """
def test(a):
def example(a):
assert False, "oh no!"
"""
text = dedent(text).strip()
Expand All @@ -172,6 +172,20 @@ def test(a):
assert actual == expected


def test_skip_asserts_in_tests():
checker = CheckAsserts()
text = """
def test_example(a):
assert False, "oh no!"
"""
text = dedent(text).strip()
funcs1 = Func.from_ast(ast.parse(text))
funcs2 = Func.from_astroid(astroid.parse(text))
for func in (funcs1[0], funcs2[0]):
actual = list(checker(func))
assert actual == []


def test_check_imports():
checker = CheckImports()
text = """
Expand Down

0 comments on commit e12360d

Please sign in to comment.