diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-17 18:21:37 -0200 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-17 18:21:37 -0200 |
commit | f208f3845c4ab36caae331fe1f756bd2d7ee07a8 (patch) | |
tree | fa5abd06a0ff06b7fd91208a80e278348909b681 /mocker.py | |
parent | 745fc9a11340f192e2f73c0f1f3101866d26f74f (diff) | |
download | mocker-f208f3845c4ab36caae331fe1f756bd2d7ee07a8.tar.gz |
Added MockerTestCase.assert[Not]{Starts,Ends}With().
Diffstat (limited to 'mocker.py')
-rw-r--r-- | mocker.py | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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 |