orionis 0.228.0__py3-none-any.whl → 0.230.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
orionis/framework.py CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.228.0"
8
+ VERSION = "0.230.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -556,4 +556,32 @@ class Console(IConsole):
556
556
  print(f" {ANSIColors.DIM.value}{ANSIColors.ITALIC.value}{ANSIColors.TEXT_WARNING.value}{name}{ANSIColors.TEXT_RESET.value} : {ANSIColors.CYAN.value}{line}{ANSIColors.TEXT_RESET.value}")
557
557
  count_error -= 1
558
558
 
559
- print("▬" * len(f" [{error_type}] : {error_message}"))
559
+ print("▬" * len(f" [{error_type}] : {error_message}"))
560
+
561
+ @staticmethod
562
+ def exitSuccess(message: str = None) -> None:
563
+ """
564
+ Exits the program with a success message.
565
+
566
+ Parameters
567
+ ----------
568
+ message : str, optional
569
+ The success message to print before exiting.
570
+ """
571
+ if message:
572
+ Console.success(message)
573
+ sys.exit(0)
574
+
575
+ @staticmethod
576
+ def exitError(message: str = None) -> None:
577
+ """
578
+ Exits the program with an error message.
579
+
580
+ Parameters
581
+ ----------
582
+ message : str, optional
583
+ The error message to print before exiting.
584
+ """
585
+ if message:
586
+ Console.error(message)
587
+ sys.exit(1)
@@ -1,37 +1,42 @@
1
- class ITests:
1
+ from abc import ABC, abstractmethod
2
+
3
+ class ITestSuite(ABC):
2
4
  """
3
5
  Provides utility methods to configure and execute unit tests from specified folders.
4
6
  """
5
7
 
6
8
  @staticmethod
7
- def execute(folders: list, print_result:bool = True, throw_exception:bool = False):
9
+ @abstractmethod
10
+ def load(
11
+ base_path: str = 'tests',
12
+ folder_path: list | str = '*',
13
+ pattern: str = 'test_*.py'
14
+ ):
8
15
  """
9
- Configure and run unit tests from a list of folder definitions.
16
+ Discover and initialize a test suite from the specified folder(s).
17
+
18
+ This method scans the provided folder(s) for test files matching the given pattern
19
+ and initializes a test suite with the discovered files.
10
20
 
11
21
  Parameters
12
22
  ----------
13
- folders : list of dict
14
- Each dict must include:
15
- - 'folder_path' (str): Path to the folder with test files.
16
- - 'base_path' (str): Base path for resolving test imports.
17
- - 'pattern' (str): Glob pattern for test file names.
18
-
19
- print_result : bool, default=True
20
- Whether to print test results to the console.
21
-
22
- throw_exception : bool, default=False
23
- Whether to raise exceptions on test failures.
23
+ base_path : str, optional
24
+ The base path for the tests. Defaults to 'tests'.
25
+ folder_path : str or list of str, optional
26
+ Path(s) to the folder(s) containing test files. Use '*' to scan all folders
27
+ under the base path. Defaults to '*'.
28
+ pattern : str, optional
29
+ File pattern to match test files. Defaults to 'test_*.py'.
24
30
 
25
31
  Returns
26
32
  -------
27
33
  UnitTestClass
28
- The initialized and executed test suite.
34
+ An initialized test suite containing the discovered test files.
29
35
 
30
36
  Raises
31
37
  ------
32
38
  TypeError
33
- If `folders` is not a list of dictionaries.
34
- KeyError
35
- If any dictionary lacks required keys: 'folder_path', 'base_path', or 'pattern'.
39
+ If `base_path` is not a string, `folder_path` is not a string or list, or
40
+ `pattern` is not a string.
36
41
  """
37
42
  pass
@@ -23,9 +23,9 @@ class TestCase(unittest.IsolatedAsyncioTestCase, TestStdOut):
23
23
  await super().asyncTearDown()
24
24
 
25
25
  # Another asynchronous test case class
