diff --git a/testing/io/test_saferepr.py b/testing/io/test_saferepr.py index 3af31824c..7dd56164a 100644 --- a/testing/io/test_saferepr.py +++ b/testing/io/test_saferepr.py @@ -6,6 +6,7 @@ from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE from _pytest._io.saferepr import saferepr from _pytest._io.saferepr import saferepr_unlimited import pytest +import re def test_simple_repr(): @@ -207,13 +208,11 @@ class TestSafereprUnbounded: def test_saferepr_unbounded(self): """saferepr() of an unbound method should still show the full information""" obj = self.Help() - # On windows, id adds leading zeros - obj_id = re.sub(r"^0+", "", f"{id(obj):x}").lower() - - assert ( - saferepr(obj) - == f"" + # using id() to fetch memory address fails on different platforms + pattern = re.compile( + r"", ) + assert pattern.match(saferepr(obj)) assert ( saferepr(self.Help) == f""