mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 00:21:15 +03:00
Fix some tests
This commit is contained in:
parent
370f87dce1
commit
eaeef5128d
@ -148,7 +148,7 @@ def safe_urljoin(base_url, url):
|
||||
return iri_to_uri(urljoin(base_url, url))
|
||||
else:
|
||||
raise InvalidValues(
|
||||
'Relative URI reference without a base URI: {url!r}')
|
||||
f'Relative URI reference without a base URI: {url!r}')
|
||||
|
||||
|
||||
def comma_separated_list(function):
|
||||
|
@ -81,7 +81,7 @@ def preprocess_declarations(base_url, declarations):
|
||||
|
||||
def validation_error(level, reason):
|
||||
getattr(LOGGER, level)(
|
||||
'Ignored "%s:%s" at %d:%d, %s.',
|
||||
'Ignored `%s:%s` at %d:%d, %s.',
|
||||
declaration.name, serialize(declaration.value),
|
||||
declaration.source_line, declaration.source_column, reason)
|
||||
|
||||
@ -96,7 +96,7 @@ def preprocess_declarations(base_url, declarations):
|
||||
name = unprefixed_name
|
||||
elif unprefixed_name in UNSTABLE:
|
||||
LOGGER.warning(
|
||||
'Deprecated "%s:%s" at %d:%d, '
|
||||
'Deprecated `%s:%s` at %d:%d, '
|
||||
'prefixes on unstable attributes are deprecated, '
|
||||
'use %r instead.',
|
||||
declaration.name, serialize(declaration.value),
|
||||
@ -105,7 +105,7 @@ def preprocess_declarations(base_url, declarations):
|
||||
name = unprefixed_name
|
||||
else:
|
||||
LOGGER.warning(
|
||||
'Ignored "%s:%s" at %d:%d, '
|
||||
'Ignored `%s:%s` at %d:%d, '
|
||||
'prefix on this attribute is not supported, '
|
||||
'use %r instead.',
|
||||
declaration.name, serialize(declaration.value),
|
||||
|
@ -58,7 +58,7 @@ def preprocess_descriptors(rule, base_url, descriptors):
|
||||
result = ((descriptor.name, value),)
|
||||
except InvalidValues as exc:
|
||||
LOGGER.warning(
|
||||
'Ignored "%s:%s" at %d:%d, %s.',
|
||||
'Ignored `%s:%s` at %d:%d, %s.',
|
||||
descriptor.name, tinycss2.serialize(descriptor.value),
|
||||
descriptor.source_line, descriptor.source_column,
|
||||
exc.args[0] if exc.args and exc.args[0] else 'invalid value')
|
||||
|
@ -82,7 +82,7 @@ def validate_non_shorthand(base_url, name, tokens, required=False):
|
||||
if not required and name not in KNOWN_PROPERTIES:
|
||||
hyphens_name = name.replace('_', '-')
|
||||
if hyphens_name in KNOWN_PROPERTIES:
|
||||
raise InvalidValues(f'did you mean "{hyphens_name}"?')
|
||||
raise InvalidValues(f'you probably mean "{hyphens_name}"')
|
||||
else:
|
||||
raise InvalidValues('unknown property')
|
||||
|
||||
|
@ -22,6 +22,7 @@ import pytest
|
||||
from PIL import Image
|
||||
|
||||
from .. import CSS, HTML, __main__, default_url_fetcher
|
||||
from ..document import resolve_links
|
||||
from ..urls import path2url
|
||||
from .test_draw import assert_pixels_equal, parse_pixels
|
||||
from .testing_utils import (
|
||||
@ -110,10 +111,7 @@ def _png_size(png_bytes):
|
||||
|
||||
|
||||
def _round_meta(pages):
|
||||
"""Eliminate errors of floating point arithmetic for metadata.
|
||||
(eg. 49.99999999999994 instead of 50)
|
||||
|
||||
"""
|
||||
"""Eliminate errors of floating point arithmetic for metadata."""
|
||||
for page in pages:
|
||||
anchors = page.anchors
|
||||
for anchor_name, (pos_x, pos_y) in anchors.items():
|
||||
@ -127,8 +125,8 @@ def _round_meta(pages):
|
||||
links[i] = link
|
||||
bookmarks = page.bookmarks
|
||||
for i, (level, label, (pos_x, pos_y), state) in enumerate(bookmarks):
|
||||
bookmarks[i] = (level, label,
|
||||
(round(pos_x, 6), round(pos_y, 6)), state)
|
||||
bookmarks[i] = (
|
||||
level, label, (round(pos_x, 6), round(pos_y, 6)), state)
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
@ -693,7 +691,7 @@ def test_links():
|
||||
document = FakeHTML(string=html, base_url=base_url).render()
|
||||
if round:
|
||||
_round_meta(document.pages)
|
||||
resolved_links = list(document.resolve_links())
|
||||
resolved_links = list(resolve_links(document.pages))
|
||||
assert len(logs) == len(warnings)
|
||||
for message, expected in zip(logs, warnings):
|
||||
assert expected in message
|
||||
|
@ -114,7 +114,7 @@ def test_spacing(rule, result):
|
||||
@assert_no_logs
|
||||
def test_spacing_warning():
|
||||
assert expand_to_dict(
|
||||
'letter_spacing: normal', 'did you mean letter-spacing?') == {}
|
||||
'letter_spacing: normal', 'you probably mean "letter-spacing"') == {}
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
|
Loading…
Reference in New Issue
Block a user