Skip to content

Commit 0c81b98

Browse files
committed
test: add None rejection tests for all entry points
Verify None raises TypeError for one-shot functions, constructors (both positional and keyword), and update().
1 parent ca52fd2 commit 0c81b98

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/test_hashlib_compat.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def test_str_rejected(self):
3131
with self.assertRaisesRegex(TypeError,
3232
'Strings must be encoded before hashing'):
3333
fn(data='hello')
34+
# None
35+
with self.assertRaises(TypeError):
36+
fn(None)
3437

3538
def test_str_rejected_constructor(self):
3639
for algo in ('xxh32', 'xxh64', 'xxh3_64', 'xxh3_128'):
@@ -43,6 +46,11 @@ def test_str_rejected_constructor(self):
4346
with self.assertRaisesRegex(TypeError,
4447
'Strings must be encoded before hashing'):
4548
cls(data='hello')
49+
# None
50+
with self.assertRaises(TypeError):
51+
cls(None)
52+
with self.assertRaises(TypeError):
53+
cls(data=None)
4654

4755
def test_str_rejected_update(self):
4856
for algo in ('xxh32', 'xxh64', 'xxh3_64', 'xxh3_128'):
@@ -53,6 +61,9 @@ def test_str_rejected_update(self):
5361
# also test that bytes work after
5462
obj.update(b'hello')
5563
self.assertIsInstance(obj.intdigest(), int)
64+
# None
65+
with self.assertRaises(TypeError):
66+
obj.update(None)
5667

5768
# ── data keyword ───────────────────────────────────────────────
5869

0 commit comments

Comments
 (0)