[Jython-checkins] jython: Reapplied Jython-specific changes to doctest.py
frank.wierzbicki
jython-checkins at python.org
Wed Mar 14 04:09:31 CET 2012
http://hg.python.org/jython/rev/aaf9d8a9b1e5
changeset: 6343:aaf9d8a9b1e5
user: Alex Grönholm <alex.gronholm at nextday.fi>
date: Tue Mar 13 13:20:33 2012 -0700
summary:
Reapplied Jython-specific changes to doctest.py
files:
Lib/doctest.py | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Lib/doctest.py b/Lib/doctest.py
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -882,6 +882,12 @@
elif inspect.isfunction(object):
return module.__dict__ is object.func_globals
elif inspect.isclass(object):
+ # XXX: Jython transition 2.5
+ # Java classes appear as Python classes to inspect, but they
+ # have no __module__ http://jython.org/bugs/1758279
+ # org.python.modules uses Java classes to masq
+ if not hasattr(object, '__module__'):
+ return False
return module.__name__ == object.__module__
elif hasattr(object, '__module__'):
return module.__name__ == object.__module__
@@ -987,6 +993,8 @@
filename = getattr(module, '__file__', module.__name__)
if filename[-4:] in (".pyc", ".pyo"):
filename = filename[:-1]
+ elif filename.endswith('$py.class'):
+ filename = '%s.py' % filename[:-9]
return self._parser.get_doctest(docstring, globs, name,
filename, lineno)
@@ -1703,7 +1711,8 @@
If a failure or error occurs, the globals are left intact:
- >>> del test.globs['__builtins__']
+ >>> if '__builtins__' in test.globs:
+ ... del test.globs['__builtins__']
>>> test.globs
{'x': 1}
@@ -1717,7 +1726,8 @@
...
UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>
- >>> del test.globs['__builtins__']
+ >>> if '__builtins__' in test.globs:
+ ... del test.globs['__builtins__']
>>> test.globs
{'x': 2}
@@ -2337,6 +2347,8 @@
filename = module.__file__
if filename[-4:] in (".pyc", ".pyo"):
filename = filename[:-1]
+ elif filename.endswith('$py.class'):
+ filename = '%s.py' % filename[:-9]
test.filename = filename
suite.addTest(DocTestCase(test, **options))
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list