Commits

Ned Batchelder committed 4768d7c

CodeParser couldn't deal with being passed the text directly.

  • Participants
  • Parent commits 736e8b5

Comments (0)

Files changed (3)

     - parser is doing some redundant work.
 - while TRUE claims to be partial?
 - Analysis class should do rolling up of stats also.
+- Update docs for --branch.
 
 
 * Speed
 
 + Switch to a real test runner, like nose.
 + Test both the C trace function and the Python trace function.
+- parser.py has no direct tests.
 - Tests about the .coverage file.
 + Tests about the --long-form of arguments.
 + Tests about overriding the .coverage filename.

File coverage/parser.py

         """
         assert text or filename, "CodeParser needs either text or filename"
         self.filename = filename or "<code>"
-        if not text:
+        self.text = text
+        if not self.text:
             try:
                 sourcef = open(self.filename, 'rU')
                 self.text = sourcef.read()

File test/test_coverage.py

 # Copyright 2004-2009, Ned Batchelder
 # http://nedbatchelder.com/code/coverage
 
-import os, sys, unittest
+import os, re, sys, unittest
 
 import coverage
 coverage.use_cache(0)
         # ---------------------------------------------------------------------
         # TOTAL                                                 8      8   100%
 
+        self.assert_("error" not in report1.lower())
         self.assert_("/coverage/__init__/" not in report1)
         self.assert_("/test/modules/covmod1 " in report1)
         self.assert_("/test/zipmods.zip/covmodzip1 " in report1)
         self.assert_("mycode " in report1)
+        self.assertEqual(re.sub(r"\s+", " ", report1.split('\n')[-2]), "TOTAL 8 8 100%")
 
         for l in report1.split('\n'):
             if '/test/modules/covmod1' in l:
         # ----------------------------
         # mycode       4      4   100%
 
+        self.assert_("error" not in report2.lower())
         self.assert_("/coverage/" not in report2)
         self.assert_("/test/modules/covmod1 " not in report2)
         self.assert_("/test/zipmods.zip/covmodzip1 " not in report2)
         # ----------------------------
         # mycode       4      4   100%
 
+        self.assert_("error" not in report3.lower())
         self.assert_("/coverage/" not in report3)
         self.assert_("/test/modules/covmod1 " not in report3)
         self.assert_("/test/zipmods.zip/covmodzip1 " not in report3)