-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_make_badge.py
More file actions
33 lines (29 loc) · 899 Bytes
/
test_make_badge.py
File metadata and controls
33 lines (29 loc) · 899 Bytes
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
import os
from unittest import TestCase
import make_badge
import tempfile
class Test(TestCase):
def test_run(self):
with tempfile.TemporaryDirectory() as d:
# Does the CWD get reset after this test? NO!!
# Changing the CWD causes later tests to fail with very non-obvious errors
# from pytest.
cwd = os.getcwd()
try:
os.chdir(d)
print("a")
with open("coverage.txt", "w") as f:
f.write("15%")
print("b")
make_badge.run()
with open("code-coverage.txt") as f:
blob = f.read()
finally:
os.chdir(cwd)
expected ="""{
"schemaVersion": 1,
"label": "coverage",
"message": "15%",
"color": "orange"
}"""
self.assertEqual(expected, blob)