forked from archived-codacy/python-codacy-coverage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
72 lines (46 loc) · 2.16 KB
/
Copy pathtests.py
File metadata and controls
72 lines (46 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import json
import os
import unittest
import codacy.reporter
HERE = os.path.abspath(os.path.dirname(__file__))
def _file_location(*args):
return os.path.join(HERE, *args)
class ReporterTests(unittest.TestCase):
def compare_parse_result(self, generated, expected_filename):
def file_get_contents(filename):
with open(filename) as f:
return f.read()
json_content = file_get_contents(expected_filename)
expected = json.loads(json_content)
self.assertEqual(generated, expected)
def test_parser_coverage3(self):
self.maxDiff = None
parsed = codacy.reporter.parse_report_file(
_file_location('coverage3', 'cobertura.xml'), '')
rounded = codacy.reporter.merge_and_round_reports([parsed])
self.compare_parse_result(rounded,
_file_location('coverage3', 'coverage.json'))
def test_parser_coverage4(self):
self.maxDiff = None
parsed = codacy.reporter.parse_report_file(
_file_location('coverage4', 'cobertura.xml'), '')
rounded = codacy.reporter.merge_and_round_reports([parsed])
self.compare_parse_result(rounded,
_file_location('coverage4', 'coverage.json'))
def test_parser_git_filepath(self):
self.maxDiff = None
parsed = codacy.reporter.parse_report_file(
_file_location('filepath', 'cobertura.xml.tpl'), '')
rounded = codacy.reporter.merge_and_round_reports([parsed])
self.compare_parse_result(rounded,
_file_location('filepath', 'coverage.json'))
def test_merge(self):
self.maxDiff = None
generated3 = codacy.reporter.parse_report_file(
_file_location('coverage-merge', 'cobertura.3.xml'), '')
generated4 = codacy.reporter.parse_report_file(
_file_location('coverage-merge', 'cobertura.4.xml'), '')
result = codacy.reporter.merge_and_round_reports([generated3, generated4])
self.compare_parse_result(result, _file_location('coverage-merge', 'coverage-merge.json'))
if __name__ == '__main__':
unittest.main()