Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
Unreleased
----------

* Avoid crashing when test node IDs contain surrogate characters from undecodable filesystem names.
In that situation, pytest’s independent cache serialization limitation still requires ``-p no:cacheprovider``.

* Drop Python 3.10 support.

5.0.0 (2026-09-01)
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_randomly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def reduce_list_of_lists(lists: list[list[T]]) -> list[T]:

@lru_cache
def _crc32(string: str) -> int:
return crc32(string.encode())
return crc32(string.encode(errors="surrogatepass"))


if have_faker: # pragma: no branch
Expand Down
14 changes: 14 additions & 0 deletions tests/test_pytest_randomly.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import shutil
import sys
from unittest import mock

import pytest
Expand Down Expand Up @@ -884,3 +885,16 @@ def test_xdist(n, ourtester):

# Can't make any assertion on the order, since output comes back from
# workers non-deterministically


@pytest.mark.skipif(
sys.platform == "win32", reason="Requires byte-based filesystem names"
)
def test_undecodable_filename(ourtester):
path = ourtester.path / "test_\udcff.py"
path.write_text("def test_one():\n assert True\n", encoding="utf-8")

# The cache provider independently cannot persist surrogate-containing node IDs.
result = ourtester.runpytest("-p", "no:cacheprovider", "--randomly-seed=1")

result.assert_outcomes(passed=1)