mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-12 05:16:48 +00:00
Python: run mypy on the tests
This commit is contained in:
parent
c111098e49
commit
607d70b3fa
21 changed files with 169 additions and 69 deletions
|
@ -4,11 +4,18 @@
|
|||
import pytest
|
||||
from slint import load_file, CompileError
|
||||
import os
|
||||
from typing import cast
|
||||
|
||||
|
||||
def test_load_file(caplog):
|
||||
module = load_file(os.path.join(os.path.dirname(
|
||||
__spec__.origin), "test-load-file.slint"), quiet=False)
|
||||
def base_dir() -> str:
|
||||
origin = __spec__.origin
|
||||
assert origin is not None
|
||||
base_dir = os.path.dirname(origin)
|
||||
assert base_dir is not None
|
||||
return base_dir
|
||||
|
||||
def test_load_file(caplog: pytest.LogCaptureFixture) -> None:
|
||||
module = load_file(os.path.join(base_dir(), "test-load-file.slint"), quiet=False)
|
||||
|
||||
assert "The property 'color' has been deprecated. Please use 'background' instead" in caplog.text
|
||||
|
||||
|
@ -35,14 +42,13 @@ def test_load_file(caplog):
|
|||
assert module.MyDiag is module.Diag
|
||||
|
||||
|
||||
def test_load_file_fail():
|
||||
def test_load_file_fail() -> None:
|
||||
with pytest.raises(CompileError, match="Could not compile non-existent.slint"):
|
||||
load_file("non-existent.slint")
|
||||
|
||||
|
||||
def test_load_file_wrapper():
|
||||
module = load_file(os.path.join(os.path.dirname(
|
||||
__spec__.origin), "test-load-file.slint"), quiet=False)
|
||||
def test_load_file_wrapper() -> None:
|
||||
module = load_file(os.path.join(base_dir(), "test-load-file.slint"), quiet=False)
|
||||
|
||||
instance = module.App()
|
||||
|
||||
|
@ -64,11 +70,10 @@ def test_load_file_wrapper():
|
|||
del instance
|
||||
|
||||
|
||||
def test_constructor_kwargs():
|
||||
module = load_file(os.path.join(os.path.dirname(
|
||||
__spec__.origin), "test-load-file.slint"), quiet=False)
|
||||
def test_constructor_kwargs() -> None:
|
||||
module = load_file(os.path.join(base_dir(), "test-load-file.slint"), quiet=False)
|
||||
|
||||
def early_say_hello(arg):
|
||||
def early_say_hello(arg: str) -> str:
|
||||
return "early:" + arg
|
||||
|
||||
instance = module.App(hello="Set early", say_hello=early_say_hello)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue