diff options
Diffstat (limited to 'tests/test_html_formatter.py')
-rw-r--r-- | tests/test_html_formatter.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py index 79990edd..670a5be9 100644 --- a/tests/test_html_formatter.py +++ b/tests/test_html_formatter.py @@ -100,7 +100,7 @@ class HtmlFormatterTest(unittest.TestCase): fmt = HtmlFormatter(**optdict) fmt.format(tokensource, outfile) html = outfile.getvalue() - self.assertTrue(re.search("<pre>\s+1\s+2\s+3", html)) + self.assertTrue(re.search(r"<pre>\s+1\s+2\s+3", html)) def test_linenos_with_startnum(self): optdict = dict(linenos=True, linenostart=5) @@ -108,7 +108,7 @@ class HtmlFormatterTest(unittest.TestCase): fmt = HtmlFormatter(**optdict) fmt.format(tokensource, outfile) html = outfile.getvalue() - self.assertTrue(re.search("<pre>\s+5\s+6\s+7", html)) + self.assertTrue(re.search(r"<pre>\s+5\s+6\s+7", html)) def test_lineanchors(self): optdict = dict(lineanchors="foo") @@ -132,9 +132,8 @@ class HtmlFormatterTest(unittest.TestCase): outencoding='utf-8') handle, pathname = tempfile.mkstemp('.html') - tfile = os.fdopen(handle, 'w+b') - fmt.format(tokensource, tfile) - tfile.close() + with os.fdopen(handle, 'w+b') as tfile: + fmt.format(tokensource, tfile) catname = os.path.join(TESTDIR, 'dtds', 'HTML4.soc') try: import subprocess @@ -173,9 +172,8 @@ class HtmlFormatterTest(unittest.TestCase): cssstyles=u'div:before { content: \'bäz\' }', encoding='utf-8') handle, pathname = tempfile.mkstemp('.html') - tfile = os.fdopen(handle, 'w+b') - fmt.format(tokensource, tfile) - tfile.close() + with os.fdopen(handle, 'w+b') as tfile: + fmt.format(tokensource, tfile) def test_ctags(self): try: |