26
- class TestAsyncCase(unittest.IsolatedAsyncioTestCase, TestStdOut):
26
+ class AsyncTestCase(unittest.IsolatedAsyncioTestCase, TestStdOut):
27
27
  """
28
- TestAsyncCase is a test case class designed for asynchronous unit testing.
28
+ AsyncTestCase is a test case class designed for asynchronous unit testing.
29
29
  It inherits from `unittest.IsolatedAsyncioTestCase` to provide support for
30
30
  async test methods and `TestStdOut` for additional functionality.
31
31
  Methods
@@ -53,9 +53,9 @@ class TestAsyncCase(unittest.IsolatedAsyncioTestCase, TestStdOut):
53
53
  """
54
54
  await super().asyncTearDown()
55
55
 
56
- class TestSyncCase(unittest.TestCase, TestStdOut):
56
+ class SyncTestCase(unittest.TestCase, TestStdOut):
57
57
  """
58
- TestSyncCase is a test case class designed for synchronous unit testing.
58
+ SyncTestCase is a test case class designed for synchronous unit testing.
59
59
  It inherits from `unittest.TestCase` to provide support for standard test methods
60
60
  and `TestStdOut` for additional functionality.
61
61
  """
@@ -1,68 +1,85 @@
1
- from orionis.luminate.test.contracts.test_suite import ITests
1
+ import re
2
+ from os import walk
3
+ from orionis.luminate.test.contracts.test_suite import ITestSuite
2
4
  from orionis.luminate.test.test_unit import UnitTest as UnitTestClass
3
5
 
4
- class Tests(ITests):
6
+ class TestSuite(ITestSuite):
5
7
  """
6
8
  A class containing test utility methods.
7
-
8
- Methods
9
- -------
10
- folders(folders: list) -> UnitTestClass
11
- Validates folder configurations and initializes test suite.
12
9
  """
13
10
 
14
11
  @staticmethod
15
- def execute(folders: list, print_result:bool = True, throw_exception:bool = False):
12
+ def load(
13
+ base_path: str = 'tests',
14
+ folder_path: list | str = '*',
15
+ pattern: str = 'test_*.py'
16
+ ) -> UnitTestClass:
16
17
  """
17
- Validate folder configurations and initialize test suite.
18
+ Discover and initialize a test suite from the specified folder(s).
19
+
20
+ This method scans the provided folder(s) for test files matching the given pattern
21
+ and initializes a test suite with the discovered files.
18
22
 
19
23
  Parameters
20
24
  ----------
21
- folders : list
22
- List of folder configuration dictionaries. Each dictionary must contain:
23
- - folder_path : str
24
- Path to the folder containing test files
25
- - base_path : str
26
- Base path for the tests
27
- - pattern : str
28
- File pattern to match test files
25
+ base_path : str, optional
26
+ The base path for the tests. Defaults to 'tests'.
27
+ folder_path : str or list of str, optional
28
+ Path(s) to the folder(s) containing test files. Use '*' to scan all folders
29
+ under the base path. Defaults to '*'.
30
+ pattern : str, optional
31
+ File pattern to match test files. Defaults to 'test_*.py'.
29
32
 
30
33
  Returns
31
34
  -------
32
35
  UnitTestClass
33
- Initialized test suite with added folders
36
+ An initialized test suite containing the discovered test files.
34
37
 
35
38
  Raises
36
39
  ------
37
40
  TypeError
38
- If folders is not a list or contains non-dictionary items
39
- KeyError
40
- If any folder dictionary is missing required keys
41
-
42
- Examples
43
- --------
44
- >>> Tests.folders([
45
- ... {
46
- ... 'folder_path': 'example',
47
- ... 'base_path': 'tests',
48
- ... 'pattern': 'test_*.py'
49
- ... }
50
- ... ])
41
+ If `base_path` is not a string, `folder_path` is not a string or list, or
42
+ `pattern` is not a string.
51
43
  """
52
- if not isinstance(folders, list):
53
- raise TypeError("folders must be a list")
44
+ # Validate parameters
45
+ if not isinstance(base_path, str):
46
+ raise TypeError("base_path must be a string")
47
+ if not isinstance(folder_path, (str, list)):
48
+ raise TypeError("folder_path must be a string or a list")
49
+ if not isinstance(pattern, str):
50
+ raise TypeError("pattern must be a string")
54
51
 
