summaryrefslogtreecommitdiff
path: root/tests/string_asserts.py
diff options
context:
space:
mode:
authorAndrew Pinkham <code@andrewsforge.com>2014-05-06 15:07:37 -0500
committerAndrew Pinkham <code@andrewsforge.com>2014-05-06 15:07:37 -0500
commitaca87505ca7d65c43eca864b1646d7882ff586e6 (patch)
tree46015afabcc1442d8af8e210bd8130e850bb5306 /tests/string_asserts.py
parent6cdc2645d849addc2b4bbb71ea2bc1933b5b2b41 (diff)
downloadpygments-aca87505ca7d65c43eca864b1646d7882ff586e6.tar.gz
Added assert methods for string comparisons.
Diffstat (limited to 'tests/string_asserts.py')
-rw-r--r--tests/string_asserts.py22
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))