Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dhzdhd committed Jun 29, 2024
1 parent 6858fd0 commit 15a317b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<example_file_name>`
2 changes: 1 addition & 1 deletion examples/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/file_cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion examples/pre_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 4 additions & 14 deletions pysvt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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: ...

0 comments on commit 15a317b

Please sign in to comment.