From 92de053e937c9f4cf6e9104f85ba25f624c0a8ef Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 9 Nov 2019 12:13:39 +0000 Subject: [PATCH] Extra commentjson tests --- tests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests.py b/tests.py index b0e5ba29..cce1f68a 100644 --- a/tests.py +++ b/tests.py @@ -1600,8 +1600,26 @@ def testGetStatusNumber(): assert int(statusNumber) > prevStatusNumber prevStatusNumber=int(statusNumber) +def testCommentJson(): + print('testCommentJson') + filename='/tmp/test.json' + messageStr="Crème brûlée यह एक परीक्षण ह" + testJson={ + "content": messageStr + } + with open(filename, 'w') as fp: + commentjson.dump(testJson, fp, indent=2, sort_keys=False) + receivedJson=None + with open(filename, 'r') as fp: + receivedJson=commentjson.load(fp) + assert receivedJson + assert receivedJson['content']==messageStr + encodedStr=json.dumps(testJson) + assert 'Cr\\u00e8me br\\u00fbl\\u00e9e \\u092f\\u0939 \\u090f\\u0915 \\u092a\\u0930\\u0940\\u0915\\u094d\\u0937\\u0923 \\u0939' in encodedStr + def runAllTests(): print('Running tests...') + testCommentJson() testGetStatusNumber() testAddEmoji() testWebLinks()