Code Duplication    Length = 37-39 lines in 2 locations

tests/bearlib/abstractions/LinterTest.py 2 locations

@@ 81-119 (lines=39) @@
78
                         "Invalid keyword arguments provided: "
79
                         "'prerequisite_check_fail_message'")
80
81
    def test_decorator_invalid_states(self):
82
        with self.assertRaises(ValueError) as cm:
83
            linter("some-executable", use_stdout=False, use_stderr=False)
84
        self.assertEqual(str(cm.exception),
85
                         "No output streams provided at all.")
86
87
        with self.assertRaises(ValueError) as cm:
88
            linter("some-executable", output_format="INVALID")
89
        self.assertEqual(str(cm.exception),
90
                         "Invalid `output_format` specified.")
91
92
        with self.assertRaises(ValueError) as cm:
93
            linter("some-executable", output_format="regex")
94
        self.assertEqual(
95
            str(cm.exception),
96
            "`output_regex` needed when specified output-format 'regex'.")
97
98
        with self.assertRaises(ValueError) as cm:
99
            linter("some-executable",
100
                   output_format="regex",
101
                   output_regex="",
102
                   severity_map={})
103
        self.assertEqual(
104
            str(cm.exception),
105
            "Provided `severity_map` but named group `severity` is not used "
106
            "in `output_regex`.")
107
108
        with self.assertRaises(ValueError) as cm:
109
            linter("some-executable")(object)
110
        self.assertEqual(
111
            str(cm.exception),
112
            "`process_output` not provided by given class 'object'.")
113
114
        with self.assertRaises(ValueError) as cm:
115
            (linter("some-executable", output_format="regex", output_regex="")
116
             (self.ManualProcessingTestLinter))
117
        self.assertEqual(
118
            str(cm.exception),
119
            "Found `process_output` already defined by class "
120
            "'ManualProcessingTestLinter', but 'regex' output-format is "
121
            "specified.")
122
@@ 42-78 (lines=37) @@
39
    def setUp(self):
40
        self.section = Section("TEST_SECTION")
41
42
    def test_decorator_invalid_parameters(self):
43
        with self.assertRaises(ValueError) as cm:
44
            linter("some-executable", invalid_arg=88, ABC=2000)
45
        self.assertEqual(
46
            str(cm.exception),
47
            "Invalid keyword arguments provided: 'ABC', 'invalid_arg'")
48
49
        with self.assertRaises(ValueError) as cm:
50
            linter("some-executable", diff_severity=RESULT_SEVERITY.MAJOR)
51
        self.assertEqual(str(cm.exception),
52
                         "Invalid keyword arguments provided: 'diff_severity'")
53
54
        with self.assertRaises(ValueError) as cm:
55
            linter("some-executable", result_message="Custom message")
56
        self.assertEqual(str(cm.exception),
57
                         "Invalid keyword arguments provided: "
58
                         "'result_message'")
59
60
        with self.assertRaises(ValueError) as cm:
61
            linter("some-executable",
62
                   output_format="corrected",
63
                   output_regex=".*")
64
        self.assertEqual(str(cm.exception),
65
                         "Invalid keyword arguments provided: 'output_regex'")
66
67
        with self.assertRaises(ValueError) as cm:
68
            linter("some-executable",
69
                   output_format="corrected",
70
                   severity_map={})
71
        self.assertEqual(str(cm.exception),
72
                         "Invalid keyword arguments provided: 'severity_map'")
73
74
        with self.assertRaises(ValueError) as cm:
75
            linter("some-executable",
76
                   prerequisite_check_fail_message="some_message")
77
        self.assertEqual(str(cm.exception),
78
                         "Invalid keyword arguments provided: "
79
                         "'prerequisite_check_fail_message'")
80
81
    def test_decorator_invalid_states(self):