diff options
author | Andrew Pinkham <code@andrewsforge.com> | 2014-05-06 15:07:37 -0500 |
---|---|---|
committer | Andrew Pinkham <code@andrewsforge.com> | 2014-05-06 15:07:37 -0500 |
commit | aca87505ca7d65c43eca864b1646d7882ff586e6 (patch) | |
tree | 46015afabcc1442d8af8e210bd8130e850bb5306 /tests/string_asserts.py | |
parent | 6cdc2645d849addc2b4bbb71ea2bc1933b5b2b41 (diff) | |
download | pygments-aca87505ca7d65c43eca864b1646d7882ff586e6.tar.gz |
Added assert methods for string comparisons.
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..025a5281 --- /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 = "'{}' does not start with '{}'".format(haystack, needle) + if not haystack.startswith(needle): + raise(AssertionError(msg)) + + def assertEndsWith(self, haystack, needle, msg=None): + if msg is None: + msg = "'{}' does not end with '{}'".format(haystack, needle) + if not haystack.endswith(needle): + raise(AssertionError(msg)) |