def test_correct_binary(
    assert_errors,
    parse_ast_tree,
    expression,
    default_options,
):
    """Testing allowed bitwise comparisons."""
    tree = parse_ast_tree(expression)

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

    assert_errors(visitor, [])
def test_bitwise_boolean_mixup(
    assert_errors,
    parse_ast_tree,
    expression,
    default_options,
):
    """Testing for forbidden comparison between bitwise and boolean operator."""
    tree = parse_ast_tree(expression)

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

    assert_errors(visitor, [BitwiseAndBooleanMixupViolation])
def test_union_type(
    assert_errors,
    parse_ast_tree,
    context,
    expression,
    default_options,
):
    """Testing PEP 604 union types."""
    tree = parse_ast_tree(context.format(expression))

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

    assert_errors(visitor, [])