Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename hash_bytes() to hash_buffer() in tests
  • Loading branch information
vstinner committed Aug 27, 2024
commit ef25088d02cbbb6566c17517a8dbb264fb40098f
6 changes: 3 additions & 3 deletions Lib/test/test_capi/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def python_hash_pointer(x):
VOID_P_MAX = -1 & (2 ** (8 * SIZEOF_VOID_P) - 1)
self.assertEqual(hash_pointer(VOID_P_MAX), -2)

def test_hash_bytes(self):
hash_bytes = _testcapi.hash_bytes
def test_hash_buffer(self):
hash_buffer = _testcapi.hash_buffer

def check(data):
Comment thread
picnixz marked this conversation as resolved.
self.assertEqual(hash_bytes(data), hash(data))
self.assertEqual(hash_buffer(data), hash(data))

check(b'')
check(b'abc')
Expand Down
4 changes: 2 additions & 2 deletions Modules/_testcapi/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ hash_pointer(PyObject *Py_UNUSED(module), PyObject *arg)


static PyObject *
hash_bytes(PyObject *Py_UNUSED(module), PyObject *args)
hash_buffer(PyObject *Py_UNUSED(module), PyObject *args)
{
char *ptr;
Py_ssize_t len;
Expand All @@ -92,7 +92,7 @@ object_generichash(PyObject *Py_UNUSED(module), PyObject *arg)
static PyMethodDef test_methods[] = {
{"hash_getfuncdef", hash_getfuncdef, METH_NOARGS},
{"hash_pointer", hash_pointer, METH_O},
{"hash_bytes", hash_bytes, METH_VARARGS},
{"hash_buffer", hash_buffer, METH_VARARGS},
{"object_generichash", object_generichash, METH_O},
{NULL},
};
Expand Down