summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2007-12-09 13:53:01 -0200
committerGustavo Niemeyer <gustavo@niemeyer.net>2007-12-09 13:53:01 -0200
commit195f0d884b7c4ad16271a9b0f17e6cecfbfba169 (patch)
treeada8a38956aa3416568a5832af046701efd88a63 /test.py
parent7ba4e6a4eff5896808e7b95e84744cd97a963c07 (diff)
downloadmocker-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-xtest.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test.py b/test.py
index 10285aa..ca6e097 100755
--- a/test.py
+++ b/test.py
@@ -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)