def test_test_non_decorated_formatter(self): formatter = Formatter(False) self.assertTrue(formatter.has_style('error')) self.assertTrue(formatter.has_style('info')) self.assertTrue(formatter.has_style('comment')) self.assertTrue(formatter.has_style('question')) self.assertEqual('some error', formatter.format('<error>some error</error>')) self.assertEqual('some info', formatter.format('<info>some info</info>')) self.assertEqual('some comment', formatter.format('<comment>some comment</comment>')) self.assertEqual( 'some question', formatter.format('<question>some question</question>')) formatter.set_decorated(True) self.assertEqual('\033[37;41msome error\033[0m', formatter.format('<error>some error</error>')) self.assertEqual('\033[32msome info\033[0m', formatter.format('<info>some info</info>')) self.assertEqual('\033[33msome comment\033[0m', formatter.format('<comment>some comment</comment>')) self.assertEqual( '\033[30;46msome question\033[0m', formatter.format('<question>some question</question>'))
def test_bundled_styles(self): formatter = Formatter(True) self.assertTrue(formatter.has_style('error')) self.assertTrue(formatter.has_style('info')) self.assertTrue(formatter.has_style('comment')) self.assertTrue(formatter.has_style('question')) self.assertEqual('\033[37;41msome error\033[0m', formatter.format('<error>some error</error>')) self.assertEqual('\033[32msome info\033[0m', formatter.format('<info>some info</info>')) self.assertEqual('\033[33msome comment\033[0m', formatter.format('<comment>some comment</comment>')) self.assertEqual( '\033[30;46msome question\033[0m', formatter.format('<question>some question</question>'))