http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11631
Revision: 11631 Author: valhallasw Date: 2013-06-08 22:38:42 +0000 (Sat, 08 Jun 2013) Log Message: ----------- + unix coloring tests
Modified Paths: -------------- branches/rewrite/tests/ui_tests.py
Modified: branches/rewrite/tests/ui_tests.py =================================================================== --- branches/rewrite/tests/ui_tests.py 2013-06-08 22:25:52 UTC (rev 11630) +++ branches/rewrite/tests/ui_tests.py 2013-06-08 22:38:42 UTC (rev 11631) @@ -232,8 +232,40 @@ self.assertIsInstance(returned, unicode) self.assertEqual(returned, "n")
+ class TestTerminalOutputColorUnix(unittest.TestCase): + def setUp(self): + patch() + newstdout.truncate(0) + newstderr.truncate(0) + newstdin.truncate(0)
+ def tearDown(self): + unpatch()
+ def testOutputColorizedText(self): + pywikibot.config.colorized_output = True + pywikibot.output(u"normal text \03{lightpurple}light purple text\03{default} normal text") + self.assertEqual(newstdout.getvalue(), "") + self.assertEqual(newstderr.getvalue(), "normal text \x1b[35;1mlight purple text\x1b[0m normal text\n\x1b[0m") + + @unittest.expectedFailure + def testOutputNoncolorizedText(self): + pywikibot.config.colorized_output = False + pywikibot.output(u"normal text \03{lightpurple}light purple text\03{default} normal text") + self.assertEqual(newstdout.getvalue(), "") + self.assertEqual(newstderr.getvalue(), "normal text light purple text normal text ***") + + @unittest.expectedFailure + def testOutputColorCascade(self): + pywikibot.config.colorized_output = True + pywikibot.output(u"normal text \03{lightpurple} light purple \03{lightblue} light blue \03{default} light purple \03{default} normal text") + self.assertEqual(newstdout.getvalue(), "") + self.assertEqual(newstderr.getvalue(), "normal text \x1b[35;1m light purple \x1b[94;1m light blue \x1b[35;1m light purple \x1b[0m normal text\n\x1b[0m") + + + + + try: try: unittest.main()
pywikipedia-svn@lists.wikimedia.org