summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/extmod/uhashlib_final.py35
-rw-r--r--tests/extmod/uhashlib_final.py.exp1
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/extmod/uhashlib_final.py b/tests/extmod/uhashlib_final.py
new file mode 100644
index 000000000..f562cc178
--- /dev/null
+++ b/tests/extmod/uhashlib_final.py
@@ -0,0 +1,35 @@
+try:
+ import uhashlib
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+
+for algo_name in ("md5", "sha1", "sha256"):
+ algo = getattr(uhashlib, algo_name, None)
+ if not algo:
+ continue
+
+ # Running .digest() several times in row is not supported.
+ h = algo(b"123")
+ h.digest()
+ try:
+ h.digest()
+ print("fail")
+ except ValueError:
+ # Expected path, don't print anything so test output is the
+ # same even if the algorithm is not implemented on the port.
+ pass
+
+ # Partial digests are not supported.
+ h = algo(b"123")
+ h.digest()
+ try:
+ h.update(b"456")
+ print("fail")
+ except ValueError:
+ # Expected path, don't print anything so test output is the
+ # same even if the algorithm is not implemented on the port.
+ pass
+
+print("done")
diff --git a/tests/extmod/uhashlib_final.py.exp b/tests/extmod/uhashlib_final.py.exp
new file mode 100644
index 000000000..19f86f493
--- /dev/null
+++ b/tests/extmod/uhashlib_final.py.exp
@@ -0,0 +1 @@
+done