mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-08 19:40:37 +00:00
Python: rework the load_file API, part 2
Take arguments for configuring style, etc., throw an exception on errors, and log warning diagnostics.
This commit is contained in:
parent
280f314eeb
commit
765c773b90
3 changed files with 47 additions and 5 deletions
|
@ -1,13 +1,22 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
||||
|
||||
from slint import load_file
|
||||
import pytest
|
||||
from slint import load_file, CompileError
|
||||
import os
|
||||
|
||||
|
||||
def test_load_file():
|
||||
def test_load_file(caplog):
|
||||
module = load_file(os.path.join(os.path.dirname(
|
||||
__spec__.origin), "test_load_file.slint"))
|
||||
__spec__.origin), "test_load_file.slint"), quiet=False)
|
||||
|
||||
assert "The property 'color' has been deprecated. Please use 'background' instead" in caplog.text
|
||||
|
||||
assert list(module.__dict__.keys()) == ["App"]
|
||||
instance = module.App()
|
||||
del instance
|
||||
|
||||
|
||||
def test_load_file_fail():
|
||||
with pytest.raises(CompileError, match="Could not compile non-existent.slint"):
|
||||
load_file("non-existent.slint")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue