Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
History
=======

* Work on FIPS Python 3.9+, by declaring use of ``hashlib.md5()`` as not used for security.

Thanks to dantebben for the report in `Issue #414 <https://github.com/pytest-dev/pytest-randomly/issues/414>`__.

3.10.2 (2021-11-10)
-------------------

Expand Down
4 changes: 3 additions & 1 deletion src/pytest_randomly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from _pytest.nodes import Item
from pytest import Collector, fixture, hookimpl

from pytest_randomly.compat import md5

if sys.version_info < (3, 10):
from importlib_metadata import entry_points
else:
Expand Down Expand Up @@ -274,7 +276,7 @@ def reduce_list_of_lists(lists: List[List[T]]) -> List[T]:


def _md5(string: str) -> bytes:
hasher = hashlib.md5()
hasher = md5()
hasher.update(string.encode())
return hasher.digest()

Expand Down
8 changes: 8 additions & 0 deletions src/pytest_randomly/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import hashlib
import sys
from functools import partial

if sys.version_info >= (3, 9):
md5 = partial(hashlib.md5, usedforsecurity=False)
else:
md5 = hashlib.md5