From 4a1cb85558a96d450a7dd87191bac045d6c5149e Mon Sep 17 00:00:00 2001 From: dhzdhd Date: Sat, 29 Jun 2024 11:50:42 +0530 Subject: [PATCH] Fix examples and function names --- examples/data/data.toml | 1 - examples/file.py | 2 +- examples/file_cls.py | 2 +- examples/pre_postprocess.py | 6 +++++- pysvt/__main__.py | 14 ++++++++------ pysvt/utils/printer.py | 8 ++++---- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/examples/data/data.toml b/examples/data/data.toml index 97da1fe..6dddc00 100644 --- a/examples/data/data.toml +++ b/examples/data/data.toml @@ -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"] diff --git a/examples/file.py b/examples/file.py index e6d171b..1a0c3aa 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(file="data/data.toml") +@test(file="examples/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 654a223..e27d2c2 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(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 diff --git a/examples/pre_postprocess.py b/examples/pre_postprocess.py index 030154d..571c9d8 100644 --- a/examples/pre_postprocess.py +++ b/examples/pre_postprocess.py @@ -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 diff --git a/pysvt/__main__.py b/pysvt/__main__.py index e1bd410..74a53b0 100644 --- a/pysvt/__main__.py +++ b/pysvt/__main__.py @@ -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): @@ -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) @@ -137,7 +137,7 @@ 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): @@ -145,7 +145,7 @@ def __call__(self, obj: object) -> Any: 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 ) @@ -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: + ... diff --git a/pysvt/utils/printer.py b/pysvt/utils/printer.py index 60583bb..bb4365e 100644 --- a/pysvt/utils/printer.py +++ b/pysvt/utils/printer.py @@ -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: @@ -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. @@ -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,