Ejemplo n.º 1
0
def test_pass_keyword(assert_errors, parse_ast_tree, code, default_options):
    """Testing that pass keyword is restricted inside different definitions."""
    tree = parse_ast_tree(code)

    visitor = WrongKeywordVisitor(default_options, tree=tree)
    visitor.run()

    assert_errors(visitor, [WrongKeywordViolation])
Ejemplo n.º 2
0
def test_global_keywords(assert_errors, parse_ast_tree, code, default_options):
    """Testing that `global` and `nonlocal` keywords are restricted."""
    tree = parse_ast_tree(code)

    visitor = WrongKeywordVisitor(default_options, tree=tree)
    visitor.run()

    assert_errors(visitor, [WrongKeywordViolation])
Ejemplo n.º 3
0
def test_pass_keyword(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    code,
    default_options,
):
    """Testing that `pass` keyword is restricted."""
    tree = parse_ast_tree(code)

    visitor = WrongKeywordVisitor(default_options, tree=tree)
    visitor.run()

    assert_errors(visitor, [WrongKeywordViolation])
    assert_error_text(visitor, 'pass')
Ejemplo n.º 4
0
def test_nonlocal_keywords(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    code,
    default_options,
    mode,
):
    """Testing that `nonlocal` keyword is restricted."""
    tree = parse_ast_tree(mode(code))

    visitor = WrongKeywordVisitor(default_options, tree=tree)
    visitor.run()

    assert_errors(visitor, [WrongKeywordViolation])
    assert_error_text(visitor, 'nonlocal')
Ejemplo n.º 5
0
def test_del_keyword(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    code,
    default_options,
):
    """
    Testing that `del` keyword is restricted.

    Regression:
    https://github.com/wemake-services/wemake-python-styleguide/issues/493
    """
    tree = parse_ast_tree(code)

    visitor = WrongKeywordVisitor(default_options, tree=tree)
    visitor.run()

    assert_errors(visitor, [WrongKeywordViolation])
    assert_error_text(visitor, 'del')