def test_simple_f_string(assert_errors, parse_ast_tree, code, default_options):
    """Testing that non complex ``f`` strings are allowed."""
    tree = parse_ast_tree(code)

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

    assert_errors(visitor, [FormattedStringViolation])
def test_wrong_string(assert_errors, parse_ast_tree, code, default_options):
    """Testing that violations are raised when reaching max value."""
    tree = parse_ast_tree(code)

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

    assert_errors(visitor, [
        TooComplexFormattedStringViolation,
        FormattedStringViolation,
    ])
def test_complex_f_string(assert_errors, parse_ast_tree, code,
                          default_options):
    """Testing that complex ``f`` strings are not allowed."""
    tree = parse_ast_tree(code)

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

    assert_errors(
        visitor,
        [TooComplexFormattedStringViolation],
        ignored_types=FormattedStringViolation,
    )