diff options
author | Georg Brandl <georg@python.org> | 2014-10-08 08:50:24 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-10-08 08:50:24 +0200 |
commit | ab509e4ea2a8bd3c7e8e355b0e83b3e2de9f7a01 (patch) | |
tree | db1c94d9d2ba3fc0c664b71ba798007eb0da5a65 /tests/string_asserts.py | |
parent | 7f5c98a36c3a8e1b9877e1d4cfe41fd00f08833a (diff) | |
parent | e07ba8bf31d7a9ee2cfd4832608a9453a9f81fbe (diff) | |
download | pygments-ab509e4ea2a8bd3c7e8e355b0e83b3e2de9f7a01.tar.gz |
Merged in __russ__/pygments-main (pull request #165)
Diffstat (limited to 'tests/string_asserts.py')
-rw-r--r-- | tests/string_asserts.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/string_asserts.py b/tests/string_asserts.py new file mode 100644 index 00000000..3aa50420 --- /dev/null +++ b/tests/string_asserts.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +""" + Pygments string assert utility + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +class StringTests(object): + + def assertStartsWith(self, haystack, needle, msg=None): + if msg is None: + msg = "'{0}' does not start with '{1}'".format(haystack, needle) + if not haystack.startswith(needle): + raise(AssertionError(msg)) + + def assertEndsWith(self, haystack, needle, msg=None): + if msg is None: + msg = "'{0}' does not end with '{1}'".format(haystack, needle) + if not haystack.endswith(needle): + raise(AssertionError(msg)) |