summaryrefslogtreecommitdiff
path: root/tests/test_report.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-10-26 19:07:03 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-10-26 19:17:19 -0400
commit93c9ca9f1b2e5d0b45dbf4b82c77aaf05b458bac (patch)
tree6b0e1cc009da5e33ca87e8fb096704b27afe1a8f /tests/test_report.py
parent18cf3b897d4b1e1a66beda180ec151cc0dd4dbc3 (diff)
downloadpython-coveragepy-git-93c9ca9f1b2e5d0b45dbf4b82c77aaf05b458bac.tar.gz
feat: xml and json say what they are doing, and -q quiets everything. #1254nedbat/dashq
Diffstat (limited to 'tests/test_report.py')
-rw-r--r--tests/test_report.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/test_report.py b/tests/test_report.py
index 1a9dd179..7d6f55af 100644
--- a/tests/test_report.py
+++ b/tests/test_report.py
@@ -13,6 +13,8 @@ from tests.coveragetest import CoverageTest
class FakeReporter:
"""A fake implementation of a one-file reporter."""
+ report_type = "fake report file"
+
def __init__(self, output="", error=False):
self.output = output
self.error = error
@@ -31,20 +33,26 @@ class RenderReportTest(CoverageTest):
def test_stdout(self):
fake = FakeReporter(output="Hello!\n")
- render_report("-", fake, [pytest, "coverage"])
+ msgs = []
+ render_report("-", fake, [pytest, "coverage"], msgs.append)
assert fake.morfs == [pytest, "coverage"]
assert self.stdout() == "Hello!\n"
+ assert msgs == []
def test_file(self):
fake = FakeReporter(output="Gréètings!\n")
- render_report("output.txt", fake, [])
+ msgs = []
+ render_report("output.txt", fake, [], msgs.append)
assert self.stdout() == ""
with open("output.txt", "rb") as f:
- assert f.read() == b"Gr\xc3\xa9\xc3\xa8tings!\n"
+ assert f.read().rstrip() == b"Gr\xc3\xa9\xc3\xa8tings!"
+ assert msgs == ["Wrote fake report file to output.txt"]
def test_exception(self):
fake = FakeReporter(error=True)
+ msgs = []
with pytest.raises(CoverageException, match="You asked for it!"):
- render_report("output.txt", fake, [])
+ render_report("output.txt", fake, [], msgs.append)
assert self.stdout() == ""
self.assert_doesnt_exist("output.txt")
+ assert msgs == []