aboutsummaryrefslogtreecommitdiff
path: root/src/suite/decorator.py
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/decorator.py
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/decorator.py')
-rw-r--r--src/suite/decorator.py31
1 files changed, 19 insertions, 12 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