55
- for folder in folders:
56
- if not isinstance(folder, dict):
57
- raise TypeError("each folder must be a dictionary")
58
- if not all(key in folder for key in ['folder_path', 'base_path', 'pattern']):
59
- raise KeyError("each folder must contain 'folder_path', 'base_path' and 'pattern' keys")
52
+ # Helper function to list folders matching the pattern
53
+ def list_matching_folders(custom_path: str, pattern: str):
54
+ matched_folders = []
55
+ for root, _, files in walk(custom_path):
56
+ for file in files:
57
+ if re.fullmatch(pattern.replace('*', '.*').replace('?', '.'), file):
58
+ relative_path = root.replace(base_path, '').replace('\\', '/').lstrip('/')
59
+ if relative_path not in matched_folders:
60
+ matched_folders.append(relative_path)
61
+ return matched_folders
60
62
 
63
+ # Discover folders
64
+ discovered_folders = []
65
+ if folder_path == '*':
66
+ discovered_folders.extend(list_matching_folders(base_path, pattern))
67
+ elif isinstance(folder_path, list):
68
+ for custom_path in folder_path:
69
+ discovered_folders.extend(list_matching_folders(custom_path, pattern))
70
+ else:
71
+ discovered_folders.extend(list_matching_folders(folder_path, pattern))
72
+
73
+ # Initialize the test suite
61
74
  tests = UnitTestClass()
62
- for folder in folders:
75
+
76
+ # Add discovered folders to the test suite
77
+ for folder in discovered_folders:
63
78
  tests.addFolder(
64
- base_path=folder['base_path'],
65
- folder_path=folder['folder_path'],
66
- pattern=folder['pattern']
79
+ base_path=base_path,
80
+ folder_path=folder,
81
+ pattern=pattern
67
82
  )
68
- return tests.run(print_result, throw_exception)
83
+
84
+ # Return the initialized test suite
85
+ return tests
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.228.0
3
+ Version: 0.230.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -1,6 +1,6 @@
1
1
  orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  orionis/console.py,sha256=4gYWxf0fWYgJ4RKwARvnTPh06FL3GJ6SAZ7R2NzOICw,1342
3
- orionis/framework.py,sha256=yvd4Qh0vImy8fXZUPVQya7sgXqCfXJMdu9FsRwpsthQ,1458
3
+ orionis/framework.py,sha256=bi6Li6kcFmefOar93w0po4ec5BGmPG60Ll_AaFeT00c,1458
4
4
  orionis/installer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  orionis/installer/manager.py,sha256=Li4TVziRXWfum02xNG4JHwbnLk-u8xzHjdqKz-D894k,2755
6
6
  orionis/installer/output.py,sha256=7O9qa2xtXMB_4ZvVi-Klneom9YazwygAd_4uYAoxhbU,8548
@@ -39,7 +39,7 @@ orionis/luminate/console/exceptions/cli_exception.py,sha256=HsZ_vSeNiJWQ0gznVFNc
39
39
  orionis/luminate/console/exceptions/cli_runtime_error.py,sha256=DaCDGu6mXBk1LIzc7cwRROw1mePAigPNASjNZHhUSBE,1154
40
40
  orionis/luminate/console/exceptions/cli_schedule_exception.py,sha256=IBbXb_5zi02pyo1laHdjGn6FYZK7WWRp4j2fkZOCT6I,1161
41
41
  orionis/luminate/console/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
- orionis/luminate/console/output/console.py,sha256=FuNlI2sjmv14iYM80YQ3jMeUcVaNv0VqBhnfVdFEChA,18209
42
+ orionis/luminate/console/output/console.py,sha256=aVvcGkzetJ66RLet2H5RZ-xidRH_MfJjKX7vSGkjkSg,18926
43
43
  orionis/luminate/console/output/executor.py,sha256=-efhCbWOS4ZqmRsO0s3j5NEbw4I9hVROF8Q3Atx77zs,3369
44
44
  orionis/luminate/console/output/progress_bar.py,sha256=ZiPGcUaN3EINeLRKgLGtS1GAb1XWlCDx7wFQ7Ff0hqY,3096
45
45
  orionis/luminate/console/output/styles.py,sha256=6a4oQCOBOKMh2ARdeq5GlIskJ3wjiylYmh66tUKKmpQ,4053
