def test_module_counts_normal( assert_errors, parse_ast_tree, code, default_options, ): """Testing that classes and functions in a module work well.""" tree = parse_ast_tree(code) visitor = ModuleMembersVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_module_counts_violation( assert_errors, parse_ast_tree, code, options, ): """Testing that violations are raised when reaching max value.""" tree = parse_ast_tree(code) option_values = options(max_module_members=1) visitor = ModuleMembersVisitor(option_values, tree=tree) visitor.run() assert_errors(visitor, [TooManyModuleMembersViolation])
def test_module_counts_single_member( assert_errors, parse_ast_tree, code, options, ): """Testing that violations are not raised for a single member.""" tree = parse_ast_tree(code) option_values = options(max_module_members=1) visitor = ModuleMembersVisitor(option_values, tree=tree) visitor.run() assert_errors(visitor, [])
def test_decorators_normal( assert_errors, parse_ast_tree, code, default_options, mode, ): """Testing that correct amount of decorators works.""" tree = parse_ast_tree(mode(code)) visitor = ModuleMembersVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_decorators_incorrect( assert_errors, assert_error_text, parse_ast_tree, code, options, mode, ): """Testing that too large amount of decorators works.""" tree = parse_ast_tree(mode(code)) option_values = options(max_decorators=2) visitor = ModuleMembersVisitor(option_values, tree=tree) visitor.run() assert_errors(visitor, [TooManyDecoratorsViolation]) assert_error_text(visitor, '3')