MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / test_hmac_sha256_kwargs

Function test_hmac_sha256_kwargs

scripts/test_stringzilla.py:1124–1162  ·  view source on GitHub ↗

Test hmac_sha256 with keyword arguments

()

Source from the content-addressed store, hash-verified

1122
1123
1124def test_hmac_sha256_kwargs():
1125 """Test hmac_sha256 with keyword arguments"""
1126 key = b"secret"
1127 message = b"Hello, world!"
1128
1129 # Test against Python's hmac module
1130 expected = hmac.new(key, message, hashlib.sha256).digest()
1131
1132 # Test with positional arguments
1133 result_positional = sz.hmac_sha256(key, message)
1134 assert result_positional == expected
1135
1136 # Test with keyword arguments (as shown in README line 483)
1137 result_kwargs = sz.hmac_sha256(key=key, message=message)
1138 assert result_kwargs == expected
1139
1140 # Test with mixed arguments
1141 result_mixed = sz.hmac_sha256(key, message=message)
1142 assert result_mixed == expected
1143
1144 # Test with reversed keyword arguments
1145 result_reversed = sz.hmac_sha256(message=message, key=key)
1146 assert result_reversed == expected
1147
1148 # Missing argument
1149 with pytest.raises(TypeError, match="expects exactly 2 arguments"):
1150 sz.hmac_sha256(key=key)
1151
1152 # Duplicate argument
1153 with pytest.raises(TypeError, match="key specified twice"):
1154 sz.hmac_sha256(key, key=key)
1155
1156 # Unknown keyword argument (only detected when total args == 2)
1157 with pytest.raises(TypeError, match="unexpected keyword argument"):
1158 sz.hmac_sha256(key=key, unknown=b"test")
1159
1160 # Too many arguments (3 args)
1161 with pytest.raises(TypeError, match="expects exactly 2 arguments"):
1162 sz.hmac_sha256(key=key, message=message, unknown=b"test")
1163
1164
1165@pytest.mark.parametrize("list_length", [10, 20, 30, 40, 50])

Callers

nothing calls this directly

Calls 2

digestMethod · 0.45
newMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…