Skip to content

Commit

Permalink
Skip async tests correctly (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ722 authored and jendrikseipp committed Jun 6, 2018
1 parent 8d66262 commit 7ff8d68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions tests/__init__.py
Expand Up @@ -9,6 +9,10 @@
REPO = os.path.dirname(DIR)
WHITELISTS = glob.glob(os.path.join(REPO, 'vulture', 'whitelists', '*.py'))

skip_if_not_has_async = pytest.mark.skipif(
not hasattr(ast, 'AsyncFunctionDef'),
reason="needs async support (added in Python 3.5)")


def check(items_or_names, expected_names):
if isinstance(items_or_names, set):
Expand All @@ -29,12 +33,6 @@ def check_unreachable(v, lineno, size, name):
assert item.name == name


def skip_if_not_has_async(function):
if not hasattr(ast, 'AsyncFunctionDef'):
pytest.mark.skip(
function, reason="needs async support (added in Python 3.5)")


@pytest.fixture
def v():
return core.Vulture(verbose=True)
2 changes: 1 addition & 1 deletion tests/test_scavenging.py
Expand Up @@ -402,7 +402,7 @@ async def test_func():
async def other_func():
pass
""", filename='test_function_names.py')
""", filename='function_names.py')
check(v.defined_funcs, ['test_func', 'other_func'])
check(v.unused_funcs, ['other_func', 'test_func'])

Expand Down

0 comments on commit 7ff8d68

Please sign in to comment.