summaryrefslogtreecommitdiff
path: root/mocker.py
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2007-11-17 18:21:37 -0200
committerGustavo Niemeyer <gustavo@niemeyer.net>2007-11-17 18:21:37 -0200
commitf208f3845c4ab36caae331fe1f756bd2d7ee07a8 (patch)
treefa5abd06a0ff06b7fd91208a80e278348909b681 /mocker.py
parent745fc9a11340f192e2f73c0f1f3101866d26f74f (diff)
downloadmocker-f208f3845c4ab36caae331fe1f756bd2d7ee07a8.tar.gz
Added MockerTestCase.assert[Not]{Starts,Ends}With().
Diffstat (limited to 'mocker.py')
-rw-r--r--mocker.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/mocker.py b/mocker.py
index 7d7160c..2662ec3 100644
--- a/mocker.py
+++ b/mocker.py
@@ -174,6 +174,30 @@ class MockerTestCase(unittest.TestCase):
if first not in second:
raise self.failureException(msg or "%r not in %r" % (first, second))
+ def failUnlessStartsWith(self, first, second, msg=None):
+ """Assert that C{first} starts with C{second}."""
+ if first[:len(second)] != second:
+ raise self.failureException(msg or "%r doesn't start with %r" %
+ (first, second))
+
+ def failIfStartsWith(self, first, second, msg=None):
+ """Assert that C{first} doesn't start with C{second}."""
+ if first[:len(second)] == second:
+ raise self.failureException(msg or "%r starts with %r" %
+ (first, second))
+
+ def failUnlessEndsWith(self, first, second, msg=None):
+ """Assert that C{first} starts with C{second}."""
+ if first[len(first)-len(second):] != second:
+ raise self.failureException(msg or "%r doesn't end with %r" %
+ (first, second))
+
+ def failIfEndsWith(self, first, second, msg=None):
+ """Assert that C{first} doesn't start with C{second}."""
+ if first[len(first)-len(second):] == second:
+ raise self.failureException(msg or "%r ends with %r" %
+ (first, second))
+
def failIfIn(self, first, second, msg=None):
"""Assert that C{first} is not contained in C{second}."""
if first in second:
@@ -229,6 +253,10 @@ class MockerTestCase(unittest.TestCase):
assertIsNot = failIfIs
assertIn = failUnlessIn
assertNotIn = failIfIn
+ assertStartsWith = failUnlessStartsWith
+ assertNotStartsWith = failIfStartsWith
+ assertEndsWith = failUnlessEndsWith
+ assertNotEndsWith = failIfEndsWith
assertApproximates = failUnlessApproximates
assertNotApproximates = failIfApproximates
assertMethodsMatch = failUnlessMethodsMatch