test(layout): keep css contract failures focused on assertions (#5545)

This commit is contained in:
Rod Boev 2026-07-04 19:55:37 -04:00
parent 0fc78da5ff
commit 33d9b9f2a7

View file

@ -31,9 +31,14 @@ def _media_blocks(kind):
return blocks
def _normalize_css(css):
return re.sub(r"\s+", "", css)
def _media_block(kind, width_px, needle):
normalized_needle = _normalize_css(needle)
for current_width, block in _media_blocks(kind):
if current_width == width_px and needle in block:
if current_width == width_px and normalized_needle in _normalize_css(block):
return block
raise AssertionError(f"Missing @media({kind}:{width_px}px) block containing {needle!r}")