Skip to content

Commit 8aac964

Browse files
committed
Debugging and test fixes for CI
test_compression_br worked on my box under python 3.6. In CI it worked in 3.4 but failed on all other versions 3.6,7,8,9,dev. Error: json_dict = json.loads(b2s(brotli.decompress(f.content))) E brotli.error: BrotliDecompress failed so print f.content. Also restructured the code to not check for type of f.content. Instead try json.loads(f.content) and if we get an exception try decompressing. Use this for br and zstd tests.
1 parent d2e2fee commit 8aac964

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/test_liveserver.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,13 @@ def test_compression_br(self):
529529
}'''
530530
content = json.loads(content_str)
531531

532+
print(f.content)
533+
print(type(f.content))
532534

533-
if (type("") == type(f.content)):
535+
try:
534536
json_dict = json.loads(f.content)
535-
else:
537+
except (ValueError):
538+
# Handle error from trying to load compressed data
536539
json_dict = json.loads(b2s(brotli.decompress(f.content)))
537540

538541
# etag wil not match, creation date different
@@ -673,9 +676,12 @@ def test_compression_zstd(self):
673676
content = json.loads(content_str)
674677

675678

676-
if (type("") == type(f.content)):
679+
try:
677680
json_dict = json.loads(f.content)
678-
else:
681+
except (ValueError, UnicodeDecodeError):
682+
# ValueError - raised by loads on compressed content python2
683+
# UnicodeDecodeError - raised by loads on compressed content
684+
# python3
679685
json_dict = json.loads(b2s(zstd.decompress(f.content)))
680686

681687
# etag wil not match, creation date different

0 commit comments

Comments
 (0)