]> granicus.if.org Git - python/commitdiff
support for checking test coverage added.
authorŁukasz Langa <lukasz@langa.pl>
Sat, 4 Dec 2010 13:48:13 +0000 (13:48 +0000)
committerŁukasz Langa <lukasz@langa.pl>
Sat, 4 Dec 2010 13:48:13 +0000 (13:48 +0000)
70% coverage at the moment (not tragic but needs work).

Lib/test/test_cfgparser.py

index 24158ad104b7728dfe1cdc005a520f1b59b877d4..2ea80dcd6c3ba0067ad35a4847c7e15f0ced2a59 100644 (file)
@@ -2,8 +2,9 @@ import collections
 import configparser
 import io
 import os
-import unittest
+import sys
 import textwrap
+import unittest
 import warnings
 
 from test import support
@@ -1084,6 +1085,17 @@ def test_main():
         ConfigParserTestCaseNonStandardDefaultSection,
         )
 
+def test_coverage(coverdir):
+    trace = support.import_module('trace')
+    tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0,
+                       count=1)
+    tracer.run('test_main()')
+    r=tracer.results()
+    print("Writing coverage results...")
+    r.write_results(show_missing=True, summary=True, coverdir=coverdir)
 
 if __name__ == "__main__":
-    test_main()
+    if "-c" in sys.argv:
+        test_coverage('/tmp/cmd.cover')
+    else:
+        test_main()