Skip to content

Commit 9669873

Browse files
committed
Accept uppercase hex in object-address assertions
CPython renders id() as uppercase hex on Windows, so the two error-message assertions in test_inject_from_container.py fail there while passing on the Linux-only CI matrix. Widen the character class and hoist the pattern into a named constant, which also keeps the lines inside the 120-column limit.
1 parent 074eddd commit 9669873

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

test/unit/test_inject_from_container.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
from test.unit.services.no_annotations.random.random_service import RandomService
1919
from test.unit.services.with_annotations.services import Foo, FooImpl, OtherFooImpl, random_service_factory
2020

21+
# CPython renders id() as uppercase hex on Windows and lowercase elsewhere.
22+
HEX_ADDR = r"0x[0-9a-fA-F]+"
23+
2124

2225
async def test_injects_targets(container: Container) -> None:
2326
class NotManagedByWireup: ...
@@ -149,7 +152,7 @@ class NotManagedByWireup: ...
149152
with pytest.raises(
150153
WireupError,
151154
match=(
152-
r"Parameter 'not_managed_by_wireup' of <function .*test_raises_on_unknown_service.*\._ at 0x[0-9a-f]+> "
155+
rf"Parameter 'not_managed_by_wireup' of <function .*test_raises_on_unknown_service.*\._ at {HEX_ADDR}> "
153156
+ re.escape(f"has an unknown dependency on {NotManagedByWireup!r}{expected_qualifier_str}.")
154157
),
155158
):
@@ -164,7 +167,7 @@ async def test_raises_on_unknown_parameter(container: Container) -> None:
164167
with pytest.raises(
165168
WireupError,
166169
match=(
167-
r"Parameter 'not_managed_by_wireup' of <function .*test_raises_on_unknown_parameter.*\._ at 0x[0-9a-f]+> "
170+
rf"Parameter 'not_managed_by_wireup' of <function .*test_raises_on_unknown_parameter.*\._ at {HEX_ADDR}> "
168171
+ re.escape("depends on an unknown Wireup config key 'invalid'.")
169172
),
170173
):

0 commit comments

Comments
 (0)