def test_write_gzip_json(self): # This case also covers the Unicode testing of write_json(). 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) with open(tmp_path, 'rb') as f: with gzip.GzipFile(fileobj=f, mode='rb') as gf: with io.TextIOWrapper(gf, encoding='utf-8') as tf: round_trip = json.load(tf) self.assertDictEqual(obj, round_trip)
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)