[py-svn] r10729 - in py/branch/py-collect/test: terminal testing
hpk at codespeak.net
hpk at codespeak.net
Sat Apr 16 14:41:56 CEST 2005
Author: hpk
Date: Sat Apr 16 14:41:56 2005
New Revision: 10729
Modified:
py/branch/py-collect/test/terminal/terminal.py
py/branch/py-collect/test/testing/test_session.py
Log:
at least show something sensible on syntax errors
Modified: py/branch/py-collect/test/terminal/terminal.py
==============================================================================
--- py/branch/py-collect/test/terminal/terminal.py (original)
+++ py/branch/py-collect/test/terminal/terminal.py Sat Apr 16 14:41:56 2005
@@ -320,7 +320,8 @@
def repr_failure_explanation(self, excinfo, indent):
info = None
info = getattr(getattr(excinfo, 'value', ''), 'msg', '')
- if not info and not self.config.option.nomagic:
+ if not info and not self.config.option.nomagic \
+ and not excinfo.errisinstance(SyntaxError):
try:
info = excinfo.traceback[-1].reinterpret() # very detailed info
except KeyboardInterrupt:
@@ -332,10 +333,17 @@
else:
self.out.line("[reinterpretation failed, increase "
"verbosity to see details]")
- indent = " " * indent
- if not info:
+ #elif excinfo.errisinstance(SyntaxError):
+ #newex = SyntaxError('\n'.join([
+ #"".join(self.lines[:ex.lineno]),
+ #" " * ex.offset + '^',
+ #"syntax error probably generated here: %s" % filename]))
+ #newex.offset = ex.offset
+ #newex.lineno = ex.lineno
+ #newex.text = ex.text
+ else:
info = str(excinfo)
-
+ indent = " " * indent
lines = info.split('\n')
self.out.line('~' + indent[:-1] + lines.pop(0))
for x in lines:
Modified: py/branch/py-collect/test/testing/test_session.py
==============================================================================
--- py/branch/py-collect/test/testing/test_session.py (original)
+++ py/branch/py-collect/test/testing/test_session.py Sat Apr 16 14:41:56 2005
@@ -67,6 +67,14 @@
assert len(l) == 2
assert out.find('2 failed') != -1
+ def test_syntax_error_module(self):
+ session = self.session
+ session.main([str(datadir / 'syntax_error.py')])
+ l = session.getresults(py.test.Item.Failed)
+ assert len(l) == 1
+ out = self.file.getvalue()
+ assert out.find(str('syntax_error.py')) != -1
+ assert out.find(str('not python')) != -1
def test_exit_first_problem(self):
session = self.session
More information about the pytest-commit
mailing list