From 958c410ba8b621a8a4d8caf04012028e7f151e0f Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 11 Sep 2020 22:20:15 +0200 Subject: Added comments --- src/suite/suite.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/suite/suite.py') 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 +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # 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: -- cgit