diff options
Diffstat (limited to 'src/suite')
| -rw-r--r-- | src/suite/decorator.py | 8 | ||||
| -rw-r--r-- | src/suite/suite.py | 23 |
2 files changed, 20 insertions, 11 deletions
diff --git a/src/suite/decorator.py b/src/suite/decorator.py index 448e0a3..d4801c3 100644 --- a/src/suite/decorator.py +++ b/src/suite/decorator.py @@ -6,7 +6,7 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:28:00 by charles #+# #+# # -# Updated: 2020/09/11 20:08:27 by charles ### ########.fr # +# Updated: 2020/09/11 22:08:36 by charles ### ########.fr # # # # ############################################################################ # @@ -16,8 +16,10 @@ import inspect def suite(groups: [str] = [], bonus: bool = False): + """Decorator generator for suites arguments""" + def suite_wrapper(origin): - """ decorator for a suite function (fmt: suite_[name]) """ + """Decorator for a suite function (fmt: suite_[name]) """ mod_name = inspect.getmodule(origin).__name__[len("suites."):] # print(mod_name) @@ -30,7 +32,7 @@ def suite(groups: [str] = [], bonus: bool = False): s.add(Test(*args, **kwargs)) origin(test) - s.add_generator(test_generator) + s.generator_func = test_generator Suite.available.append(s) return test_generator diff --git a/src/suite/suite.py b/src/suite/suite.py index a51da65..2ac64e4 100644 --- a/src/suite/suite.py +++ b/src/suite/suite.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:29 by charles #+# #+# # -# Updated: 2020/09/11 20:08:39 by charles ### ########.fr # +# Updated: 2020/09/11 20:35:13 by charles ### ########.fr # # # # ############################################################################ # @@ -18,11 +18,13 @@ class Suite: @classmethod def run_all(cls): + """Run all available suites""" for s in cls.available: s.run() @classmethod def setup(cls, asked_names: [str]): + """Remove not asked suite from available suites""" if len(asked_names) == 0: asked_names = [s.name for s in cls.available] if not config.BONUS: @@ -32,13 +34,19 @@ class Suite: + [s for s in cls.available if any([g for g in s.groups if g in asked_names])] )) for s in cls.available: - s.generate() + s.generator_func() @classmethod def available_names(cls) -> [str]: + """List of available suites names""" return [s.name for s in cls.available] def __init__(self, name: str, groups: [str], bonus: bool = False): + """Suite class + name: suite id + groups: list of suite groups + bonus: is this suite bonus + """ self.name = name self.groups = groups self.bonus = bonus @@ -46,12 +54,11 @@ class Suite: self.tests = [] def add(self, test): + """Append a test to the suite""" self.tests.append(test) - def add_generator(self, generator): - self.generator_func = generator - def run(self): + """Run all test in the suite""" if config.VERBOSE_LEVEL == 0: print(self.name + ": ", end="") else: @@ -61,10 +68,8 @@ class Suite: if config.VERBOSE_LEVEL == 0: print() - def generate(self): - self.generator_func() - def total(self) -> (int, int): + """Returns the total of passed and failed tests""" passed_total = 0 for t in self.tests: if t.result is None: @@ -75,6 +80,7 @@ class Suite: @classmethod def summarize(cls): + """Print a summary of all runned suites""" pass_sum = 0 fail_sum = 0 print("\nSummary:") @@ -91,6 +97,7 @@ class Suite: @classmethod def save_log(cls): + """Save the result of all suites to a file""" with open(config.LOG_PATH, "w") as log_file: for s in cls.available: for t in s.tests: |
