summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorDuncan McGreggor <duncan@canonical.com>2009-02-13 05:49:02 -0600
committerDuncan McGreggor <duncan@canonical.com>2009-02-13 05:49:02 -0600
commit44c1f801a3068647673c7e827827bab7cc72264c (patch)
tree055452bee51cdcdcf7b01bc8da07fbf975f0d404 /test.py
parent8a4227cfcc32fed041462ebf6031d722bb0c39a1 (diff)
downloadmocker-44c1f801a3068647673c7e827827bab7cc72264c.tar.gz
- Added a new unit test to check for a bug in mocker where the original
attribute gets swallowed by a subsequent exception check. - Added a fix for the bug.
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test.py b/test.py
index e98acb8..ec9578f 100755
--- a/test.py
+++ b/test.py
@@ -3983,6 +3983,20 @@ class PatcherTest(TestCase):
self.assertEquals(obj.method(), "original")
self.assertRaises(AssertionError, obj.method)
+ def test_original_exception_raised(self):
+ class MyClass(object):
+ def non_existing_attribute(self):
+ return self.bad_attribute
+
+ mock_class = self.mocker.patch(MyClass)
+ mock_class.run()
+ self.mocker.replay()
+ my_class = MyClass()
+ try:
+ my_class.non_existing_attribute()
+ except AttributeError, error:
+ message = "'MyClass' object has no attribute 'bad_attribute'"
+ self.assertEquals(message, error.message)
def main():
try: