diff options
author | Matthias Bussonnier <bussonniermatthias@gmail.com> | 2016-02-14 10:05:12 -0800 |
---|---|---|
committer | Matthias Bussonnier <bussonniermatthias@gmail.com> | 2016-02-14 10:05:12 -0800 |
commit | 064edec39bc9075dad066450c9a5bab254f4a581 (patch) | |
tree | 721d0761c36c0ad05b6f70cbaf9a8d22e9a1af9b /tests/test_lexers_other.py | |
parent | 29add34f07fb41b231582025546e3c638bdf9fb7 (diff) | |
download | pygments-064edec39bc9075dad066450c9a5bab254f4a581.tar.gz |
Finish backporting assertLess and assertIn
Diffstat (limited to 'tests/test_lexers_other.py')
-rw-r--r-- | tests/test_lexers_other.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py index c59ae323..4c5132ad 100644 --- a/tests/test_lexers_other.py +++ b/tests/test_lexers_other.py @@ -9,7 +9,6 @@ import glob import os import unittest -import sys from pygments.lexers import guess_lexer from pygments.lexers.scripting import EasytrieveLexer, JclLexer, RexxLexer @@ -17,6 +16,18 @@ from pygments.lexers.scripting import EasytrieveLexer, JclLexer, RexxLexer def _exampleFilePath(filename): return os.path.join(os.path.dirname(__file__), 'examplefiles', filename) +_MAX_LENGTH = 80 + +def safe_repr(obj, short=False): + try: + result = repr(obj) + except Exception: + result = object.__repr__(obj) + if not short or len(result) < _MAX_LENGTH: + return result + return result[:_MAX_LENGTH] + ' [truncated]...' + + class MyTestCase(unittest.TestCase): ### Assert less is 2.7+ only. def assertLess(self, a, b, msg=None): |