From 9e9260f996d212bf08547b3c3489a26aeb01e8dd Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Sat, 9 Nov 2019 18:16:15 +0000 Subject: [PATCH] Unit test for commentjson --- tests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests.py b/tests.py index c345dbaf4..72917a0f3 100644 --- a/tests.py +++ b/tests.py @@ -1598,8 +1598,26 @@ def testGetStatusNumber(): assert int(statusNumber) > prevStatusNumber prevStatusNumber=int(statusNumber) +def testCommentJson() -> None: + 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, ensure_ascii=False) + assert messageStr in encodedStr + def runAllTests(): print('Running tests...') + testCommentJson() testGetStatusNumber() testAddEmoji() testWebLinks()