def expand_to_dict(css, expected_error=None):
    """Helper to test shorthand properties expander functions."""
    declarations = tinycss2.parse_blocks_contents(css)

    with capture_logs() as logs:
        base_url = 'https://weasyprint.org/foo/'
        declarations = list(preprocess_declarations(base_url, declarations))

    if expected_error:
        assert len(logs) == 1
        assert expected_error in logs[0]
    else:
        assert not logs

    return {
        name: value for name, value, _ in declarations if value != 'initial'}
Helper to test shorthand properties expander functions.
tests/css/test_expanders.py