From c20cbfea9bb878fc88e76f0ba773ded5a7b149ca Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 8 Oct 2020 08:43:12 +0200 Subject: Added suite description for -l option --- src/suite/decorator.py | 13 +++++++++---- src/suite/suite.py | 39 +++++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 18 deletions(-) (limited to 'src/suite') diff --git a/src/suite/decorator.py b/src/suite/decorator.py index d4801c3..12f58a6 100644 --- a/src/suite/decorator.py +++ b/src/suite/decorator.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:28:00 by charles #+# #+# # -# Updated: 2020/09/11 22:08:36 by charles ### ########.fr # +# Updated: 2020/10/08 08:34:10 by cacharle ### ########.fr # # # # ############################################################################ # @@ -22,10 +22,15 @@ def suite(groups: [str] = [], bonus: bool = False): """Decorator for a suite function (fmt: suite_[name]) """ mod_name = inspect.getmodule(origin).__name__[len("suites."):] - # print(mod_name) - name = "{}/{}".format(mod_name, origin.__name__[len("suite_"):]) - s = Suite(name, groups + [mod_name], bonus) + description = origin.__doc__ + if description is None: + print("You should had a doc string to the {} suite".format(name)) + description = "no description" + description = description.split("\n")[0].strip() + + s = Suite(name, groups + [mod_name], bonus, description) + def test_generator(): def test(*args, **kwargs): diff --git a/src/suite/suite.py b/src/suite/suite.py index dc5611a..b5eb96c 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/10/07 18:24:20 by cacharle ### ########.fr # +# Updated: 2020/10/08 08:42:50 by cacharle ### ########.fr # # # # ############################################################################ # @@ -17,18 +17,6 @@ import termios import config -# # from: https://stackoverflow.com/questions/510357 -# def getchar(): -# fd = sys.stdin.fileno() -# old_settings = termios.tcgetattr(fd) -# try: -# tty.setraw(sys.stdin.fileno()) -# char = sys.stdin.read(1) -# finally: -# termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) -# return char - - class Suite: available = [] @@ -85,7 +73,29 @@ class Suite: """List of available suites names""" return [s.name for s in cls.available] - def __init__(self, name: str, groups: [str], bonus: bool = False): + @classmethod + def list(cls): + print("Groups:") + print("\n".join(set([" - " + ', '.join(s.groups) for s in Suite.available]))) + print("The available suites are:") + max_name_width = max(len(s.name) for s in Suite.available) + 5 + lines = [ + " - {:.<{max_name_width}} {}".format( + s.name + " ", + s.description, + max_name_width=max_name_width + ) + for s in Suite.available + ] + print("\n".join(lines)) + + def __init__( + self, + name: str, + groups: [str], + bonus: bool = False, + description: str = "no description", + ): """Suite class name: suite id groups: list of suite groups @@ -93,6 +103,7 @@ class Suite: """ self.name = name self.groups = groups + self.description = description self.bonus = bonus self.generator_func = None self.tests = [] -- cgit