diff --git a/README.md b/README.md index 5159122..b44f183 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,7 @@ Check the [examples directory](https://github.com/dhzdhd/pysvt/tree/master/examp - Input key can be either of - i, in, input, inputs - Output key can be either of - o, out, output, outputs + +## Running examples + +`poetry run python -m examples.` diff --git a/examples/file.py b/examples/file.py index 362fb81..e6d171b 100644 --- a/examples/file.py +++ b/examples/file.py @@ -3,6 +3,6 @@ # Use this instead if you want to use a different TOML format # @test("data/data_cases.toml") -@test("data/data.toml") +@test(file="data/data.toml") def func(arg1: int, arg2: int) -> int: return arg1 + arg2 diff --git a/examples/file_cls.py b/examples/file_cls.py index 370abdb..654a223 100644 --- a/examples/file_cls.py +++ b/examples/file_cls.py @@ -3,7 +3,7 @@ # Use this instead if you want to use a different TOML format # @test("data/data_cases.toml") -@test("data/data.toml", method="func") +@test(file="data/data.toml", method="func") class Demo: def func(self, arg1: int, arg2: int) -> int: return arg1 + arg2 diff --git a/examples/pre_postprocess.py b/examples/pre_postprocess.py index 78cc974..030154d 100644 --- a/examples/pre_postprocess.py +++ b/examples/pre_postprocess.py @@ -9,7 +9,7 @@ def postprocess(lst: list[str]) -> str: return "".join(lst) -@test("data/prepostprocess.toml", preprocess=preprocess, postprocess=postprocess) +@test(file="data/prepostprocess.toml", preprocess=preprocess, postprocess=postprocess) def func(arg1: list[str], arg2: list[str]) -> list[str]: new = arg1 + arg2 return new diff --git a/pysvt/__main__.py b/pysvt/__main__.py index 6a7996e..e1bd410 100644 --- a/pysvt/__main__.py +++ b/pysvt/__main__.py @@ -43,11 +43,11 @@ class test: Usage: ``` - @test("data.toml") + @test(file="data.toml") def function(arg1, arg2): # Your code - @test("data.toml", method="method") + @test(file="data.toml", method="method") class Demo: def method(self, arg1, arg2): # Your code @@ -330,14 +330,6 @@ def _validate(self, data: _FuncModel, func: Callable[..., Any]) -> Result: stdout = f.getvalue() else: result = partial_fn() - # else: - # if self._pretty_print_errors: - # try: - # result = func() - # except: - # console.print_exception(show_locals=True) - # else: - # result = func() if self._postprocess is not None: result = self._postprocess(result) @@ -346,8 +338,6 @@ def _validate(self, data: _FuncModel, func: Callable[..., Any]) -> Result: class inspect_locals: - def __init__(self) -> None: - ... + def __init__(self) -> None: ... - def __call__(self, obj: object) -> Any: - ... + def __call__(self, obj: object) -> Any: ...