summaryrefslogtreecommitdiff
path: root/tests/test_lexers_other.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_lexers_other.py')
-rw-r--r--tests/test_lexers_other.py21
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)