[Zope3-checkins] SVN: zope.testing/trunk/ - Open doctest files in universal mode, so that packages released in Windoes

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Aug 27 03:41:01 EDT 2008


Log message for revision 90401:
  - Open doctest files in universal mode, so that packages released in Windoes
    can be tested in Linux, for example.
  
  - Fixed failing test in testrunner-coverage.txt.
  --This line, and those 
  below, 
  will be ignored--
  
  AM   src/zope/testing/doctest.txt
  M    src/zope/testing/tests.py
  M    src/zope/testing/doctest.py
  M    src/zope/testing/testrunner/testrunner-coverage.txt
  M    README.txt
  

Changed:
  U   zope.testing/trunk/README.txt
  U   zope.testing/trunk/src/zope/testing/doctest.py
  A   zope.testing/trunk/src/zope/testing/doctest.txt
  U   zope.testing/trunk/src/zope/testing/testrunner/testrunner-coverage.txt
  U   zope.testing/trunk/src/zope/testing/tests.py

-=-
Modified: zope.testing/trunk/README.txt
===================================================================
--- zope.testing/trunk/README.txt	2008-08-27 07:27:11 UTC (rev 90400)
+++ zope.testing/trunk/README.txt	2008-08-27 07:41:00 UTC (rev 90401)
@@ -63,6 +63,8 @@
 
 - Fixed NameError in StartUpFailure.
 
+- Open doctest files in universal mode, so that packages released in Windoes
+  can be tested in Linux, for example.
 
 
 3.6.0 (2008/07/10)

Modified: zope.testing/trunk/src/zope/testing/doctest.py
===================================================================
--- zope.testing/trunk/src/zope/testing/doctest.py	2008-08-27 07:27:11 UTC (rev 90400)
+++ zope.testing/trunk/src/zope/testing/doctest.py	2008-08-27 07:41:00 UTC (rev 90401)
@@ -2074,7 +2074,7 @@
         runner = DocTestRunner(verbose=verbose, optionflags=optionflags)
 
     # Read the file, convert it to a test, and run it.
-    s = open(filename).read()
+    s = open(filename, 'U').read()
     if encoding is None:
         encoding = pep263_encoding(s)
     if encoding is not None:
@@ -2517,7 +2517,7 @@
 
     # Find the file and read it.
     name = os.path.basename(path)
-    doc = open(path).read()
+    doc = open(path, 'U').read()
 
     # If an encoding is specified, use it to convert the file to unicode
     if encoding is None:

Added: zope.testing/trunk/src/zope/testing/doctest.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/doctest.txt	                        (rev 0)
+++ zope.testing/trunk/src/zope/testing/doctest.txt	2008-08-27 07:41:00 UTC (rev 90401)
@@ -0,0 +1,32 @@
+========================
+Additional doctest Tests
+========================
+
+Most `doctest` module tests are located within the module. This file only
+tests a few additional features not covered by the module tests, so that the
+changes to the `doctest` module -- which is forked from the Python stanadrd
+library -- are minimized.
+
+Working with Carriage Returns
+-----------------------------
+
+Due to the way releases are made on different platforms, we sometimes test
+files on a *nix system with Windows file endings. Unfortunately, that leaves
+some the tests broken:
+
+  >>> import tempfile
+  >>> fn = tempfile.mktemp()
+  >>> open(fn, 'w').write('Test:\r\n\r\n  >>> x = 1 + 1\r\n\r\nDone.\r\n')
+
+Let's now run it as a doctest:
+
+  >>> from zope.testing import doctest
+  >>> doctest.testfile(fn, False)
+  (0, 1)
+
+It worked. Let's also try the test file suite:
+
+  >>> import unittest
+  >>> result = unittest.TestResult()
+  >>> doctest.DocFileSuite(fn, module_relative=False).run(result)
+  <unittest.TestResult run=1 errors=0 failures=0>


