From b6ebb4f04e45e5db597ad32ab25cdc60261eabd2 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 19 Aug 2018 12:04:03 +0300 Subject: [PATCH] tests/extmod/uhashlib_md5: Add coverage tests for MD5 algorithm. Based on tests/extmod/uhashlib_sha1. --- tests/extmod/uhashlib_md5.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/extmod/uhashlib_md5.py diff --git a/tests/extmod/uhashlib_md5.py b/tests/extmod/uhashlib_md5.py new file mode 100644 index 0000000000..10b6d054e7 --- /dev/null +++ b/tests/extmod/uhashlib_md5.py @@ -0,0 +1,21 @@ +try: + import uhashlib as hashlib +except ImportError: + try: + import hashlib + except ImportError: + # This is neither uPy, nor cPy, so must be uPy with + # uhashlib module disabled. + print("SKIP") + raise SystemExit + +try: + hashlib.md5 +except AttributeError: + # MD5 is only available on some ports + print("SKIP") + raise SystemExit + +md5 = hashlib.md5(b'hello') +md5.update(b'world') +print(md5.digest())