From c25502afe90e6589e711aca6975db981cbf2275d Mon Sep 17 00:00:00 2001 From: roedoejet Date: Tue, 5 Oct 2021 14:58:04 -0700 Subject: [PATCH] fix(test): fix mimetype issue with test for b64 encoding --- test/test_align_cli.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/test_align_cli.py b/test/test_align_cli.py index cee8184e..375fe9b5 100755 --- a/test/test_align_cli.py +++ b/test/test_align_cli.py @@ -2,6 +2,7 @@ import io import os +import re import tempfile from os.path import exists, join from unittest import TestCase, main @@ -146,20 +147,15 @@ def test_invoke_align(self): with open(join(output, "html", "html.html"), "rb") as fhtml: path_bytes = fhtml.read() htmldoc = fromstring(path_bytes) - self.assertTrue( - htmldoc.body.xpath("//read-along")[0] - .attrib["text"] - .startswith("data:application/xml;base64,") + b64_pattern = r"data:[\w\/\+]*;base64,\w*" + self.assertRegex( + htmldoc.body.xpath("//read-along")[0].attrib["text"], b64_pattern ) - self.assertTrue( - htmldoc.body.xpath("//read-along")[0] - .attrib["alignment"] - .startswith("data:application/smil+xml;base64,") + self.assertRegex( + htmldoc.body.xpath("//read-along")[0].attrib["alignment"], b64_pattern ) - self.assertTrue( - htmldoc.body.xpath("//read-along")[0] - .attrib["audio"] - .startswith("data:audio/mp4;base64,") + self.assertRegex( + htmldoc.body.xpath("//read-along")[0].attrib["audio"], b64_pattern ) # Functionally the same as self.assertTrue(filecmp.cmp(f1, f2)), but show where