def test_regular_short_compare( code, assert_errors, parse_ast_tree, default_options, ): """Testing implicit complex compare.""" tree = parse_ast_tree(code) visitor = ImplicitBoolPatternsVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_implicit_complex_compare( code, comparators, assert_errors, parse_ast_tree, default_options, ): """Testing implicit complex compare.""" tree = parse_ast_tree(code.format(*comparators)) visitor = ImplicitBoolPatternsVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [ImplicitComplexCompareViolation])
def test_regular_compare_not_ternary( code, first, second, assert_errors, parse_ast_tree, default_options, ): """Testing regular compares and not ternaries.""" tree = parse_ast_tree(code.format(first, second)) visitor = ImplicitBoolPatternsVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_implicit_ternary( code, first, second, assert_errors, parse_ast_tree, default_options, ): """Testing implicit ternary.""" tree = parse_ast_tree(code.format(first, second)) visitor = ImplicitBoolPatternsVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [ImplicitTernaryViolation])
def test_wrong_patterns_in_values( code, first, second, assert_errors, parse_ast_tree, default_options, ): """Testing safe in patterns.""" tree = parse_ast_tree(code.format(first, second)) visitor = ImplicitBoolPatternsVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [ImplicitInConditionViolation])
def test_different_in_values( code, first, second, assert_errors, parse_ast_tree, default_options, ): """Testing regular conditions.""" tree = parse_ast_tree(code.format(first, second)) visitor = ImplicitBoolPatternsVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])