[Checkins] SVN: zope.monkeypatches.doctest/trunk/ Python 3.1 support.
Lennart Regebro
regebro at gmail.com
Fri Apr 30 10:39:20 EDT 2010
Log message for revision 111634:
Python 3.1 support.
Changed:
U zope.monkeypatches.doctest/trunk/setup.py
U zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/README.txt
U zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/__init__.py
-=-
Modified: zope.monkeypatches.doctest/trunk/setup.py
===================================================================
--- zope.monkeypatches.doctest/trunk/setup.py 2010-04-30 14:35:05 UTC (rev 111633)
+++ zope.monkeypatches.doctest/trunk/setup.py 2010-04-30 14:39:20 UTC (rev 111634)
@@ -17,6 +17,8 @@
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.1",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
],
Modified: zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/README.txt
===================================================================
--- zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/README.txt 2010-04-30 14:35:05 UTC (rev 111633)
+++ zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/README.txt 2010-04-30 14:39:20 UTC (rev 111634)
@@ -6,7 +6,11 @@
around those bugs other ways.
It achieves the bugfixing via monkey-patches, which is horrid, so in general
-it's better if you don't use this product.
+it's better if you don't use this product. Of these bugs, the unicode bug
+is not relevant and the Windows lineending bug seems to be fixed. The
+report flag issue is an issue in Python 3, and this module will run under
+Python 3.1 and fix that issue. However, the tests will fail. This may or
+may not change in the future. :)
Bugfix: Unicode output
----------------------
@@ -41,7 +45,7 @@
>>> import tempfile
>>> import os
>>> fd, fn = tempfile.mkstemp()
- >>> f = os.fdopen(fd, 'wb')
+ >>> f = os.fdopen(fd, 'w')
>>> f.write('Test:\r\n\r\n >>> x = 1 + 1\r\n\r\nDone.\r\n')
>>> f.close()
Modified: zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/__init__.py
===================================================================
--- zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/__init__.py 2010-04-30 14:35:05 UTC (rev 111633)
+++ zope.monkeypatches.doctest/trunk/zope/monkeypatches/doctest/__init__.py 2010-04-30 14:39:20 UTC (rev 111634)
@@ -1,39 +1,46 @@
# Patch to fix an error that makes subsequent tests fail after you have
# returned unicode in a test.
import doctest
+import sys
-_org_SpoofOut = doctest._SpoofOut
-class _patched_SpoofOut(_org_SpoofOut):
- def truncate(self, size=None):
- _org_SpoofOut.truncate(self, size)
- if not self.buf:
- self.buf = ''
+if sys.version < '3': # This is obviously not an issue in Python 3
+ _org_SpoofOut = doctest._SpoofOut
+ class _patched_SpoofOut(_org_SpoofOut):
+ def truncate(self, size=None):
+ _org_SpoofOut.truncate(self, size)
+ if not self.buf:
+ self.buf = ''
+
+ doctest._SpoofOut = _patched_SpoofOut
-doctest._SpoofOut = _patched_SpoofOut
+if sys.version < '3': # This bug seems fixed in Python 3:
-# Patch to fix tests that has mixed line endings:
-import os
+ # Patch to fix tests that has mixed line endings:
+ import os
+
+ def _patched_load_testfile(filename, package, module_relative):
+ if module_relative:
+ package = doctest._normalize_module(package, 3)
+ filename = doctest._module_relative_path(package, filename)
+ if hasattr(package, '__loader__'):
+ if hasattr(package.__loader__, 'get_data'):
+ file_contents = package.__loader__.get_data(filename)
+ # get_data() opens files as 'rb', so one must do the equivalent
+ # conversion as universal newlines would do.
+ return file_contents.replace(os.linesep, '\n'), filename
+ return open(filename, 'rU').read(), filename
+
+ doctest._load_testfile = _patched_load_testfile
-def _patched_load_testfile(filename, package, module_relative):
- if module_relative:
- package = doctest._normalize_module(package, 3)
- filename = doctest._module_relative_path(package, filename)
- if hasattr(package, '__loader__'):
- if hasattr(package.__loader__, 'get_data'):
- file_contents = package.__loader__.get_data(filename)
- # get_data() opens files as 'rb', so one must do the equivalent
- # conversion as universal newlines would do.
- return file_contents.replace(os.linesep, '\n'), filename
- return open(filename, 'rU').read(), filename
-doctest._load_testfile = _patched_load_testfile
-
-
# Patch so you can set REPORT_ONLY_FIRST_FAILURE even if you have a DIFF flag
# on the test.
import sys
-from StringIO import StringIO
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO
def _patched_runTest(self):
test = self._dt_test
More information about the checkins
mailing list