Skip to content
Browse files

UnexpectedCall is now a BaseException which is re-raised as an

AssertionError to decrease the chance that application error handling
will mask it.
chai 0.2.2
  • Loading branch information...
1 parent e8d8528 commit 31eb4bf742fe593d378e76bb237d376587e12b53 @awestendorf awestendorf committed Sep 11, 2012
Showing with 15 additions and 4 deletions.
  1. +7 −0 CHANGELOG
  2. +1 −1 README.rst
  3. +5 −1 chai/chai.py
  4. +1 −1 chai/exception.py
  5. +1 −1 setup.py
View
7 CHANGELOG
@@ -1,3 +1,10 @@
+0.2.2
+=====
+
+* UnexpectedCall is now a BaseException which is re-raised as an AssertionError
+in Chai metaclass `test_wrapper` method. This decreases the chance that
+UnexpectedCall will be caught by the application code being tested.
+
0.2.1
=====
View
2 README.rst
@@ -2,7 +2,7 @@
Chai - Python Mocking Made Easy
=================================
-:Version: 0.2.1
+:Version: 0.2.2
:Download: http://pypi.python.org/pypi/chai
:Source: https://github.com/agoragames/chai
:Keywords: python, mocking, testing, unittest, unittest2
View
6 chai/chai.py
@@ -45,7 +45,11 @@ def test_wrapper(cls, func):
calls assert_expectations on the stub. This is to avoid getting to exceptions about the same error.
"""
def wrapper(self, *args, **kwargs):
- func(self, *args, **kwargs)
+ try:
+ func(self, *args, **kwargs)
+ except UnexpectedCall as e:
+ raise AssertionError, e.args, sys.exc_info()[-1]
+
exceptions = []
for stub in self._stubs:
exceptions.extend(stub.unmet_expectations())
View
2 chai/exception.py
@@ -17,7 +17,7 @@ class ChaiAssertion(AssertionError):
Base class for all assertion errors.
'''
-class UnexpectedCall(ChaiAssertion):
+class UnexpectedCall(BaseException):
'''
Raised when a unexpected call occurs to a stub.
'''
View
2 setup.py
@@ -8,7 +8,7 @@
setup(
name='chai',
- version='0.2.1',
+ version='0.2.2',
author='Vitaly Babiy, Aaron Westendorf',
author_email="vbabiy@agoragames.com, aaron@agoragames.com",
packages=['chai'],

0 comments on commit 31eb4bf

Please sign in to comment.
Something went wrong with that request. Please try again.