Skip to content

Commit ab19eeb

Browse files
committed
Further encoding shenanigans to make test pass in TravisCI environment.
1 parent 7039a4f commit ab19eeb

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/utility_classes/test_buttons.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,25 @@ def test_ButtonTheme_from_js_literal(input_files, filename, as_file, error):
364364

365365

366366
def test_issue86_ButtonTheme_to_json():
367+
try:
368+
import orjson as json
369+
except ImportError:
370+
print('using standard library')
371+
import json
372+
367373
kwargs = STANDARD_PARAMS_5[1][0]
368374
instance = cls5(**kwargs)
369375

370376
assert instance['states'] is not None
371377
assert instance['states'].hover is not None
372378

373-
result = str(instance.to_json(), encoding = 'utf-8')
374-
assert result == str(kwargs).replace("'", '"')
379+
input_as_json = json.dumps(kwargs)
380+
print(type(input_as_json))
381+
382+
result_as_json = instance.to_json()
383+
if isinstance(result_as_json, str) and isinstance(input_as_json, bytes):
384+
result_as_json = result_as_json.encode('utf-8')
385+
elif isinstance(result_as_json, bytes) and isinstance(input_as_json, str):
386+
input_as_json = input_as_json.encode('utf-8')
387+
388+
assert result_as_json == input_as_json

0 commit comments

Comments
 (0)