Skip to content

Commit

Permalink
Fix examples and function names
Browse files Browse the repository at this point in the history
  • Loading branch information
dhzdhd committed Jun 29, 2024
1 parent 15a317b commit 4a1cb85
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
1 change: 0 additions & 1 deletion examples/data/data.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ name = ["Normal case", "Edge case"]
i = [[1, 2], [2, 3]]
out = [3, 5]
# init can be ignored when not using instance methods
init = [[1, 2], [1, 2]]
metadata = ["Basic addition functionality", "Basic addition functionality"]
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(file="data/data.toml")
@test(file="examples/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(file="data/data.toml", method="func")
@test(file="examples/data/data.toml", method="func")
class Demo:
def func(self, arg1: int, arg2: int) -> int:
return arg1 + arg2
6 changes: 5 additions & 1 deletion examples/pre_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def postprocess(lst: list[str]) -> str:
return "".join(lst)


@test(file="data/prepostprocess.toml", preprocess=preprocess, postprocess=postprocess)
@test(
file="examples/data/prepostprocess.toml",
preprocess=preprocess,
postprocess=postprocess,
)
def func(arg1: list[str], arg2: list[str]) -> list[str]:
new = arg1 + arg2
return new
14 changes: 8 additions & 6 deletions pysvt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __call__(self, obj: object) -> Any:
"The decorator cannot be applied to non-instance methods. Instead, use it directly on the function"
)

# with self._printer.init_normal() as _:
# with self._printer.init() as _:
failures = 0

for index, data in enumerate(self._data.data):
Expand All @@ -127,7 +127,7 @@ def __call__(self, obj: object) -> Any:
result = self._validate(data, partial_method)
failures += 0 if result.valid else 1

self._printer.post_validation_normal(
self._printer.post_validation(
result, data, obj, timer(), self._show_error_only
)
self._printer.finish(len(self._data.data), failures)
Expand All @@ -137,15 +137,15 @@ def __call__(self, obj: object) -> Any:
"The decorator cannot be applied to instance methods. Instead, apply it on the class and pass the name of the method as an argument"
)

# with self._printer.init_normal() as _:
# with self._printer.init() as _:
failures = 0

for index, data in enumerate(self._data):
with Timer() as timer:
result = self._validate(data, obj)
failures += 0 if result.valid else 1

self._printer.post_validation_normal(
self._printer.post_validation(
result, data, obj, timer(), self._show_error_only
)

Expand Down Expand Up @@ -338,6 +338,8 @@ 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:
...
8 changes: 4 additions & 4 deletions pysvt/utils/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class Printer:
console (Console): The console object used for printing.
Methods:
init_normal() -> Status:
init() -> Status:
Initializes the printer in normal mode and returns the status object.
post_validation_normal(res: Result, data: _FuncModel, time_taken: float, show_error_only: bool) -> None:
post_validation(res: Result, data: _FuncModel, time_taken: float, show_error_only: bool) -> None:
Updates the information after validating a test case in normal mode.
finish(total: int, failures: int) -> None:
Expand All @@ -42,7 +42,7 @@ def __init__(self, console: Console) -> None:
self._console = console
self._layout = Layout()

def init_normal(self) -> Status:
def init(self) -> Status:
"""
Initializes the printer in normal mode.
Expand All @@ -51,7 +51,7 @@ def init_normal(self) -> Status:
"""
return Status("Running tests")

def post_validation_normal(
def post_validation(
self,
res: Result,
data: _FuncModel,
Expand Down

0 comments on commit 4a1cb85

Please sign in to comment.