1 import crunchstat_summary.command
2 import crunchstat_summary.summarizer
9 class ExampleLogsTestCase(unittest.TestCase):
10 def test_example_files(self):
11 dirname = os.path.dirname(os.path.abspath(__file__))
12 for fnm in glob.glob(os.path.join(dirname, '*.txt.gz')):
13 logfile = os.path.join(dirname, fnm)
14 args = crunchstat_summary.command.ArgumentParser().parse_args(
15 ['--log-file', logfile])
16 summarizer = crunchstat_summary.summarizer.Summarizer(args)
18 got = [x+"\n" for x in summarizer.report().strip("\n").split("\n")]
19 expectfile = logfile+'.report'
20 expect = open(expectfile).readlines()
21 self.assertEqual(got, expect, "\n"+"".join(difflib.context_diff(
22 expect, got, fromfile=expectfile, tofile="(generated)")))