MCPcopy Create free account
hub / github.com/ActiveState/code / test

Function test

recipes/Python/572181_Unicode_String_Hex_Dump/recipe-572181.py:57–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55 open(path, 'wb').write(encText)
56
57def test():
58 TEST = u"Copyright: \u00a9\r\nRegistered: \u00ae\r\nAlpha: \u03b1\r\nOmega: \u03c9\r\n\Em dash: \u2015\r\n"
59
60 print dump("ascii " + TEST.encode("ascii", "replace"))
61 print dump("Latin-1 " + TEST.encode("Latin-1", "replace"))
62 print dump("utf8 " + TEST.encode("utf8", "replace"))
63 print dump("utf16 " + TEST.encode("utf16", "replace"))
64 print dump("utf-16-be " + TEST.encode("utf-16-be", "replace"))
65 print dump("utf-16-le " + TEST.encode("utf-16-le", "replace"))
66 print dump("unicode " + TEST)
67
68 DELETE_ME_TXT = "deleteme.txt"
69 writeFile(DELETE_ME_TXT, TEST, "utf8")
70 uniText = readFile(DELETE_ME_TXT, "utf8")
71 assert (uniText == TEST)
72
73if __name__ == "__main__":
74 test()

Callers 1

recipe-572181.pyFile · 0.70

Calls 4

writeFileFunction · 0.85
dumpFunction · 0.70
readFileFunction · 0.70
encodeMethod · 0.45

Tested by

no test coverage detected