diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-12-09 13:53:01 -0200 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-12-09 13:53:01 -0200 |
commit | 195f0d884b7c4ad16271a9b0f17e6cecfbfba169 (patch) | |
tree | ada8a38956aa3416568a5832af046701efd88a63 /test.py | |
parent | 7ba4e6a4eff5896808e7b95e84744cd97a963c07 (diff) | |
download | mocker-195f0d884b7c4ad16271a9b0f17e6cecfbfba169.tar.gz |
When the expression executed isn't exactly the same as the
recorded events (e.g. when parameter matchers are used), show in
the error message the real expression run, to aid in debugging.
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -2624,6 +2624,31 @@ class EventTest(TestCase): self.assertEquals(calls, [42, 42, 42]) def test_run_errors(self): + """When the path representation isn't the same it's shown up.""" + class MyTask(object): + def __init__(self, id, failed): + self.id = id + self.failed = failed + def run(self, path): + if self.failed: + raise AssertionError("%d failed" % self.id) + event = Event("i.am.a.path") + event.add_task(MyTask(1, True)) + event.add_task(MyTask(2, False)) + event.add_task(MyTask(3, True)) + + try: + event.run("i.am.a.path") + except AssertionError, e: + message = os.linesep.join(["i.am.a.path", + "- 1 failed", + "- 3 failed"]) + self.assertEquals(str(e), message) + else: + self.fail("AssertionError not raised") + + def test_run_errors_with_different_path_representation(self): + """When the path representation isn't the same it's shown up.""" class MyTask(object): def __init__(self, id, failed): self.id = id @@ -2640,6 +2665,7 @@ class EventTest(TestCase): event.run(42) except AssertionError, e: message = os.linesep.join(["i.am.a.path", + "- Run: 42", # <== "- 1 failed", "- 3 failed"]) self.assertEquals(str(e), message) |