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
50 lines (30 loc) · 1.34 KB
/
Copy pathtests.py
File metadata and controls
50 lines (30 loc) · 1.34 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
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_filename, expected_filename):
def file_get_contents(filename):
with open(filename) as f:
return f.read()
generated = codacy.reporter.parse_report_file(generated_filename, '')
json_content = file_get_contents(expected_filename)
expected = json.loads(json_content)
self.assertEqual(generated, expected)
def test_parser_coverage3(self):
self.maxDiff = None
self.compare_parse_result(_file_location('coverage3', 'cobertura.xml'),
_file_location('coverage3', 'coverage.json'))
def test_parser_coverage4(self):
self.maxDiff = None
self.compare_parse_result(_file_location('coverage4', 'cobertura.xml'),
_file_location('coverage4', 'coverage.json'))
def test_parser_git_filepath(self):
self.maxDiff = None
self.compare_parse_result(_file_location('filepath', 'cobertura.xml.tpl'),
_file_location('filepath', 'coverage.json'))
if __name__ == '__main__':
unittest.main()