[pypy-svn] r9953 - in pypy/dist/pypy/tool: . test
briandorsey at codespeak.net
briandorsey at codespeak.net
Sun Mar 20 22:15:04 CET 2005
Author: briandorsey
Date: Sun Mar 20 22:15:04 2005
New Revision: 9953
Modified:
pypy/dist/pypy/tool/pytestsupport.py
pypy/dist/pypy/tool/test/test_pytestsupport.py
Log:
Disable py.test assertion magic if a message is explicitly passed to 'assert' at the application level. (eg: assert False, "this fails")
Modified: pypy/dist/pypy/tool/pytestsupport.py
==============================================================================
--- pypy/dist/pypy/tool/pytestsupport.py (original)
+++ pypy/dist/pypy/tool/pytestsupport.py Sun Mar 20 22:15:04 2005
@@ -88,19 +88,24 @@
if frame.code.co_name == 'normalize_exception':
frame = framestack.top(1)
- runner = AppFrame(frame)
- try:
- source = runner.statement
- source = str(source).strip()
- except py.error.ENOENT:
- source = None
- if source and not py.test.config.option.nomagic:
- msg = exprinfo.interpret(source, runner, should_fail=True)
- space.setattr(w_self, space.wrap('args'),
- space.newtuple([space.wrap(msg)]))
- w_msg = space.wrap(msg)
+ # if the assertion provided a message, don't do magic
+ args_w, kwargs_w = __args__.unpack()
+ if args_w:
+ w_msg = args_w[0]
else:
- w_msg = space.w_None
+ runner = AppFrame(frame)
+ try:
+ source = runner.statement
+ source = str(source).strip()
+ except py.error.ENOENT:
+ source = None
+ if source and not py.test.config.option.nomagic:
+ msg = exprinfo.interpret(source, runner, should_fail=True)
+ space.setattr(w_self, space.wrap('args'),
+ space.newtuple([space.wrap(msg)]))
+ w_msg = space.wrap(msg)
+ else:
+ w_msg = space.w_None
space.setattr(w_self, space.wrap('msg'), w_msg)
# build a new AssertionError class to replace the original one.
Modified: pypy/dist/pypy/tool/test/test_pytestsupport.py
==============================================================================
--- pypy/dist/pypy/tool/test/test_pytestsupport.py (original)
+++ pypy/dist/pypy/tool/test/test_pytestsupport.py Sun Mar 20 22:15:04 2005
@@ -46,4 +46,11 @@
else:
raise AssertionError, "app level AssertionError mixup!"
+def app_test_exception_with_message():
+ try:
+ assert 0, "Failed"
+ except AssertionError, e:
+ assert e.msg == "Failed"
+
+
More information about the Pypy-commit
mailing list