Commit 9601163e authored by Nikki Sharpley's avatar Nikki Sharpley
Browse files

Bug 1554203 - [mozlog] Move formatter tests to one location and refactor r=jgraham

As the number of tests have grown considerably, for clarity, this patch
moves the formatter tests in test_structured.py to test_formatters.py.

html.py and its corresponding test were also amended to account for
discrepancies in the way Python 2 and 3 handle strings (bytes vs text type).

Differential Revision: https://phabricator.services.mozilla.com/D33048

--HG--
extra : moz-landing-system : lando
parent 78657c15
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@ class HTMLFormatter(base.BaseFormatter):
                    if not isinstance(content, (six.text_type, six.binary_type)):
                        # All types must be json serializable
                        content = json.dumps(content)
                        # Decode to text type if JSON output is byte string
                        if not isinstance(content, six.text_type):
                            content = content.decode('utf-8')
                    # Encode base64 to avoid that some browsers (such as Firefox, Opera)
                    # treats '#' as the start of another link if it is contained in the data URL.
                    if isinstance(content, six.text_type):
+1 −1
Original line number Diff line number Diff line
@@ -347,7 +347,7 @@ class TestHTMLFormatter(FormatterTest):
        self.logger.test_end("int_test", "FAIL",
                             extra={"data": {"foo": "bar"}})
        self.logger.suite_end()
        self.assertIn("data:text/html;base64,eyJmb28iOiAiYmFyIn0=",
        self.assertIn("data:text/html;charset=utf-8;base64,eyJmb28iOiAiYmFyIn0=",
                      ''.join(self.loglines))