@@ -195,16 +195,16 @@ orionis/luminate/support/standard/std.py,sha256=t6dkZxOmSsu3yaIwlvRwdTcV-6KS8lZE
195
195
  orionis/luminate/support/standard/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
196
196
  orionis/luminate/support/standard/contracts/std.py,sha256=x9sVir2yg4hve56cCklIdVSr8utruIO_sUdlTNfZ1Ds,3109
197
197
  orionis/luminate/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
198
- orionis/luminate/test/test_case.py,sha256=y3-u3oJtCHLP-DoVW3jan2i96Y78VVdIM1pL7iV0uqU,2508
198
+ orionis/luminate/test/test_case.py,sha256=ghVpBHHnE79kswWjpNNy62XkvKwxrnY-C6DdKZp-0lk,2508
199
199
  orionis/luminate/test/test_exception.py,sha256=21PILTXnMuL5-wT3HGKjIklt8VeIYDcQDN346i-BbJw,1336
200
200
  orionis/luminate/test/test_result.py,sha256=Px2_M70r_y7BntRITk_h0IPTbSTW5XhDyklMKHm3JJI,999
201
201
  orionis/luminate/test/test_status.py,sha256=vNKRmp1lud_ZGTayf3A8wO_0vEYdFABy_oMw-RcEc1c,673
202
202
  orionis/luminate/test/test_std_out.py,sha256=rPwXCf3qvMzkZHRCu03KvLCfD4K7cPOB02BZNpXtaiU,2851
203
- orionis/luminate/test/test_suite.py,sha256=85OvJRZBzpFGxGw-28n0rXWYjbhACs0nZn5t3FHtzcg,2289
203
+ orionis/luminate/test/test_suite.py,sha256=752VbEJHCSe0ztDrBmJlU8FpUg96W4MHnQbHPKpOGqc,3270
204
204
  orionis/luminate/test/test_unit.py,sha256=ZTsGlFJ-vwc77sfb7kLDs_sAwJL4L1YP8R9nFUWlgZY,12146
205
205
  orionis/luminate/test/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
206
206
  orionis/luminate/test/contracts/test_std_out.py,sha256=ryvMotj-rpVKOsyGqW0B0IEHuF8DdQj1Rn0K8xiyBOE,489
207
- orionis/luminate/test/contracts/test_suite.py,sha256=ieyhZLfC09VfMraskMdWUTUFAD03aaG_8FURWI_d_YQ,1214
207
+ orionis/luminate/test/contracts/test_suite.py,sha256=TOIys-Z1HllUJe-qMY9mOfZGiZPXlKRuAZtJ-B2iDz8,1375
208
208
  orionis/luminate/test/contracts/test_unit.py,sha256=3euExuq7QgkJljnENxDyZW-okrw9S0apLnhf93o0Vqg,2612
209
209
  orionis/static/ascii/icon.ascii,sha256=IgrlVjcYxcCrr0cJuJkOnEz0aEdAQBTyLzO5ainKsWc,398
210
210
  orionis/static/ascii/info.ascii,sha256=HF_o2eXaiw5iqcOhHfnPByn5GJ_O2eBwSK3IpTfYOwY,457
@@ -249,9 +249,9 @@ tests/support/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
249
249
  tests/support/patterns/test_singleton.py,sha256=U5uwpgGcP7-fIazsnFLwg30mmc24S62udhVIHuL-scY,634
250
250
  tests/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
251
251
  tests/support/standard/test_std.py,sha256=bJ5LV_OKEEZa_Bk3PTk9Kapk6qECLzcKf0hfR_x2QqM,2042
252
- orionis-0.228.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
253
- orionis-0.228.0.dist-info/METADATA,sha256=_wFvSjxKzyhc20WErhCgMTt0Hv9o9WpU8Qcsus_2PXk,3003
254
- orionis-0.228.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
255
- orionis-0.228.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
256
- orionis-0.228.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
257
- orionis-0.228.0.dist-info/RECORD,,
252
+ orionis-0.230.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
253
+ orionis-0.230.0.dist-info/METADATA,sha256=jQC8g9qbVXlE1cvFGv96tT8o_55xjFZz12DNC2nXcSI,3003
254
+ orionis-0.230.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
255
+ orionis-0.230.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
256
+ orionis-0.230.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
257
+ orionis-0.230.0.dist-info/RECORD,,