mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 16:37:47 +03:00
Log warning when unknown rendering option is given
This commit is contained in:
parent
5441f326dd
commit
1f41486af4
@ -305,6 +305,15 @@ def test_python_render(assert_pixels_equal, tmp_path):
|
||||
).write_png() == rotated_png_bytes
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_unknown_options():
|
||||
with capture_logs() as logs:
|
||||
pdf_bytes = FakeHTML(string='test').write_pdf(zoom=2, unknown=True)
|
||||
assert len(logs) == 1
|
||||
assert 'unknown' in logs[0]
|
||||
assert pdf_bytes
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_command_line_render(tmp_path):
|
||||
css = b'''
|
||||
|
@ -210,6 +210,8 @@ class HTML:
|
||||
:returns: A :class:`document.Document` object.
|
||||
|
||||
"""
|
||||
for unknown in set(options) - set(DEFAULT_OPTIONS):
|
||||
LOGGER.warning('Unknown rendering option: %s.', unknown)
|
||||
new_options = DEFAULT_OPTIONS.copy()
|
||||
new_options.update(options)
|
||||
options = new_options
|
||||
|
@ -165,7 +165,8 @@ def main(argv=None, stdout=None, stdin=None, HTML=HTML): # noqa: N803
|
||||
if args.timeout is not None:
|
||||
url_fetcher = partial(default_url_fetcher, timeout=args.timeout)
|
||||
|
||||
options = vars(args)
|
||||
options = {
|
||||
key: value for key, value in vars(args).items() if key in DEFAULT_OPTIONS}
|
||||
|
||||
# Default to logging to stderr.
|
||||
if args.debug:
|
||||
|
Loading…
Reference in New Issue
Block a user