Merge branch '7454-azure-custom-data' closes #7454
[arvados.git] / tools / crunchstat-summary / tests / test_examples.py
1 import crunchstat_summary.command
2 import crunchstat_summary.summarizer
3 import difflib
4 import glob
5 import os
6 import unittest
7
8
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)
17             summarizer.run()
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)")))