diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2009-02-13 12:10:28 +0000 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2009-02-13 12:10:28 +0000 |
commit | a9b44545edaae14ea4656181a93a98cfaad8310c (patch) | |
tree | 26db48abcb6c12aece30c3fef53c6edc92e37b29 /test.py | |
parent | 8a4227cfcc32fed041462ebf6031d722bb0c39a1 (diff) | |
parent | 44c1f801a3068647673c7e827827bab7cc72264c (diff) | |
download | mocker-a9b44545edaae14ea4656181a93a98cfaad8310c.tar.gz |
Merged 328990-mocker-hides-exception branch from Duncan McGreggor. This
ensures that the raised AttributeError exception on a patched object
actually exposes the real problem rather than an internal Mocker
exception.
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -3983,6 +3983,21 @@ class PatcherTest(TestCase): self.assertEquals(obj.method(), "original") self.assertRaises(AssertionError, obj.method) + def test_original_exception_raised(self): + class C(object): + def use_non_existing_attribute(self): + return self.bad_attribute + + mock = self.mocker.patch(C) + mock.any_other_method() + self.mocker.replay() + obj = C() + try: + obj.use_non_existing_attribute() + except AttributeError, error: + message = "'C' object has no attribute 'bad_attribute'" + self.assertEquals(message, error.message) + def main(): try: |