Skip to content

Commit

Permalink
check that __methods are not explict callable
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed May 16, 2018
1 parent 754a3a0 commit 373e8dc
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/transformer/test_functiondef.py
Expand Up @@ -138,7 +138,7 @@ def test_RestrictingNodeTransformer__visit_FunctionDef__8(
_getiter_.reset_mock()


BLACKLISTED_FUNC_NAMES_TEST = """
FUNC_NAMES_TEST = """
def __init__(test):
test
"""
Expand All @@ -147,6 +147,24 @@ def __init__(test):
@pytest.mark.parametrize(*c_exec)
def test_RestrictingNodeTransformer__module_func_def_name(c_exec):
""""""
result = c_exec(BLACKLISTED_FUNC_NAMES_TEST)
# assert result.errors == ('Line 1: ')
result = c_exec(FUNC_NAMES_TEST)
assert result.errors == ()


BLACKLISTED_FUNC_NAMES_CALL_TEST = """
def __init__(test):
test
__init__(1)
"""


@pytest.mark.parametrize(*c_exec)
def test_RestrictingNodeTransformer__module_func_def_name_call(c_exec):
""""""
result = c_exec(BLACKLISTED_FUNC_NAMES_CALL_TEST)
# assert result.errors == ('Line 1: ')
assert result.errors == (
'Line 5: Call of private method.',
'Line 5: "__init__" is an invalid variable name because it starts with "_"', # NOQA: E501
)

0 comments on commit 373e8dc

Please sign in to comment.