Code Duplication    Length = 24-25 lines in 2 locations

tests_oval_graph/test_tools.py 1 location

@@ 32-56 (lines=25) @@
29
    def get_random_dir_in_tmp():
30
        return os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
31
32
    @staticmethod
33
    def compare_results_html(result):
34
        result_ = TestTools.get_text_file(result)
35
        reference_pattern = TestTools.get_text_file(
36
            'test_commands/test_data/referenc_pattern_html_report.txt')
37
        prefix_start = '<script>var data_of_tree = '
38
        prefix_end = ';</script><div>\n'
39
        data_in_html = ""
40
        matched = False
41
        for row in result_:
42
            if prefix_start in row and prefix_end in row:
43
                matched = True
44
                data_in_html = row
45
        assert matched
46
47
        tmp_json_str = data_in_html.replace(prefix_start, '').replace(prefix_end, '')
48
        tmp_json = json.loads(tmp_json_str)
49
        data_in_html = prefix_start + json.dumps(tmp_json, indent=4, sort_keys=False) + prefix_end
50
51
        count_row = 0
52
        rule_name = 'xccdforgssgprojectcontentrulepackageabrtremoved'
53
        for row in reference_pattern:
54
            if row in data_in_html or rule_name in row:
55
                count_row += 1
56
        assert count_row == len(reference_pattern)
57
58
    @staticmethod
59
    def get_data_json(src):

tests/any_test_help.py 1 location

@@ 152-175 (lines=24) @@
149
    return str(FIXTURE_DIR)
150
151
152
def compare_results_html(result):
153
    result_ = any_get_tested_file(result)
154
    reference_pattern = any_get_tested_file(
155
        'test_data/referenc_pattern_html_report.txt')
156
    prefix_start = '<script>var data_of_tree = '
157
    prefix_end = ';</script><div>\n'
158
    data_in_html = ""
159
    matched = False
160
    for row in result_:
161
        if prefix_start in row and prefix_end in row:
162
            matched = True
163
            data_in_html = row
164
    assert matched
165
166
    tmp_json_str = data_in_html.replace(prefix_start, '').replace(prefix_end, '')
167
    tmp_json = json.loads(tmp_json_str)
168
    data_in_html = prefix_start + json.dumps(tmp_json, indent=4, sort_keys=False) + prefix_end
169
170
    count_row = 0
171
    rule_name = 'xccdforgssgprojectcontentrulepackageabrtremoved'
172
    for row in reference_pattern:
173
        if row in data_in_html or rule_name in row:
174
            count_row += 1
175
    assert count_row == len(reference_pattern)
176
177
178
def compare_results_json(result):