Property changes on: zope.testing/trunk/src/zope/testing/doctest.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: zope.testing/trunk/src/zope/testing/testrunner/testrunner-coverage.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/testrunner-coverage.txt	2008-08-27 07:27:11 UTC (rev 90400)
+++ zope.testing/trunk/src/zope/testing/testrunner/testrunner-coverage.txt	2008-08-27 07:41:00 UTC (rev 90401)
@@ -52,32 +52,41 @@
     Tearing down left over layers:
       Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds.
     lines   cov%   module   (path)
-       82    78%   sample1.sample11.sampletests   (testrunner-ex\sample1\sample11\sampletests.py)
-       52    92%   sample1.sample13.sampletests   (testrunner-ex\sample1\sample13\sampletests.py)
-       52    92%   sample1.sampletests.test1   (testrunner-ex\sample1\sampletests\test1.py)
-       78    94%   sample1.sampletests.test11   (testrunner-ex\sample1\sampletests\test11.py)
-       78    94%   sample1.sampletests.test111   (testrunner-ex\sample1\sampletests\test111.py)
-       78    94%   sample1.sampletests.test112   (testrunner-ex\sample1\sampletests\test112.py)
-       78    94%   sample1.sampletests.test12   (testrunner-ex\sample1\sampletests\test12.py)
-       78    94%   sample1.sampletests.test121   (testrunner-ex\sample1\sampletests\test121.py)
-       78    94%   sample1.sampletests.test122   (testrunner-ex\sample1\sampletests\test122.py)
-       52    92%   sample1.sampletests.test_one   (testrunner-ex\sample1\sampletests\test_one.py)
-       52    92%   sample1.sampletestsf   (testrunner-ex\sample1\sampletestsf.py)
-       52    92%   sample2.sample21.sampletests   (testrunner-ex\sample2\sample21\sampletests.py)
-       52    92%   sample2.sampletests.test_1   (testrunner-ex\sample2\sampletests\test_1.py)
-       52    92%   sample2.sampletests.testone   (testrunner-ex\sample2\sampletests\testone.py)
-       52    92%   sample3.sampletests   (testrunner-ex\sample3\sampletests.py)
-       96    75%   samplelayers   (testrunner-ex\samplelayers.py)
-       52    92%   sampletests.test1   (testrunner-ex\sampletests\test1.py)
-       78    94%   sampletests.test11   (testrunner-ex\sampletests\test11.py)
-       78    94%   sampletests.test111   (testrunner-ex\sampletests\test111.py)
-       80    95%   sampletests.test112   (testrunner-ex\sampletests\test112.py)
-       78    94%   sampletests.test12   (testrunner-ex\sampletests\test12.py)
-       78    94%   sampletests.test121   (testrunner-ex\sampletests\test121.py)
-       78    94%   sampletests.test122   (testrunner-ex\sampletests\test122.py)
-       52    92%   sampletests.test_one   (testrunner-ex\sampletests\test_one.py)
-      122    87%   sampletestsf   (testrunner-ex\sampletestsf.py)
-    Total: 405 tests, 0 failures, 0 errors in 1.641 seconds.
+        1   100%   sample1.__init__   (testrunner-ex/sample1/__init__.py)
+        1   100%   sample1.sample11.__init__   (testrunner-ex/sample1/sample11/__init__.py)
+       74    86%   sample1.sample11.sampletests   (testrunner-ex/sample1/sample11/sampletests.py)
+        1   100%   sample1.sample13.__init__   (testrunner-ex/sample1/sample13/__init__.py)
+       48   100%   sample1.sample13.sampletests   (testrunner-ex/sample1/sample13/sampletests.py)
+        1   100%   sample1.sampletests.__init__   (testrunner-ex/sample1/sampletests/__init__.py)
+       48   100%   sample1.sampletests.test1   (testrunner-ex/sample1/sampletests/test1.py)
+       74   100%   sample1.sampletests.test11   (testrunner-ex/sample1/sampletests/test11.py)
+       74   100%   sample1.sampletests.test111   (testrunner-ex/sample1/sampletests/test111.py)
+       74   100%   sample1.sampletests.test112   (testrunner-ex/sample1/sampletests/test112.py)
+       74   100%   sample1.sampletests.test12   (testrunner-ex/sample1/sampletests/test12.py)
+       74   100%   sample1.sampletests.test121   (testrunner-ex/sample1/sampletests/test121.py)
+       74   100%   sample1.sampletests.test122   (testrunner-ex/sample1/sampletests/test122.py)
+       48   100%   sample1.sampletests.test_one   (testrunner-ex/sample1/sampletests/test_one.py)
+       48   100%   sample1.sampletestsf   (testrunner-ex/sample1/sampletestsf.py)
+        1   100%   sample2.__init__   (testrunner-ex/sample2/__init__.py)
+        1   100%   sample2.sample21.__init__   (testrunner-ex/sample2/sample21/__init__.py)
+       48   100%   sample2.sample21.sampletests   (testrunner-ex/sample2/sample21/sampletests.py)
+        1   100%   sample2.sampletests.__init__   (testrunner-ex/sample2/sampletests/__init__.py)
+       48   100%   sample2.sampletests.test_1   (testrunner-ex/sample2/sampletests/test_1.py)
+       48   100%   sample2.sampletests.testone   (testrunner-ex/sample2/sampletests/testone.py)
+        1   100%   sample3.__init__   (testrunner-ex/sample3/__init__.py)
+       48   100%   sample3.sampletests   (testrunner-ex/sample3/sampletests.py)
+       84    85%   samplelayers   (testrunner-ex/samplelayers.py)
+        1   100%   sampletests.__init__   (testrunner-ex/sampletests/__init__.py)
+       48   100%   sampletests.test1   (testrunner-ex/sampletests/test1.py)
+       74   100%   sampletests.test11   (testrunner-ex/sampletests/test11.py)
+       74   100%   sampletests.test111   (testrunner-ex/sampletests/test111.py)
+       76   100%   sampletests.test112   (testrunner-ex/sampletests/test112.py)
+       74   100%   sampletests.test12   (testrunner-ex/sampletests/test12.py)
+       74   100%   sampletests.test121   (testrunner-ex/sampletests/test121.py)
+       74   100%   sampletests.test122   (testrunner-ex/sampletests/test122.py)
+       48   100%   sampletests.test_one   (testrunner-ex/sampletests/test_one.py)
+      112    95%   sampletestsf   (testrunner-ex/sampletestsf.py)
+    Total: 405 tests, 0 failures, 0 errors in 0.630 seconds.
     False
 
 The directory specified with the --coverage option will have been created and

Modified: zope.testing/trunk/src/zope/testing/tests.py
===================================================================
--- zope.testing/trunk/src/zope/testing/tests.py	2008-08-27 07:27:11 UTC (rev 90400)
+++ zope.testing/trunk/src/zope/testing/tests.py	2008-08-27 07:41:00 UTC (rev 90401)
@@ -23,10 +23,11 @@
 
 def test_suite():
     return unittest.TestSuite((
+        doctest.DocTestSuite('zope.testing.loggingsupport'),
         doctest.DocTestSuite('zope.testing.renormalizing'),
+        doctest.DocTestSuite('zope.testing.server'),
+        doctest.DocFileSuite('doctest.txt'),
         doctest.DocFileSuite('formparser.txt'),
-        doctest.DocTestSuite('zope.testing.loggingsupport'),
-        doctest.DocTestSuite('zope.testing.server'),
+        doctest.DocFileSuite('module.txt'),
         doctest.DocFileSuite('setupstack.txt'),
-        doctest.DocFileSuite('module.txt'),
         ))



More information about the Zope3-Checkins mailing list