diff options
author | Georg Brandl <georg@python.org> | 2012-03-11 08:17:52 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-03-11 08:17:52 +0100 |
commit | 6f8e79cdf72575dac0047deaf7b2a32540676198 (patch) | |
tree | e0ced08a2f775d7e8c9fc4d523566bc797fbcb43 /tests/test_cmdline.py | |
parent | 9e80de2655ac91392e77fdb851cb8af940cff89d (diff) | |
download | pygments-6f8e79cdf72575dac0047deaf7b2a32540676198.tar.gz |
Fixes #748: clean up deprecation and resource warnings in the test suite when run with python3 -Wd.
Diffstat (limited to 'tests/test_cmdline.py')
-rw-r--r-- | tests/test_cmdline.py | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 6a285fcc..56036183 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -38,64 +38,68 @@ class CmdLineTest(unittest.TestCase): def test_L_opt(self): c, o, e = run_cmdline("-L") - self.assertEquals(c, 0) - self.assert_("Lexers" in o and "Formatters" in o and - "Filters" in o and "Styles" in o) + self.assertEqual(c, 0) + self.assertTrue("Lexers" in o and "Formatters" in o and + "Filters" in o and "Styles" in o) c, o, e = run_cmdline("-L", "lexer") - self.assertEquals(c, 0) - self.assert_("Lexers" in o and "Formatters" not in o) + self.assertEqual(c, 0) + self.assertTrue("Lexers" in o and "Formatters" not in o) c, o, e = run_cmdline("-L", "lexers") - self.assertEquals(c, 0) + self.assertEqual(c, 0) def test_O_opt(self): filename = TESTFILE c, o, e = run_cmdline("-Ofull=1,linenos=true,foo=bar", "-fhtml", filename) - self.assertEquals(c, 0) - self.assert_("<html" in o) - self.assert_('class="linenos"' in o) + self.assertEqual(c, 0) + self.assertTrue("<html" in o) + self.assertTrue('class="linenos"' in o) def test_P_opt(self): filename = TESTFILE c, o, e = run_cmdline("-Pfull", "-Ptitle=foo, bar=baz=,", "-fhtml", filename) - self.assertEquals(c, 0) - self.assert_("<title>foo, bar=baz=,</title>" in o) + self.assertEqual(c, 0) + self.assertTrue("<title>foo, bar=baz=,</title>" in o) def test_F_opt(self): filename = TESTFILE c, o, e = run_cmdline("-Fhighlight:tokentype=Name.Blubb," "names=TESTFILE filename", "-fhtml", filename) - self.assertEquals(c, 0) - self.assert_('<span class="n-Blubb' in o) + self.assertEqual(c, 0) + self.assertTrue('<span class="n-Blubb' in o) def test_H_opt(self): c, o, e = run_cmdline("-H", "formatter", "html") - self.assertEquals(c, 0) - self.assert_('HTML' in o) + self.assertEqual(c, 0) + self.assertTrue('HTML' in o) def test_S_opt(self): c, o, e = run_cmdline("-S", "default", "-f", "html", "-O", "linenos=1") - self.assertEquals(c, 0) + self.assertEqual(c, 0) def test_invalid_opts(self): for opts in [("-L", "-lpy"), ("-L", "-fhtml"), ("-L", "-Ox"), ("-a",), ("-Sst", "-lpy"), ("-H",), ("-H", "formatter"),]: - self.assert_(run_cmdline(*opts)[0] == 2) + self.assertTrue(run_cmdline(*opts)[0] == 2) def test_normal(self): # test that cmdline gives the same output as library api from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter filename = TESTFILE - code = open(filename, 'rb').read() + fp = open(filename, 'rb') + try: + code = fp.read() + finally: + fp.close() output = highlight(code, PythonLexer(), HtmlFormatter()) c, o, e = run_cmdline("-lpython", "-fhtml", filename) - self.assertEquals(o, output) - self.assertEquals(e, "") - self.assertEquals(c, 0) + self.assertEqual(o, output) + self.assertEqual(e, "") + self.assertEqual(c, 0) |