forked from please-build/python-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_coverage_test.py
More file actions
33 lines (26 loc) · 1.24 KB
/
Copy pathpython_coverage_test.py
File metadata and controls
33 lines (26 loc) · 1.24 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
import sys
import unittest
class PythonCoverageTest(unittest.TestCase):
"""Tests that we can import parts of the coverage module.
By default it's not trivial to import binary modules from inside a pex. Also we need to package
relevant versions of the tracer module, which can't work for every OS, but it'd be nice to
cover at least a few since it improves performance quite a bit.
"""
@classmethod
def setUpClass(cls):
"""Must ensure coverage is set up before we can import tracer."""
import __main__ as test_main
test_main.initialise_coverage()
def test_can_import_coverage(self):
"""Test we can import the coverage module OK."""
import coverage
self.assertIsNotNone(coverage)
@unittest.skipIf(sys.platform.startswith("freebsd"), "built-in test runners do not contain a tracer module compatible with this platform")
def test_can_import_tracer(self):
"""Test we can import the binary tracer module."""
from coverage import tracer
self.assertIsNotNone(tracer)
def test_coverage_output(self):
"""Test for manually examining coverage output."""
from test.python_coverage import the_answer
self.assertEqual(42, the_answer())