示例#1
0
	def setUp(self):
		self.formatter = Formatter()
示例#2
0
class FormatterTest(unittest.TestCase):
	def setUp(self):
		self.formatter = Formatter()

	def testRun(self):
		out = subprocess.getoutput('echo "aaa" | ../fmake.py')
		self.assertEqual(out, 'aaa')

	def testLoadConfig(self):
		self.formatter.loadConfig('config_nocolor')

		fmt = self.formatter.fmt
		self.assertEqual(fmt['gcc'],  "[{0[cmd]}] ** [{0[tgt]}]")
		self.assertEqual(fmt['qt'],   "[{0[cmd]}] ** [{0[tgt]}]")
		self.assertEqual(fmt['warn'], "[{0[cmd]}] {0[loc]}{0[msg]}")
		self.assertEqual(fmt['err'],  "[{0[cmd]}] {0[loc]}{0[msg]}")
		self.assertEqual(fmt['info'], "[make] ** [{0[msg]}]")

	def testSubsNocolor(self):
		self.formatter.loadConfig('config_nocolor')
		for key in raw.keys():
			self.assertEqual(self.formatter.subsMake(raw[key]), fmt_nocol[key])

	def testSubsColor(self):
		self.formatter.loadConfig('config_color')
		for key in raw.keys():
			self.assertEqual(self.formatter.subsMake(raw[key]), fmt_col[key])

	def testSubsLong(self):
		self.formatter.setColumns(20)
		self.assertEqual(self.formatter.subsMake(long_raw), long_fmt)