def test_correct_constant_is( assert_errors, parse_ast_tree, comparators, is_conditions, default_options, ): """Testing that compares with falsy constants are not allowed.""" tree = parse_ast_tree(is_conditions.format(*comparators)) visitor = WrongConstantCompareVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_falsy_constant( assert_errors, parse_ast_tree, comparators, eq_conditions, default_options, ): """Testing that compares with falsy contants are not allowed.""" tree = parse_ast_tree(eq_conditions.format(*comparators)) visitor = WrongConstantCompareVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [FalsyConstantCompareViolation])
def test_correct_constant_compare( assert_errors, parse_ast_tree, comparators, simple_conditions, default_options, ): """Testing that normal compares are allowed.""" tree = parse_ast_tree(simple_conditions.format(*comparators)) visitor = WrongConstantCompareVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [], (WrongIsCompareViolation, ))
def test_wrong_constant_is( assert_errors, parse_ast_tree, comparators, is_conditions, default_options, ): """Testing that compares with falsy constants are not allowed.""" tree = parse_ast_tree(is_conditions.format(*comparators)) visitor = WrongConstantCompareVisitor(default_options, tree=tree) visitor.run() assert_errors( visitor, [WrongIsCompareViolation], ignored_types=FalsyConstantCompareViolation, )