diff options
author | Georg Brandl <georg@python.org> | 2014-10-08 09:21:15 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-10-08 09:21:15 +0200 |
commit | 444fb6fd9b3492040a36fcca672fee8175f8d603 (patch) | |
tree | 2bd411ca78decf276b95dc6b1788e594b2e35287 /tests/test_lexers_other.py | |
parent | 491fec23ef01687906f5d71ee718522cd2917926 (diff) | |
parent | c1bfe4eed3805d3556bffa3c6b9cc2d3f6976205 (diff) | |
download | pygments-444fb6fd9b3492040a36fcca672fee8175f8d603.tar.gz |
Merged in leodemoura/pygments-main (pull request #399)
Diffstat (limited to 'tests/test_lexers_other.py')
-rw-r--r-- | tests/test_lexers_other.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py index 91b0dc70..e3625a2b 100644 --- a/tests/test_lexers_other.py +++ b/tests/test_lexers_other.py @@ -12,7 +12,7 @@ import os import unittest from pygments.lexers import guess_lexer -from pygments.lexers.other import RexxLexer +from pygments.lexers.scripting import RexxLexer def _exampleFilePath(filename): @@ -26,17 +26,14 @@ class AnalyseTextTest(unittest.TestCase): for pattern in lexer.filenames: exampleFilesPattern = _exampleFilePath(pattern) for exampleFilePath in glob.glob(exampleFilesPattern): - exampleFile = open(exampleFilePath, 'rb') - try: - text = exampleFile.read().decode('utf-8') - probability = lexer.analyse_text(text) - self.assertTrue(probability > 0, - '%s must recognize %r' % ( - lexer.name, exampleFilePath)) - guessedLexer = guess_lexer(text) - self.assertEqual(guessedLexer.name, lexer.name) - finally: - exampleFile.close() + with open(exampleFilePath, 'rb') as fp: + text = fp.read().decode('utf-8') + probability = lexer.analyse_text(text) + self.assertTrue(probability > 0, + '%s must recognize %r' % ( + lexer.name, exampleFilePath)) + guessedLexer = guess_lexer(text) + self.assertEqual(guessedLexer.name, lexer.name) def testCanRecognizeAndGuessExampleFiles(self): self._testCanRecognizeAndGuessExampleFiles(RexxLexer) |