def test_main_error(self): with self.withBytesOutput() as (out, err): args = ['color-cat', os.path.join('tests', 'resources', 'test_01_not_exist.txt')] ret = color_cat.main(args, stdout=out, stderr=err) self.assertEqual(ret, 1) self.assertEqual(out.getvalue(), b'') self.assertTrue(b'No such file or directory' in err.getvalue())
def test_main(self): with self.withBytesOutput() as (out, err): args = ['color-cat', os.path.join('tests', 'resources', 'test_01.txt'), os.path.join('tests', 'resources', 'test_02.txt')] ret = color_cat.main(args, stdout=out, stderr=err) self.assertEqual(ret, 0) self.assertEqual(out.getvalue(), b'\x1b[31mfoo\x1b[0m\n\x1b[31mbar\x1b[0m\n\x1b[31mbaz\x1b[0m\n' b'\x1b[31m123\x1b[0m\n\x1b[31m456\x1b[0m\n\x1b[31m789\x1b[0m\n') self.assertEqual(err.getvalue(), b'')