Exemplo n.º 1
0
def test_correct_startup_metadata(
    assert_errors,
    parse_ast_tree,
    default_options,
):
    """Testing that startup hook is allowed."""
    tree = parse_ast_tree(startup_metadata)

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

    assert_errors(visitor, [])
Exemplo n.º 2
0
def test_correct_metadata(
    assert_errors,
    parse_ast_tree,
    code,
    correct_name,
    default_options,
):
    """Testing that metadata can have normal names."""
    tree = parse_ast_tree(code.format(correct_name))

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

    assert_errors(visitor, [])
def test_wrong_metadata(
    assert_errors,
    parse_ast_tree,
    bad_name,
    code,
    default_options,
):
    """Testing that metadata can not have blacklisted names."""
    tree = parse_ast_tree(code.format(bad_name))

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

    assert_errors(visitor, [WrongModuleMetadataViolation])