def test_correct_assignments( assert_errors, parse_ast_tree, code, default_options, ): """Testing that correct assignments work.""" tree = parse_ast_tree(code) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_multiple_assignments( assert_errors, parse_ast_tree, code, default_options, ): """Testing that multiple assignments are restricted.""" tree = parse_ast_tree(code) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [MultipleAssignmentsViolation])
def test_correct_unpacking( assert_errors, parse_ast_tree, code, default_options, mode, ): """Testing that correct assignments work.""" tree = parse_ast_tree(mode(code.format('some_name'))) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_correct_assignment( assert_errors, parse_ast_tree, assignment, default_options, mode, ): """Testing that correct assignments work.""" tree = parse_ast_tree(mode(single_assignment.format(assignment))) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_correct_destructing( assert_errors, parse_ast_tree, target, default_options, mode, ): """Testing that correct elements destructuring work.""" tree = parse_ast_tree(mode(correct_single_destructuring.format(target))) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_unpacking_to_list( assert_errors, parse_ast_tree, default_options, code, assignment, ): """Ensure that unpacking iterable to list is restricted.""" tree = parse_ast_tree(code.format(assignment)) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [UnpackingIterableToListViolation])
def test_multiple_assignments( assert_errors, parse_ast_tree, code, assignment, default_options, ): """Testing that multiple assignments are restricted.""" tree = parse_ast_tree(code.format(assignment)) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [IncorrectUnpackingViolation])
def test_element_getting_by_unpacking( assert_errors, parse_ast_tree, code, definition, default_options, ): """Testing that getting element by unpacking is restricted.""" tree = parse_ast_tree(code.format(definition)) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors( visitor, [GettingElementByUnpackingViolation], ignored_types=WrongUnpackingViolation, )
def test_single_element_destructing( assert_errors, parse_ast_tree, code, assignment, default_options, mode, ): """Testing that single element destructuring is restricted.""" tree = parse_ast_tree(mode(code.format(assignment))) visitor = WrongAssignmentVisitor(default_options, tree=tree) visitor.run() assert_errors( visitor, [SingleElementDestructuringViolation], ignored_types=UnpackingIterableToListViolation, )