示例#1
0
 def test_write_gzip_json(self):
     obj = {
         'results': [{
             'test':
             'ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ',
             'message': None,
             'status': 'PASS'
         }]
     }
     tmp_path = os.path.join(self.tmp_dir, 'foo', 'bar.json.gz')
     WPTReport.write_gzip_json(tmp_path, obj)
     r = WPTReport()
     with open(tmp_path, 'rb') as f:
         r.load_gzip_json(f)
     self.assertDictEqual(obj, r._report)
示例#2
0
    def test_load_gzip_json(self):
        # This case also covers the Unicode testing of load_json().
        obj = {
            'results': [{
                'test':
                'ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ',
                'message': None,
                'status': 'PASS'
            }]
        }
        json_s = json.dumps(obj, ensure_ascii=False)
        tmp_path = os.path.join(self.tmp_dir, 'test.json.gz')
        with open(tmp_path, 'wb') as f:
            gzip_file = gzip.GzipFile(fileobj=f, mode='wb')
            gzip_file.write(json_s.encode('utf-8'))
            gzip_file.close()

        r = WPTReport()
        with open(tmp_path, 'rb') as f:
            r.load_gzip_json(f)
        self.assertDictEqual(r._report, obj)