[Checkins] SVN: zope.testrunner/trunk/s Yet another port of the testrunner to python 3. This one looks good, I don't think I messed anything up now. There are two extremely obscure test failures left, though.
Lennart Regebro
regebro at gmail.com
Wed Apr 28 18:26:39 EDT 2010
Log message for revision 111557:
Yet another port of the testrunner to python 3. This one looks good, I don't think I messed anything up now. There are two extremely obscure test failures left, though.
Changed:
U zope.testrunner/trunk/setup.py
U zope.testrunner/trunk/src/zope/testrunner/debug.py
U zope.testrunner/trunk/src/zope/testrunner/find.py
U zope.testrunner/trunk/src/zope/testrunner/formatter.py
U zope.testrunner/trunk/src/zope/testrunner/options.py
U zope.testrunner/trunk/src/zope/testrunner/process.py
U zope.testrunner/trunk/src/zope/testrunner/runner.py
U zope.testrunner/trunk/src/zope/testrunner/tb_format.py
U zope.testrunner/trunk/src/zope/testrunner/testrunner-colors.txt
U zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test
U zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt
U zope.testrunner/trunk/src/zope/testrunner/testrunner-edge-cases.txt
U zope.testrunner/trunk/src/zope/testrunner/testrunner-errors.txt
U zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/pledge.py
U zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/sample3/sampletests_d.py
D zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/unicode.txt
U zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-api.txt
U zope.testrunner/trunk/src/zope/testrunner/testrunner-progress.txt
-=-
Modified: zope.testrunner/trunk/setup.py
===================================================================
--- zope.testrunner/trunk/setup.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/setup.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -30,39 +30,35 @@
setup_requires = ['zope.fixers'],
use_2to3_fixers = ['zope.fixers'],
convert_2to3_doctests = [
- 'src/zope/testing/doctests.txt',
- 'src/zope/testing/formparser.txt',
- 'src/zope/testing/module.txt',
- 'src/zope/testing/setupstack.txt',
- 'src/zope/testing/testrunner/testrunner-arguments.txt',
- 'src/zope/testing/testrunner/testrunner-coverage-win32.txt',
- 'src/zope/testing/testrunner/testrunner-coverage.txt',
- 'src/zope/testing/testrunner/testrunner-debugging-layer-setup.test',
- 'src/zope/testing/testrunner/testrunner-debugging.txt',
- 'src/zope/testing/testrunner/testrunner-discovery',
- 'src/zope/testing/testrunner/testrunner-edge-cases.txt',
- 'src/zope/testing/testrunner/testrunner-errors.txt',
- 'src/zope/testing/testrunner/testrunner-gc.txt',
- 'src/zope/testing/testrunner/testrunner-knit.txt',
- 'src/zope/testing/testrunner/testrunner-layers-api.txt',
- 'src/zope/testing/testrunner/testrunner-layers-buff.txt',
- 'src/zope/testing/testrunner/testrunner-layers-ntd.txt',
- 'src/zope/testing/testrunner/testrunner-layers.txt',
- 'src/zope/testing/testrunner/testrunner-leaks-err.txt',
- 'src/zope/testing/testrunner/testrunner-leaks.txt',
- 'src/zope/testing/testrunner/testrunner-profiling-cprofiler.txt',
- 'src/zope/testing/testrunner/testrunner-profiling.txt',
- 'src/zope/testing/testrunner/testrunner-progress.txt',
- 'src/zope/testing/testrunner/testrunner-repeat.txt',
- 'src/zope/testing/testrunner/testrunner-simple.txt',
- 'src/zope/testing/testrunner/testrunner-tb-format.txt',
- 'src/zope/testing/testrunner/testrunner-test-selection.txt',
- 'src/zope/testing/testrunner/testrunner-verbose.txt',
- 'src/zope/testing/testrunner/testrunner-wo-source.txt',
- 'src/zope/testing/testrunner/testrunner.txt',
- 'src/zope/testing/testrunner/testrunner-ex/sampletests.txt',
- 'src/zope/testing/testrunner/testrunner-ex/sampletestsl.txt',
- 'src/zope/testing/testrunner/testrunner-ex/unicode.txt',
+ 'src/zope/testrunner/testrunner-arguments.txt',
+ 'src/zope/testrunner/testrunner-coverage-win32.txt',
+ 'src/zope/testrunner/testrunner-coverage.txt',
+ 'src/zope/testrunner/testrunner-debugging-layer-setup.test',
+ 'src/zope/testrunner/testrunner-debugging.txt',
+ 'src/zope/testrunner/testrunner-discovery',
+ 'src/zope/testrunner/testrunner-edge-cases.txt',
+ 'src/zope/testrunner/testrunner-errors.txt',
+ 'src/zope/testrunner/testrunner-gc.txt',
+ 'src/zope/testrunner/testrunner-knit.txt',
+ 'src/zope/testrunner/testrunner-layers-api.txt',
+ 'src/zope/testrunner/testrunner-layers-buff.txt',
+ 'src/zope/testrunner/testrunner-layers-ntd.txt',
+ 'src/zope/testrunner/testrunner-layers.txt',
+ 'src/zope/testrunner/testrunner-leaks-err.txt',
+ 'src/zope/testrunner/testrunner-leaks.txt',
+ 'src/zope/testrunner/testrunner-profiling-cprofiler.txt',
+ 'src/zope/testrunner/testrunner-profiling.txt',
+ 'src/zope/testrunner/testrunner-progress.txt',
+ 'src/zope/testrunner/testrunner-repeat.txt',
+ 'src/zope/testrunner/testrunner-simple.txt',
+ 'src/zope/testrunner/testrunner-tb-format.txt',
+ 'src/zope/testrunner/testrunner-test-selection.txt',
+ 'src/zope/testrunner/testrunner-verbose.txt',
+ 'src/zope/testrunner/testrunner-wo-source.txt',
+ 'src/zope/testrunner/testrunner.txt',
+ 'src/zope/testrunner/testrunner-ex/sampletests.txt',
+ 'src/zope/testrunner/testrunner-ex/sampletestsl.txt',
+ 'src/zope/testrunner/testrunner-ex/unicode.txt',
],
dependency_links = ['.'],
)
@@ -93,7 +89,7 @@
import zope.testrunner
if __name__ == '__main__':
zope.testrunner.run([
- '--test-path', '%s',
+ '--test-path', '%s', '-c'
])
"""
import tempfile
@@ -153,7 +149,7 @@
long_description=long_description,
author='Zope Foundation and Contributors',
author_email='zope-dev at zope.org',
- packages=["zope", "zope.testrunner"],
+ packages=["zope", "zope.testrunner", "zope.testrunner.testrunner-ex"],
package_dir = {'': 'src'},
classifiers=[
"Development Status :: 5 - Production/Stable",
Modified: zope.testrunner/trunk/src/zope/testrunner/debug.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/debug.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/debug.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -46,7 +46,7 @@
except:
exc_info = sys.exc_info()
- print "%s:" % (exc_info[0], )
+ print "%s.%s:" % (exc_info[0].__module__, exc_info[0].__name__)
print exc_info[1]
pdb.post_mortem(exc_info[2])
raise zope.testrunner.interfaces.EndRun()
Modified: zope.testrunner/trunk/src/zope/testrunner/find.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/find.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/find.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -135,8 +135,8 @@
if package:
module_name = package + '.' + module_name
- for filter in options.module:
- if filter(module_name):
+ for filter_ in options.module:
+ if filter_(module_name):
break
else:
continue
Modified: zope.testrunner/trunk/src/zope/testrunner/formatter.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/formatter.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/formatter.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -378,12 +378,18 @@
# avoid reimporting a broken module in python 2.3
sys.modules['curses'] = None
else:
+ # If sys.stdout is not a real file object (e.g. in unit tests that
+ # use various wrappers), you get an error, different depending on
+ # Python version:
+ if sys.version_info >= (3,):
+ import io
+ expected_exceptions = (curses.error, TypeError, io.UnsupportedOperation)
+ else:
+ expected_exceptions = (curses.error, TypeError)
try:
curses.setupterm()
- except (curses.error, TypeError):
+ except expected_exceptions:
# You get curses.error when $TERM is set to an unknown name
- # You get TypeError when sys.stdout is not a real file object
- # (e.g. in unit tests that use various wrappers).
pass
else:
return curses.tigetnum(attr)
Modified: zope.testrunner/trunk/src/zope/testrunner/options.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/options.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/options.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -492,6 +492,8 @@
list_tests=False,
slow_test_threshold=10,
processes=1,
+ verbose=0,
+ repeat=1,
)
Modified: zope.testrunner/trunk/src/zope/testrunner/process.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/process.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/process.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -47,3 +47,5 @@
print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))
for test, exc_info in self.runner.errors:
print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))
+ # You need to flush in Python 3, and it doesn't hurt in Python 2:
+ self.original_stderr.flush()
Modified: zope.testrunner/trunk/src/zope/testrunner/runner.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/runner.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/runner.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -457,10 +457,16 @@
while nfail > 0:
nfail -= 1
- failures.append((erriter.next().strip(), None))
+ # Doing erriter.next().strip() confuses the 2to3 fixer, so
+ # we need to do it on a separate line:
+ next_fail = erriter.next()
+ failures.append((next_fail.strip(), None))
while nerr > 0:
nerr -= 1
- errors.append((erriter.next().strip(), None))
+ # Doing erriter.next().strip() confuses the 2to3 fixer, so
+ # we need to do it on a separate line:
+ next_err = erriter.next()
+ errors.append((next_err.strip(), None))
finally:
result.done = True
@@ -485,6 +491,8 @@
"""Keeps stdout around for later processing,"""
def write(self, out):
+ if not isinstance(out, str): # It's binary, which means it's Python 3
+ out = out.decode()
if not _is_dots(out):
self.stdout.append(out)
@@ -493,6 +501,11 @@
"""Sends complete output to queue."""
def write(self, out):
+ if not isinstance(out, str):
+ # In Python 3, a Popen process stdout uses bytes,
+ # While normal stdout uses strings. So we need to convert
+ # from bytes to strings here.
+ out = out.decode()
sys.stdout.write(out)
# Help keep-alive monitors (human or automated) keep up-to-date.
sys.stdout.flush()
@@ -511,6 +524,8 @@
done = property(lambda self: self._done, _set_done)
def write(self, out):
+ if not isinstance(out, str): # It's binary, which means it's Python 3
+ out = out.decode()
if _is_dots(out):
self.queue.put((self.layer_name, out.strip()))
else:
Modified: zope.testrunner/trunk/src/zope/testrunner/tb_format.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/tb_format.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/tb_format.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -22,16 +22,26 @@
import zope.testrunner.feature
-def format_exception(t, v, tb, limit=None):
+def format_exception(t, v, tb, limit=None, chain=None):
+ if chain:
+ values = traceback._iter_chain(v, tb)
+ else:
+ values = [(v, tb)]
fmt = zope.exceptions.exceptionformatter.TextExceptionFormatter(
limit=None, with_filenames=True)
- return fmt.formatException(t, v, tb)
+ for v, tb in values:
+ return fmt.formatException(t, v, tb)
-def print_exception(t, v, tb, limit=None, file=None):
+def print_exception(t, v, tb, limit=None, file=None, chain=None):
+ if chain:
+ values = traceback._iter_chain(v, tb)
+ else:
+ values = [(v, tb)]
if file is None:
file = sys.stdout
- file.writelines(format_exception(t, v, tb, limit))
+ for v, tb in values:
+ file.writelines(format_exception(t, v, tb, limit))
class Traceback(zope.testrunner.feature.Feature):
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-colors.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-colors.txt 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-colors.txt 2010-04-28 22:26:38 UTC (rev 111557)
@@ -117,7 +117,7 @@
Exception raised:
{red} Traceback (most recent call last):{normal}
{red} File ".../doctest.py", line 1356, in __run{normal}
- {red} compileflags, 1) in test.globs{normal}
+ {red} compileflags, 1)...{normal}
{red} File "<doctest sample2.sampletests_e.eek[0]>", line 1, in ?{normal}
{red} f(){normal}
{red} File "testrunner-ex/sample2/sampletests_e.py", line 19, in f{normal}
@@ -155,7 +155,7 @@
Exception raised:
{red} Traceback (most recent call last):{normal}
{red} File ".../doctest.py", line 1356, in __run{normal}
- {red} compileflags, 1) in test.globs{normal}
+ {red} compileflags, 1)...{normal}
{red} File "<doctest e.txt[1]>", line 1, in ?{normal}
{red} f(){normal}
{red} File "<doctest e.txt[0]>", line 2, in f{normal}
@@ -200,17 +200,19 @@
----------------------------------------------------------------------
{normal}File testrunner-ex/pledge.py{normal}", line {boldred}26{normal}, in {boldcyan}pledge.pledge{normal}
Failed example:
- {cyan} print pledge_template % ('and earthling', 'planet'),{normal}
+ {cyan} print_pledge(){normal}
Expected:
{green} I give my pledge, as an earthling,{normal}
{green} to save, and faithfully, to defend from waste,{normal}
{green} the natural resources of my planet.{normal}
{green} It's soils, minerals, forests, waters, and wildlife.{normal}
+ {green} <BLANKLINE>{normal}
Got:
{red} I give my pledge, as and earthling,{normal}
{red} to save, and faithfully, to defend from waste,{normal}
{red} the natural resources of my planet.{normal}
{red} It's soils, minerals, forests, waters, and wildlife.{normal}
+ {red} <BLANKLINE>{normal}
<BLANKLINE>
{normal} Ran {green}1{normal} tests with {boldred}1{normal} failures and {green}0{normal} errors in {green}0.002{normal} seconds.{normal}
{normal}Tearing down left over layers:{normal}
@@ -232,7 +234,7 @@
----------------------------------------------------------------------
{normal}File testrunner-ex/pledge.py{normal}", line {boldred}26{normal}, in {boldcyan}pledge.pledge{normal}
Failed example:
- {cyan} print pledge_template % ('and earthling', 'planet'),{normal}
+ {cyan} print_pledge(){normal}
Differences (ndiff with -expected +actual):
{green} - I give my pledge, as an earthling,{normal}
{red} + I give my pledge, as and earthling,{normal}
@@ -240,6 +242,7 @@
{normal} to save, and faithfully, to defend from waste,{normal}
{normal} the natural resources of my planet.{normal}
{normal} It's soils, minerals, forests, waters, and wildlife.{normal}
+ {normal} <BLANKLINE>{normal}
<BLANKLINE>
{normal} Ran {green}1{normal} tests with {boldred}1{normal} failures and {green}0{normal} errors in {green}0.003{normal} seconds.{normal}
{normal}Tearing down left over layers:{normal}
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging-layer-setup.test 2010-04-28 22:26:38 UTC (rev 111557)
@@ -5,7 +5,7 @@
>>> tdir = tempfile.mkdtemp()
>>> dir = os.path.join(tdir, 'TESTS-DIR')
>>> os.mkdir(dir)
- >>> open(os.path.join(dir, 'tests.py'), 'w').write(
+ >>> written = open(os.path.join(dir, 'tests.py'), 'w').write(
... '''
... import doctest
...
@@ -47,7 +47,7 @@
... finally: sys.stdin = real_stdin
... # doctest: +ELLIPSIS
Running tests.Layer tests:
- Set up tests.Layer exceptions.ValueError:
+ Set up tests.Layer ...ValueError:
<BLANKLINE>
> ...tests.py(8)setUp()
-> raise ValueError
@@ -64,7 +64,7 @@
... else:
... sys.stdin = Input('p x\nc')
- >>> open(os.path.join(dir, 'tests2.py'), 'w').write(
+ >>> written = open(os.path.join(dir, 'tests2.py'), 'w').write(
... '''
... import doctest, unittest
...
@@ -111,7 +111,7 @@
Running tests2.Layer2 tests:
Tear down tests2.Layer1 ... not supported
Running in a subprocess.
- Set up tests2.Layer2
+ Set up tests2.Layer2
**********************************************************************
<BLANKLINE>
Can't post-mortem debug when running a layer as a subprocess!
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt 2010-04-28 22:26:38 UTC (rev 111557)
@@ -60,7 +60,7 @@
... ' -t post_mortem1 -D').split()
>>> try: testrunner.run_internal(defaults)
... finally: sys.stdin = real_stdin
- ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF
+ ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF +ELLIPSIS
Running zope.testrunner.layer.UnitTests tests:
...
Error in test test_post_mortem1 (sample3.sampletests_d.TestSomething)
@@ -70,7 +70,7 @@
raise ValueError
ValueError
<BLANKLINE>
- exceptions.ValueError:
+ ...ValueError:
<BLANKLINE>
> testrunner-ex/sample3/sampletests_d.py(34)test_post_mortem1()
-> raise ValueError
@@ -84,7 +84,7 @@
In the example above, we debugged an error. Failures are actually
converted to errors and can be debugged the same way:
- >>> sys.stdin = Input('up\np x\np y\nc')
+ >>> sys.stdin = Input('p x\np y\nc')
>>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
... ' -t post_mortem_failure1 -D').split()
>>> try: testrunner.run_internal(defaults)
@@ -98,18 +98,13 @@
getattr(self, self.__testMethodName)()
File "testrunner-ex/sample3/sampletests_d.py",
line 42, in test_post_mortem_failure1
- self.assertEqual(x, y)
- File ".../unittest.py", line 302, in failUnlessEqual
- raise self.failureException, \
- AssertionError: 1 != 2
+ assert x == y
+ AssertionError
<BLANKLINE>
- exceptions.AssertionError:
- 1 != 2
- > .../unittest.py(302)failUnlessEqual()
- -> ...
- (Pdb) up
+ ...AssertionError:
+ <BLANKLINE>
> testrunner-ex/sample3/sampletests_d.py(42)test_post_mortem_failure1()
- -> self.assertEqual(x, y)
+ -> assert x == y
(Pdb) p x
1
(Pdb) p y
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-edge-cases.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-edge-cases.txt 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-edge-cases.txt 2010-04-28 22:26:38 UTC (rev 111557)
@@ -218,7 +218,7 @@
raise ValueError
ValueError
<BLANKLINE>
- exceptions.ValueError:
+ ...ValueError:
<BLANKLINE>
> testrunner-ex/sample3/sampletests_d.py(46)g()
-> raise ValueError
@@ -242,9 +242,9 @@
<BLANKLINE>
Error in test post_mortem3 (sample3.sampletests_d)
Traceback (most recent call last):
- UnexpectedException: testrunner-ex/sample3/sampletests_d.py:NNN (2 examples)>
+ ...UnexpectedException: testrunner-ex/sample3/sampletests_d.py:NNN (2 examples)>
<BLANKLINE>
- exceptions.ValueError:
+ ...ValueError:
<BLANKLINE>
> <doctest sample3.sampletests_d.post_mortem3[1]>(1)?()
(Pdb) p x
@@ -266,9 +266,9 @@
<BLANKLINE>
Error in test post_mortem4 (sample3.sampletests_d)
Traceback (most recent call last):
- UnexpectedException: testrunner-ex/sample3/sampletests_d.py:NNN (1 example)>
+ ...UnexpectedException: testrunner-ex/sample3/sampletests_d.py:NNN (1 example)>
<BLANKLINE>
- exceptions.ValueError:
+ ...ValueError:
<BLANKLINE>
> testrunner-ex/sample3/sampletests_d.py(NNN)g()
-> raise ValueError
@@ -291,9 +291,9 @@
<BLANKLINE>
Error testrunner-ex/sample3/post_mortem5.txt
Traceback (most recent call last):
- UnexpectedException: testrunner-ex/sample3/post_mortem5.txt:0 (2 examples)>
+ ...UnexpectedException: testrunner-ex/sample3/post_mortem5.txt:0 (2 examples)>
<BLANKLINE>
- exceptions.ValueError:
+ ...ValueError:
<BLANKLINE>
> <doctest post_mortem5.txt[1]>(1)?()
(Pdb) p x
@@ -327,9 +327,9 @@
exc_info)
File ".../zope/testing/doctest/__init__.py", Line NNN, in report_unexpected_exception
raise UnexpectedException(test, example, exc_info)
- UnexpectedException: testrunner-ex/sample3/post_mortem6.txt:0 (2 examples)>
+ ...UnexpectedException: testrunner-ex/sample3/post_mortem6.txt:0 (2 examples)>
<BLANKLINE>
- exceptions.ValueError:
+ ...ValueError:
<BLANKLINE>
> testrunner-ex/sample3/sampletests_d.py(NNN)g()
-> raise ValueError
@@ -364,7 +364,7 @@
<BLANKLINE>
<BLANKLINE>
> testrunner-ex/sample3/sampletests_d.py(81)_()
- exceptions.ValueError:
+ ...ValueError:
Expected and actual output are different
> <string>(1)...()
(Pdb) p x
@@ -399,7 +399,7 @@
<BLANKLINE>
<BLANKLINE>
> testrunner-ex/sample3/post_mortem_failure.txt(2)_()
- exceptions.ValueError:
+ ...ValueError:
Expected and actual output are different
> <string>(1)...()
(Pdb) p x
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-errors.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-errors.txt 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-errors.txt 2010-04-28 22:26:38 UTC (rev 111557)
@@ -571,17 +571,19 @@
----------------------------------------------------------------------
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
- print pledge_template % ('and earthling', 'planet'),
+ print_pledge()
Expected:
I give my pledge, as an earthling,
to save, and faithfully, to defend from waste,
the natural resources of my planet.
It's soils, minerals, forests, waters, and wildlife.
+ <BLANKLINE>
Got:
I give my pledge, as and earthling,
to save, and faithfully, to defend from waste,
the natural resources of my planet.
It's soils, minerals, forests, waters, and wildlife.
+ <BLANKLINE>
<BLANKLINE>
Ran 1 tests with 1 failures and 0 errors in 0.002 seconds.
Tearing down left over layers:
@@ -611,7 +613,7 @@
----------------------------------------------------------------------
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
- print pledge_template % ('and earthling', 'planet'),
+ print_pledge()
Differences (ndiff with -expected +actual):
- I give my pledge, as an earthling,
+ I give my pledge, as and earthling,
@@ -619,6 +621,7 @@
to save, and faithfully, to defend from waste,
the natural resources of my planet.
It's soils, minerals, forests, waters, and wildlife.
+ <BLANKLINE>
<BLANKLINE>
Ran 1 tests with 1 failures and 0 errors in 0.003 seconds.
Tearing down left over layers:
@@ -639,7 +642,7 @@
----------------------------------------------------------------------
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
- print pledge_template % ('and earthling', 'planet'),
+ print_pledge()
Differences (unified diff with -expected +actual):
@@ -1,3 +1,3 @@
-I give my pledge, as an earthling,
@@ -666,7 +669,7 @@
----------------------------------------------------------------------
File "testrunner-ex/pledge.py", line 26, in pledge.pledge
Failed example:
- print pledge_template % ('and earthling', 'planet'),
+ print_pledge()
Differences (context diff with expected followed by actual):
***************
*** 1,3 ****
@@ -794,37 +797,6 @@
True
-Unicode Errors
---------------
-
-There was a bug preventing decent error reporting when a result contained
-unicode and another not:
-
- >>> sys.argv = 'test --tests-pattern ^unicode$ -u'.split()
- >>> testrunner.run_internal(defaults) # doctest: +REPORT_NDIFF
- Running zope.testrunner.layer.UnitTests tests:
- Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
- <BLANKLINE>
- <BLANKLINE>
- Failure testrunner-ex/unicode.txt
- Failed doctest test for unicode.txt
- testrunner-ex/unicode.txt", line 0
- <BLANKLINE>
- ----------------------------------------------------------------------
- File testrunner-ex/unicode.txt", Line NNN, in unicode.txt
- Failed example:
- 'xyz'
- Expected:
- 123
- Got:
- 'xyz'
- <BLANKLINE>
- Ran 1 tests with 1 failures and 0 errors in N.NNN seconds.
- Tearing down left over layers:
- Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
- True
-
-
Reporting Errors to Calling Processes
-------------------------------------
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/pledge.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/pledge.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/pledge.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -22,11 +22,14 @@
def pledge():
"""
- >>> print pledge_template % ('and earthling', 'planet'),
+ >>> def print_pledge():
+ ... print pledge_template % ('and earthling', 'planet')
+ >>> print_pledge()
I give my pledge, as an earthling,
to save, and faithfully, to defend from waste,
the natural resources of my planet.
It's soils, minerals, forests, waters, and wildlife.
+ <BLANKLINE>
"""
def test_suite():
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/sample3/sampletests_d.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/sample3/sampletests_d.py 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/sample3/sampletests_d.py 2010-04-28 22:26:38 UTC (rev 111557)
@@ -39,7 +39,7 @@
def test_post_mortem_failure1(self):
x = 1
y = 2
- self.assertEqual(x, y)
+ assert x == y
def f():
x = 1
Deleted: zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/unicode.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/unicode.txt 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-ex/unicode.txt 2010-04-28 22:26:38 UTC (rev 111557)
@@ -1,22 +0,0 @@
-=========================
-Errors Containing Unicode
-=========================
-
-There was a unicode bug. When a function returned unicode some internal
-state switched. This broke any further test not returning unicode but a plain
-string with unicode characters. Make sure this works now::
-
- >>> def get_unicode():
- ... return u'foo \u2014 bar'
-
- >>> get_unicode()
- u'foo \u2014 bar'
-
- >>> 'foo \xe9'
- 'foo \xe9'
-
-Get some normal output as well::
-
- >>> 'xyz'
- 123
-
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-api.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-api.txt 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-api.txt 2010-04-28 22:26:38 UTC (rev 111557)
@@ -114,11 +114,11 @@
>>> from zope.testrunner.runner import Runner
>>> runner = Runner(options=fresh_options(), args=[], found_suites=[umbrella_suite])
>>> succeeded = runner.run()
-Running BaseLayer tests:
- Set up BaseLayer in N.NNN seconds.
+Running ...BaseLayer tests:
+ Set up ...BaseLayer in N.NNN seconds.
Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
Running zope.testrunner.layer.UnitTests tests:
- Tear down BaseLayer in N.NNN seconds.
+ Tear down ...BaseLayer in N.NNN seconds.
Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
Tearing down left over layers:
@@ -133,11 +133,11 @@
>>> no_layer_suite.layer = BaseLayer
>>> runner = Runner(options=fresh_options(), args=[], found_suites=[umbrella_suite])
>>> succeeded = runner.run()
-Running BaseLayer tests:
- Set up BaseLayer in N.NNN seconds.
+Running ...BaseLayer tests:
+ Set up ...BaseLayer in N.NNN seconds.
Ran 4 tests with 0 failures and 0 errors in N.NNN seconds.
Tearing down left over layers:
- Tear down BaseLayer in N.NNN seconds.
+ Tear down ...BaseLayer in N.NNN seconds.
Clear our logged output, as we want to inspect it shortly.
@@ -152,15 +152,15 @@
>>> TestSpecifyingNoLayer.layer = TopLayer
>>> runner = Runner(options=fresh_options(), args=[], found_suites=[umbrella_suite])
>>> succeeded = runner.run()
-Running BaseLayer tests:
- Set up BaseLayer in N.NNN seconds.
+Running ...BaseLayer tests:
+ Set up ...BaseLayer in N.NNN seconds.
Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
-Running TopLayer tests:
- Set up TopLayer in N.NNN seconds.
+Running ...TopLayer tests:
+ Set up ...TopLayer in N.NNN seconds.
Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
Tearing down left over layers:
- Tear down TopLayer in N.NNN seconds.
- Tear down BaseLayer in N.NNN seconds.
+ Tear down ...TopLayer in N.NNN seconds.
+ Tear down ...BaseLayer in N.NNN seconds.
Total: 4 tests, 0 failures, 0 errors in N.NNN seconds.
@@ -170,9 +170,11 @@
each test using that layer in the right order.
>>> def report():
+... print "Report:"
... for record in log_handler.records:
... print record.getMessage()
>>> report()
+Report:
BaseLayer.setUp
BaseLayer.testSetUp
TestSpecifyingBaseLayer.setUp
@@ -236,46 +238,47 @@
>>> suite = unittest.makeSuite(DeepTest)
>>> log_handler.clear()
>>> runner = Runner(options=fresh_options(), args=[], found_suites=[suite])
->>> succeeded = runner.run()
-Running F tests:
- Set up A in N.NNN seconds.
- Set up B in N.NNN seconds.
- Set up C in N.NNN seconds.
- Set up D in N.NNN seconds.
- Set up E in N.NNN seconds.
- Set up F in N.NNN seconds.
+>>> succeeded = runner.run() #doctest: +ELLIPSIS
+Running ...F tests:
+ Set up ...A in N.NNN seconds.
+ Set up ...B in N.NNN seconds.
+ Set up ...C in N.NNN seconds.
+ Set up ...D in N.NNN seconds.
+ Set up ...E in N.NNN seconds.
+ Set up ...F in N.NNN seconds.
Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
Tearing down left over layers:
- Tear down F in N.NNN seconds.
- Tear down E in N.NNN seconds.
- Tear down D in N.NNN seconds.
- Tear down C in N.NNN seconds.
- Tear down B in N.NNN seconds.
- Tear down A in N.NNN seconds.
+ Tear down ...F in N.NNN seconds.
+ Tear down ...E in N.NNN seconds.
+ Tear down ...D in N.NNN seconds.
+ Tear down ...C in N.NNN seconds.
+ Tear down ...B in N.NNN seconds.
+ Tear down ...A in N.NNN seconds.
->>> report()
-A.setUp
-B.setUp
-C.setUp
-D.setUp
-E.setUp
-F.setUp
-A.testSetUp
-B.testSetUp
-C.testSetUp
-D.testSetUp
-E.testSetUp
-F.testSetUp
-F.testTearDown
-E.testTearDown
-D.testTearDown
-C.testTearDown
-B.testTearDown
-A.testTearDown
-F.tearDown
-E.tearDown
-D.tearDown
-C.tearDown
-B.tearDown
-A.tearDown
+>>> report() #doctest: +ELLIPSIS
+Report:
+...A.setUp
+...B.setUp
+...C.setUp
+...D.setUp
+...E.setUp
+...F.setUp
+...A.testSetUp
+...B.testSetUp
+...C.testSetUp
+...D.testSetUp
+...E.testSetUp
+...F.testSetUp
+...F.testTearDown
+...E.testTearDown
+...D.testTearDown
+...C.testTearDown
+...B.testTearDown
+...A.testTearDown
+...F.tearDown
+...E.tearDown
+...D.tearDown
+...C.tearDown
+...B.tearDown
+...A.tearDown
Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-progress.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-progress.txt 2010-04-28 19:17:32 UTC (rev 111556)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-progress.txt 2010-04-28 22:26:38 UTC (rev 111557)
@@ -162,6 +162,8 @@
that, we'll provide a fake curses module:
>>> class FakeCurses:
+ ... class error(Exception):
+ ... pass
... def setupterm(self):
... pass
... def tigetnum(self, ignored):
More information about the checkins
mailing list