~barry/ubuntu-system-image/lp1365646

« back to all changes in this revision

Viewing changes to systemimage/testing/service.py

  • Committer: Barry Warsaw
  • Date: 2014-08-08 19:06:47 UTC
  • Revision ID: barry@python.org-20140808190647-qhx3evptw0sbi0d2
Boost coverage numbers in several ways:

* Sprinkle "pragma: no cover" comments in places where we do not expect the
  test suite to cover, e.g. asserts, non-test-paths, "virtual" methods,
  reprs.

* Add a few tests for legitimately missed sections.

Remove testing infrastructure from the foreground process.  Now we only need
specific programmatic coverage invocation in the D-Bus activated subprocess.
For the foreground process, invoke the test suite using the python3-coverage
script via the tox.ini file.

tox.ini always recreates the environment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
collection as early as possible in the private bus D-Bus activated processes.
20
20
"""
21
21
 
 
22
import os
 
23
 
 
24
# It's okay if this module isn't available.
 
25
try:
 
26
    from coverage.control import coverage as _Coverage
 
27
except ImportError:
 
28
    _Coverage = None
 
29
 
 
30
 
22
31
def main():
23
 
    # All imports happen here so that we have the best possible chance of
24
 
    # instrumenting all relevant code.
25
 
    from systemimage.testing.nose import Coverage
26
 
    Coverage().start()
 
32
    # Enable code coverage.
 
33
    ini_file = os.environ.get('COVERAGE_PROCESS_START')
 
34
    if _Coverage is not None and ini_file is not None:
 
35
        coverage =_Coverage(config_file=ini_file, auto_data=True)
 
36
        # Stolen from coverage.process_startup()
 
37
        coverage.erase()
 
38
        coverage.start()
 
39
        coverage._warn_no_data = False
 
40
        coverage._warn_unimported_source = False
 
41
    # All systemimage imports happen here so that we have the best possible
 
42
    # chance of instrumenting all relevant code.
 
43
    from systemimage.service import main as real_main
27
44
    # Now run the actual D-Bus service.
28
 
    from systemimage.service import main
29
 
    return main()
 
45
    return real_main()
30
46
 
31
47
 
32
48
if __name__ == '__main__':