aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze/utils/MiscFeatures.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/argaze/utils/MiscFeatures.py b/src/argaze/utils/MiscFeatures.py
index 46e0269..09c289d 100644
--- a/src/argaze/utils/MiscFeatures.py
+++ b/src/argaze/utils/MiscFeatures.py
@@ -30,6 +30,26 @@ def printProgressBar (iteration:int, total:int, prefix:str = '', suffix:str = ''
if iteration == total:
print()
+def importFromTestPackage(module: str):
+ """Import module from ArGaze test package.
+ * **Returns:**
+ - a module named <Module>Test"""
+
+ import argaze
+ import importlib.util
+ import sys
+ import os
+
+ source_directory = os.path.dirname(os.path.dirname(os.path.abspath(argaze.__file__)))
+ module_directory = os.path.join(source_directory, 'argaze.test', f'{module}.py')
+
+ spec = importlib.util.spec_from_file_location(f'{module}Test', module_directory)
+ TestModule = importlib.util.module_from_spec(spec)
+ sys.modules[f'{module}Test'] = TestModule
+ spec.loader.exec_module(TestModule)
+
+ return TestModule
+
class ExitSignalHandler():
"""Handle exit event"""
def __init__(self):