Code Duplication    Length = 36-39 lines in 2 locations

tests/bearlib/abstractions/LinterTest.py 2 locations

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