aboutsummaryrefslogtreecommitdiff
path: root/src/suite
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-11 14:27:26 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-11 14:27:26 +0200
commitd0a80859f630866461e8a888b3f8fe008c8158ba (patch)
treead0ebcc42a620aeea5a4407e1cacbac24faf1dcb /src/suite
parent46ba2708f83bf46186c33bf84975d39e87f467c1 (diff)
downloadminishell_test-d0a80859f630866461e8a888b3f8fe008c8158ba.tar.gz
minishell_test-d0a80859f630866461e8a888b3f8fe008c8158ba.tar.bz2
minishell_test-d0a80859f630866461e8a888b3f8fe008c8158ba.zip
Added suite group and suite bonus, Added signal (not tested)
Diffstat (limited to 'src/suite')
-rw-r--r--src/suite/decorator.py31
-rw-r--r--src/suite/suite.py14
2 files changed, 29 insertions, 16 deletions
diff --git a/src/suite/decorator.py b/src/suite/decorator.py
index 55c9de6..4f1aaa9 100644
--- a/src/suite/decorator.py
+++ b/src/suite/decorator.py
@@ -6,22 +6,29 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 12:28:00 by charles #+# #+# #
-# Updated: 2020/09/11 12:28:14 by charles ### ########.fr #
+# Updated: 2020/09/11 14:13:34 by charles ### ########.fr #
# #
# ############################################################################ #
from suite import Suite
from test import Test
+import inspect
-def suite(origin):
- """ decorator for a suite function (fmt: suite_[name]) """
+def suite(groups: [str] = [], bonus: bool = False):
+ def suite_wrapper(origin):
+ """ decorator for a suite function (fmt: suite_[name]) """
- name = origin.__name__[len("suite_"):]
- s = Suite(name)
- def test_generator():
- def test(*args, **kwargs):
- s.add(Test(*args, **kwargs))
- origin(test)
- s.add_generator(test_generator)
- Suite.available.append(s)
- return test_generator
+ mod_name = inspect.getmodule(origin).__name__[len("suites."):]
+ # print(mod_name)
+
+ name = origin.__name__[len("suite_"):]
+ s = Suite(name, groups + [mod_name], bonus)
+ def test_generator():
+ def test(*args, **kwargs):
+ s.add(Test(*args, **kwargs))
+ origin(test)
+ s.add_generator(test_generator)
+ Suite.available.append(s)
+ return test_generator
+
+ return suite_wrapper
diff --git a/src/suite/suite.py b/src/suite/suite.py
index fee4aa9..d796cf7 100644
--- a/src/suite/suite.py
+++ b/src/suite/suite.py
@@ -6,12 +6,11 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:29 by charles #+# #+# #
-# Updated: 2020/09/11 12:27:47 by charles ### ########.fr #
+# Updated: 2020/09/11 14:18:01 by charles ### ########.fr #
# #
# ############################################################################ #
import config
-from test import Test
class Suite:
@@ -26,7 +25,12 @@ class Suite:
def setup(cls, asked_names: [str]):
if len(asked_names) == 0:
asked_names = [s.name for s in cls.available]
- cls.available = [s for s in cls.available if s.name in asked_names]
+ if not config.BONUS:
+ cls.available = [s for s in cls.available if not s.bonus]
+ cls.available = list(set(
+ [s for s in cls.available if s.name in asked_names] +
+ [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()
@@ -34,8 +38,10 @@ class Suite:
def available_names(cls) -> [str]:
return [s.name for s in cls.available]
- def __init__(self, name: str):
+ def __init__(self, name: str, groups: [str], bonus: bool = False):
self.name = name
+ self.groups = groups
+ self.bonus = bonus
self.generator_func = None
self.tests = []