diff --git a/roles/htmlify-logs/library/htmlify.py b/roles/htmlify-logs/library/htmlify.py index a97b9b94d..2b02f0c3a 100644 --- a/roles/htmlify-logs/library/htmlify.py +++ b/roles/htmlify-logs/library/htmlify.py @@ -85,8 +85,8 @@ highlight_by_hash(); def run(inpath, outpath): if inpath.endswith('.gz'): - infile = gzip.open(inpath, 'r') - outfile = gzip.open(outpath, 'w') + infile = gzip.open(inpath, 'rt') + outfile = gzip.open(outpath, 'wt') else: infile = open(inpath, 'r') outfile = open(outpath, 'w') diff --git a/roles/htmlify-logs/library/test_htmlify.py b/roles/htmlify-logs/library/test_htmlify.py index a9abebc60..16aef34cf 100644 --- a/roles/htmlify-logs/library/test_htmlify.py +++ b/roles/htmlify-logs/library/test_htmlify.py @@ -28,9 +28,9 @@ FIXTURE_DIR = os.path.join(os.path.dirname(__file__), class TestHTMLify(testtools.TestCase): - def _test_file(self, fn): + def _test_file(self, fn, ref_fn): in_path = os.path.join(FIXTURE_DIR, 'in', fn) - ref_path = os.path.join(FIXTURE_DIR, 'reference', fn) + ref_path = os.path.join(FIXTURE_DIR, 'reference', ref_fn) out_root = self.useFixture(fixtures.TempDir()).path out_path = os.path.join(out_root, fn) run(in_path, out_path) @@ -45,4 +45,5 @@ class TestHTMLify(testtools.TestCase): self.assertEqual(reference_data, generated_data) def test_htmlify(self): - self._test_file('job-output.txt') + self._test_file('job-output.txt', 'job-output.txt') + self._test_file('job-output.txt.gz', 'job-output.txt')