htmlify: fix py3 gzip issue
Actually test the gzip path, and correct a bytes/str issue under python3 (the file should be opened as text). Change-Id: Icc5362d3d020761e07e60fb8ee296c98a8fe3ac4
This commit is contained in:
parent
3b6429938b
commit
15ba4de7e6
@ -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')
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user