Esempio n. 1
0
def test_init_without_logic(
    assert_errors, parse_ast_tree, code, default_options,
):
    """Testing that `__init__` without logic is allowed."""
    tree = parse_ast_tree(code)

    visitor = EmptyModuleContentsVisitor(
        default_options, tree=tree, filename='__init__.py',
    )
    visitor.run()

    assert_errors(visitor, [])
Esempio n. 2
0
def test_init_with_logic(
    assert_errors, parse_ast_tree, code, default_options,
):
    """Testing that `__init__` with logic is restricted."""
    tree = parse_ast_tree(code)

    visitor = EmptyModuleContentsVisitor(
        default_options, tree=tree, filename='__init__.py',
    )
    visitor.run()

    assert_errors(visitor, [InitModuleHasLogicViolation])
Esempio n. 3
0
def test_simple_filename(
    assert_errors, parse_ast_tree, filename, default_options,
):
    """Testing that simple file names should not be empty."""
    tree = parse_ast_tree('')

    visitor = EmptyModuleContentsVisitor(
        default_options, tree=tree, filename=filename,
    )
    visitor.run()

    assert_errors(visitor, [EmptyModuleViolation])
Esempio n. 4
0
def test_init_with_logic_without_control(
    assert_errors, parse_ast_tree, code, options,
):
    """Testing that `__init__` with logic is restricted."""
    tree = parse_ast_tree(code)

    option_values = options(i_control_code=False)
    visitor = EmptyModuleContentsVisitor(
        option_values,
        tree=tree,
        filename='__init__.py',
    )
    visitor.run()

    assert_errors(visitor, [])