winipedia-utils 0.2.0__py3-none-any.whl → 0.2.1__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.

Potentially problematic release.


This version of winipedia-utils might be problematic. Click here for more details.

Files changed (90) hide show
  1. winipedia_utils/concurrent/concurrent.py +245 -245
  2. winipedia_utils/concurrent/multiprocessing.py +130 -130
  3. winipedia_utils/concurrent/multithreading.py +93 -93
  4. winipedia_utils/consts.py +21 -23
  5. winipedia_utils/data/__init__.py +1 -1
  6. winipedia_utils/data/dataframe/__init__.py +1 -1
  7. winipedia_utils/data/dataframe/cleaning.py +378 -378
  8. winipedia_utils/data/structures/__init__.py +1 -1
  9. winipedia_utils/data/structures/dicts.py +16 -16
  10. winipedia_utils/git/__init__.py +1 -1
  11. winipedia_utils/git/gitignore/__init__.py +1 -1
  12. winipedia_utils/git/gitignore/gitignore.py +136 -136
  13. winipedia_utils/git/pre_commit/__init__.py +1 -1
  14. winipedia_utils/git/pre_commit/config.py +70 -70
  15. winipedia_utils/git/pre_commit/hooks.py +109 -109
  16. winipedia_utils/git/pre_commit/run_hooks.py +49 -49
  17. winipedia_utils/iterating/__init__.py +1 -1
  18. winipedia_utils/iterating/iterate.py +29 -29
  19. winipedia_utils/logging/ansi.py +6 -6
  20. winipedia_utils/logging/config.py +64 -64
  21. winipedia_utils/logging/logger.py +26 -26
  22. winipedia_utils/modules/class_.py +119 -119
  23. winipedia_utils/modules/function.py +101 -101
  24. winipedia_utils/modules/module.py +379 -379
  25. winipedia_utils/modules/package.py +390 -390
  26. winipedia_utils/oop/mixins/meta.py +333 -333
  27. winipedia_utils/oop/mixins/mixin.py +37 -37
  28. winipedia_utils/os/__init__.py +1 -1
  29. winipedia_utils/os/os.py +63 -63
  30. winipedia_utils/projects/__init__.py +1 -1
  31. winipedia_utils/projects/poetry/__init__.py +1 -1
  32. winipedia_utils/projects/poetry/config.py +91 -91
  33. winipedia_utils/projects/poetry/poetry.py +31 -31
  34. winipedia_utils/projects/project.py +48 -48
  35. winipedia_utils/resources/__init__.py +1 -1
  36. winipedia_utils/resources/svgs/__init__.py +1 -1
  37. winipedia_utils/resources/svgs/download_arrow.svg +2 -2
  38. winipedia_utils/resources/svgs/exit_fullscreen_icon.svg +5 -5
  39. winipedia_utils/resources/svgs/fullscreen_icon.svg +2 -2
  40. winipedia_utils/resources/svgs/menu_icon.svg +3 -3
  41. winipedia_utils/resources/svgs/pause_icon.svg +3 -3
  42. winipedia_utils/resources/svgs/play_icon.svg +16 -16
  43. winipedia_utils/resources/svgs/plus_icon.svg +23 -23
  44. winipedia_utils/resources/svgs/svg.py +15 -15
  45. winipedia_utils/security/__init__.py +1 -1
  46. winipedia_utils/security/cryptography.py +29 -29
  47. winipedia_utils/security/keyring.py +70 -70
  48. winipedia_utils/setup.py +47 -47
  49. winipedia_utils/testing/assertions.py +23 -23
  50. winipedia_utils/testing/convention.py +177 -177
  51. winipedia_utils/testing/create_tests.py +291 -291
  52. winipedia_utils/testing/fixtures.py +28 -28
  53. winipedia_utils/testing/tests/base/fixtures/__init__.py +1 -1
  54. winipedia_utils/testing/tests/base/fixtures/fixture.py +6 -6
  55. winipedia_utils/testing/tests/base/fixtures/scopes/class_.py +33 -33
  56. winipedia_utils/testing/tests/base/fixtures/scopes/function.py +7 -7
  57. winipedia_utils/testing/tests/base/fixtures/scopes/module.py +31 -31
  58. winipedia_utils/testing/tests/base/fixtures/scopes/package.py +7 -7
  59. winipedia_utils/testing/tests/base/fixtures/scopes/session.py +312 -312
  60. winipedia_utils/testing/tests/base/utils/utils.py +82 -82
  61. winipedia_utils/testing/tests/conftest.py +32 -32
  62. winipedia_utils/text/string.py +126 -126
  63. {winipedia_utils-0.2.0.dist-info → winipedia_utils-0.2.1.dist-info}/METADATA +1 -4
  64. winipedia_utils-0.2.1.dist-info/RECORD +80 -0
  65. {winipedia_utils-0.2.0.dist-info → winipedia_utils-0.2.1.dist-info}/licenses/LICENSE +21 -21
  66. winipedia_utils/django/__init__.py +0 -24
  67. winipedia_utils/django/bulk.py +0 -538
  68. winipedia_utils/django/command.py +0 -334
  69. winipedia_utils/django/database.py +0 -289
  70. winipedia_utils/pyside/__init__.py +0 -1
  71. winipedia_utils/pyside/core/__init__.py +0 -1
  72. winipedia_utils/pyside/core/py_qiodevice.py +0 -476
  73. winipedia_utils/pyside/ui/__init__.py +0 -1
  74. winipedia_utils/pyside/ui/base/__init__.py +0 -1
  75. winipedia_utils/pyside/ui/base/base.py +0 -180
  76. winipedia_utils/pyside/ui/pages/__init__.py +0 -1
  77. winipedia_utils/pyside/ui/pages/base/__init__.py +0 -1
  78. winipedia_utils/pyside/ui/pages/base/base.py +0 -92
  79. winipedia_utils/pyside/ui/pages/browser.py +0 -26
  80. winipedia_utils/pyside/ui/pages/player.py +0 -85
  81. winipedia_utils/pyside/ui/widgets/__init__.py +0 -1
  82. winipedia_utils/pyside/ui/widgets/browser.py +0 -243
  83. winipedia_utils/pyside/ui/widgets/clickable_widget.py +0 -57
  84. winipedia_utils/pyside/ui/widgets/media_player.py +0 -430
  85. winipedia_utils/pyside/ui/widgets/notification.py +0 -78
  86. winipedia_utils/pyside/ui/windows/__init__.py +0 -1
  87. winipedia_utils/pyside/ui/windows/base/__init__.py +0 -1
  88. winipedia_utils/pyside/ui/windows/base/base.py +0 -49
  89. winipedia_utils-0.2.0.dist-info/RECORD +0 -103
  90. {winipedia_utils-0.2.0.dist-info → winipedia_utils-0.2.1.dist-info}/WHEEL +0 -0
@@ -1,291 +1,291 @@
1
- """Utilities for automatically creating test files for the project.
2
-
3
- This module provides functions to generate test files for all modules and classes
4
- in the project, ensuring that every function and method has a corresponding test.
5
- It creates the basic test structure and generates skeleton test functions with
6
- NotImplementedError to indicate tests that need to be written.
7
- """
8
-
9
- from pathlib import Path
10
- from types import ModuleType
11
- from typing import cast
12
-
13
- from winipedia_utils.modules.class_ import (
14
- get_all_cls_from_module,
15
- get_all_methods_from_cls,
16
- )
17
- from winipedia_utils.modules.function import get_all_functions_from_module
18
- from winipedia_utils.modules.module import (
19
- create_module,
20
- get_isolated_obj_name,
21
- get_module_content_as_str,
22
- get_qualname_of_obj,
23
- to_path,
24
- )
25
- from winipedia_utils.modules.package import (
26
- copy_package,
27
- get_src_package,
28
- walk_package,
29
- )
30
- from winipedia_utils.testing import tests
31
- from winipedia_utils.testing.convention import (
32
- TESTS_PACKAGE_NAME,
33
- get_test_obj_from_obj,
34
- make_test_obj_importpath_from_obj,
35
- make_test_obj_name,
36
- reverse_make_test_obj_name,
37
- )
38
- from winipedia_utils.testing.tests.base.utils.utils import (
39
- _conftest_content_is_correct,
40
- _get_conftest_content,
41
- )
42
-
43
-
44
- def create_tests() -> None:
45
- """Create all test files for the project.
46
-
47
- This function orchestrates the test creation process by first setting up the base
48
- test structure and then creating test files for all source packages.
49
- """
50
- create_tests_base()
51
- create_tests_for_src_package()
52
-
53
-
54
- def create_tests_base() -> None:
55
- """Create the base test structure.
56
-
57
- This function:
58
- 1. Creates a mirror of winipedia_utils.testing.tests in the tests directory
59
- 2. Skips copying __init__.py file contents
60
- 3. Writes new __init__.py files for all packages
61
- 4. Creates a conftest.py file with the appropriate pytest plugin configuration
62
- 5. Does not overwrite anything if it already exists except conftest.py
63
- """
64
- tests_path = Path(TESTS_PACKAGE_NAME)
65
- copy_package(
66
- src_package=tests,
67
- dst=".",
68
- with_file_content=False,
69
- )
70
- # write pytest_plugin in the conftest.py
71
- conftest_path = tests_path / "conftest.py"
72
- # if conftest does not exist or the content is not the same, overwrite it
73
- if not _conftest_content_is_correct(conftest_path):
74
- conftest_path.write_text(_get_conftest_content())
75
-
76
-
77
- def create_tests_for_src_package() -> None:
78
- """Create test files for all modules in the source package.
79
-
80
- This function walks through the source package hierarchy and creates corresponding
81
- test packages and modules for each package and module found in the source.
82
- """
83
- src_package = get_src_package()
84
- for package, modules in walk_package(src_package):
85
- create_test_package(package)
86
- for module in modules:
87
- create_test_module(module)
88
-
89
-
90
- def create_test_package(package: ModuleType) -> None:
91
- """Create a test package for a source package.
92
-
93
- Args:
94
- package: The source package module to create a test package for
95
-
96
- This function creates a test package with the appropriate naming convention
97
- if it doesn't already exist.
98
-
99
- """
100
- test_package_name = make_test_obj_importpath_from_obj(package)
101
- # create package if it doesn't exist
102
- create_module(test_package_name, is_package=True)
103
-
104
-
105
- def create_test_module(module: ModuleType) -> None:
106
- """Create a test module for a source module.
107
-
108
- Args:
109
- module: The source module to create a test module for
110
-
111
- This function:
112
- 1. Creates a test module with the appropriate naming convention
113
- 2. Generates the test module content with skeleton test functions
114
- 3. Writes the content to the test module file
115
-
116
- """
117
- test_module_name = make_test_obj_importpath_from_obj(module)
118
- test_module = create_module(test_module_name, is_package=False)
119
- test_module_path = to_path(test_module, is_package=False)
120
- test_module_path.write_text(get_test_module_content(module))
121
-
122
-
123
- def get_test_module_content(module: ModuleType) -> str:
124
- """Generate the content for a test module.
125
-
126
- Args:
127
- module: The source module to generate test content for
128
-
129
- Returns:
130
- The generated test module content as a string
131
-
132
- This function:
133
- 1. Gets the existing test module content if it exists
134
- 2. Adds test functions for all functions in the source module
135
- 3. Adds test classes for all classes in the source module
136
-
137
- """
138
- test_module = cast("ModuleType", (get_test_obj_from_obj(module)))
139
- test_module_content = get_module_content_as_str(test_module)
140
-
141
- test_module_content = get_test_functions_content(
142
- module, test_module, test_module_content
143
- )
144
-
145
- return get_test_classes_content(module, test_module, test_module_content)
146
-
147
-
148
- def get_test_functions_content(
149
- module: ModuleType,
150
- test_module: ModuleType,
151
- test_module_content: str,
152
- ) -> str:
153
- """Generate test function content for a module.
154
-
155
- Args:
156
- module: The source module containing functions to test
157
- test_module: The test module to add function tests to
158
- test_module_content: The current content of the test module
159
-
160
- Returns:
161
- The updated test module content with function tests added
162
-
163
- This function:
164
- 1. Identifies all functions in the source module
165
- 2. Determines which functions don't have corresponding tests
166
- 3. Generates skeleton test functions for untested functions
167
-
168
- """
169
- funcs = get_all_functions_from_module(module)
170
- test_functions = get_all_functions_from_module(test_module)
171
- supposed_test_funcs_names = [make_test_obj_name(f) for f in funcs]
172
-
173
- test_funcs_names = [get_qualname_of_obj(f) for f in test_functions]
174
-
175
- untested_funcs_names = [
176
- f for f in supposed_test_funcs_names if f not in test_funcs_names
177
- ]
178
-
179
- for test_func_name in untested_funcs_names:
180
- test_module_content += f"""
181
-
182
- def {test_func_name}() -> None:
183
- \"\"\"Test func for {reverse_make_test_obj_name(test_func_name)}.\"\"\"
184
- raise {NotImplementedError.__name__}
185
- """
186
-
187
- return test_module_content
188
-
189
-
190
- def get_test_classes_content(
191
- module: ModuleType,
192
- test_module: ModuleType,
193
- test_module_content: str,
194
- ) -> str:
195
- """Generate test class content for a module.
196
-
197
- Args:
198
- module: The source module containing classes to test
199
- test_module: The test module to add class tests to
200
- test_module_content: The current content of the test module
201
-
202
- Returns:
203
- The updated test module content with class tests added
204
-
205
- This function:
206
- 1. Identifies all classes in the source module
207
- 2. Determines which classes and methods don't have corresponding tests
208
- 3. Generates skeleton test classes and methods for untested classes and methods
209
- 4. Inserts the new test classes into the existing content
210
- if the class already exists
211
-
212
- Raises:
213
- ValueError: If a test class declaration appears multiple
214
- times in the test module
215
-
216
- """
217
- classes = get_all_cls_from_module(module)
218
- test_classes = get_all_cls_from_module(test_module)
219
-
220
- class_to_methods = {
221
- c: get_all_methods_from_cls(c, exclude_parent_methods=True) for c in classes
222
- }
223
- test_class_to_methods = {
224
- tc: get_all_methods_from_cls(tc, exclude_parent_methods=True)
225
- for tc in test_classes
226
- }
227
-
228
- supposed_test_class_to_methods_names = {
229
- make_test_obj_name(c): [make_test_obj_name(m) for m in ms]
230
- for c, ms in class_to_methods.items()
231
- }
232
- test_class_to_methods_names = {
233
- get_isolated_obj_name(tc): [get_isolated_obj_name(tm) for tm in tms]
234
- for tc, tms in test_class_to_methods.items()
235
- }
236
-
237
- untested_test_class_to_methods_names: dict[str, list[str]] = {}
238
- for (
239
- test_class_name,
240
- supposed_test_methods_names,
241
- ) in supposed_test_class_to_methods_names.items():
242
- test_methods_names = test_class_to_methods_names.get(test_class_name, [])
243
- untested_methods_names = [
244
- tmn for tmn in supposed_test_methods_names if tmn not in test_methods_names
245
- ]
246
- if (
247
- not supposed_test_methods_names
248
- and test_class_name not in test_class_to_methods_names
249
- ):
250
- untested_test_class_to_methods_names[test_class_name] = []
251
- if untested_methods_names:
252
- untested_test_class_to_methods_names[test_class_name] = (
253
- untested_methods_names
254
- )
255
-
256
- for (
257
- test_class_name,
258
- untested_methods_names,
259
- ) in untested_test_class_to_methods_names.items():
260
- test_class_declaration = f"""
261
- class {test_class_name}:
262
- \"\"\"Test class for {reverse_make_test_obj_name(test_class_name)}.\"\"\"
263
- """
264
- test_class_content = test_class_declaration
265
- for untested_method_name in untested_methods_names:
266
- test_class_content += f"""
267
- def {untested_method_name}(self) -> None:
268
- \"\"\"Test method for {reverse_make_test_obj_name(untested_method_name)}.\"\"\"
269
- raise {NotImplementedError.__name__}
270
- """
271
- parts = test_module_content.split(test_class_declaration)
272
- expected_parts = 2
273
- if len(parts) > expected_parts:
274
- msg = f"Found {len(parts)} parts, expected 2"
275
- raise ValueError(msg)
276
- parts.insert(1, test_class_content)
277
- test_module_content = "".join(parts)
278
-
279
- return test_module_content
280
-
281
-
282
- def main() -> None:
283
- """Entry point for the create_tests script.
284
-
285
- Calls the create_tests function to generate all test files.
286
- """
287
- create_tests()
288
-
289
-
290
- if __name__ == "__main__":
291
- main()
1
+ """Utilities for automatically creating test files for the project.
2
+
3
+ This module provides functions to generate test files for all modules and classes
4
+ in the project, ensuring that every function and method has a corresponding test.
5
+ It creates the basic test structure and generates skeleton test functions with
6
+ NotImplementedError to indicate tests that need to be written.
7
+ """
8
+
9
+ from pathlib import Path
10
+ from types import ModuleType
11
+ from typing import cast
12
+
13
+ from winipedia_utils.modules.class_ import (
14
+ get_all_cls_from_module,
15
+ get_all_methods_from_cls,
16
+ )
17
+ from winipedia_utils.modules.function import get_all_functions_from_module
18
+ from winipedia_utils.modules.module import (
19
+ create_module,
20
+ get_isolated_obj_name,
21
+ get_module_content_as_str,
22
+ get_qualname_of_obj,
23
+ to_path,
24
+ )
25
+ from winipedia_utils.modules.package import (
26
+ copy_package,
27
+ get_src_package,
28
+ walk_package,
29
+ )
30
+ from winipedia_utils.testing import tests
31
+ from winipedia_utils.testing.convention import (
32
+ TESTS_PACKAGE_NAME,
33
+ get_test_obj_from_obj,
34
+ make_test_obj_importpath_from_obj,
35
+ make_test_obj_name,
36
+ reverse_make_test_obj_name,
37
+ )
38
+ from winipedia_utils.testing.tests.base.utils.utils import (
39
+ _conftest_content_is_correct,
40
+ _get_conftest_content,
41
+ )
42
+
43
+
44
+ def create_tests() -> None:
45
+ """Create all test files for the project.
46
+
47
+ This function orchestrates the test creation process by first setting up the base
48
+ test structure and then creating test files for all source packages.
49
+ """
50
+ create_tests_base()
51
+ create_tests_for_src_package()
52
+
53
+
54
+ def create_tests_base() -> None:
55
+ """Create the base test structure.
56
+
57
+ This function:
58
+ 1. Creates a mirror of winipedia_utils.testing.tests in the tests directory
59
+ 2. Skips copying __init__.py file contents
60
+ 3. Writes new __init__.py files for all packages
61
+ 4. Creates a conftest.py file with the appropriate pytest plugin configuration
62
+ 5. Does not overwrite anything if it already exists except conftest.py
63
+ """
64
+ tests_path = Path(TESTS_PACKAGE_NAME)
65
+ copy_package(
66
+ src_package=tests,
67
+ dst=".",
68
+ with_file_content=False,
69
+ )
70
+ # write pytest_plugin in the conftest.py
71
+ conftest_path = tests_path / "conftest.py"
72
+ # if conftest does not exist or the content is not the same, overwrite it
73
+ if not _conftest_content_is_correct(conftest_path):
74
+ conftest_path.write_text(_get_conftest_content())
75
+
76
+
77
+ def create_tests_for_src_package() -> None:
78
+ """Create test files for all modules in the source package.
79
+
80
+ This function walks through the source package hierarchy and creates corresponding
81
+ test packages and modules for each package and module found in the source.
82
+ """
83
+ src_package = get_src_package()
84
+ for package, modules in walk_package(src_package):
85
+ create_test_package(package)
86
+ for module in modules:
87
+ create_test_module(module)
88
+
89
+
90
+ def create_test_package(package: ModuleType) -> None:
91
+ """Create a test package for a source package.
92
+
93
+ Args:
94
+ package: The source package module to create a test package for
95
+
96
+ This function creates a test package with the appropriate naming convention
97
+ if it doesn't already exist.
98
+
99
+ """
100
+ test_package_name = make_test_obj_importpath_from_obj(package)
101
+ # create package if it doesn't exist
102
+ create_module(test_package_name, is_package=True)
103
+
104
+
105
+ def create_test_module(module: ModuleType) -> None:
106
+ """Create a test module for a source module.
107
+
108
+ Args:
109
+ module: The source module to create a test module for
110
+
111
+ This function:
112
+ 1. Creates a test module with the appropriate naming convention
113
+ 2. Generates the test module content with skeleton test functions
114
+ 3. Writes the content to the test module file
115
+
116
+ """
117
+ test_module_name = make_test_obj_importpath_from_obj(module)
118
+ test_module = create_module(test_module_name, is_package=False)
119
+ test_module_path = to_path(test_module, is_package=False)
120
+ test_module_path.write_text(get_test_module_content(module))
121
+
122
+
123
+ def get_test_module_content(module: ModuleType) -> str:
124
+ """Generate the content for a test module.
125
+
126
+ Args:
127
+ module: The source module to generate test content for
128
+
129
+ Returns:
130
+ The generated test module content as a string
131
+
132
+ This function:
133
+ 1. Gets the existing test module content if it exists
134
+ 2. Adds test functions for all functions in the source module
135
+ 3. Adds test classes for all classes in the source module
136
+
137
+ """
138
+ test_module = cast("ModuleType", (get_test_obj_from_obj(module)))
139
+ test_module_content = get_module_content_as_str(test_module)
140
+
141
+ test_module_content = get_test_functions_content(
142
+ module, test_module, test_module_content
143
+ )
144
+
145
+ return get_test_classes_content(module, test_module, test_module_content)
146
+
147
+
148
+ def get_test_functions_content(
149
+ module: ModuleType,
150
+ test_module: ModuleType,
151
+ test_module_content: str,
152
+ ) -> str:
153
+ """Generate test function content for a module.
154
+
155
+ Args:
156
+ module: The source module containing functions to test
157
+ test_module: The test module to add function tests to
158
+ test_module_content: The current content of the test module
159
+
160
+ Returns:
161
+ The updated test module content with function tests added
162
+
163
+ This function:
164
+ 1. Identifies all functions in the source module
165
+ 2. Determines which functions don't have corresponding tests
166
+ 3. Generates skeleton test functions for untested functions
167
+
168
+ """
169
+ funcs = get_all_functions_from_module(module)
170
+ test_functions = get_all_functions_from_module(test_module)
171
+ supposed_test_funcs_names = [make_test_obj_name(f) for f in funcs]
172
+
173
+ test_funcs_names = [get_qualname_of_obj(f) for f in test_functions]
174
+
175
+ untested_funcs_names = [
176
+ f for f in supposed_test_funcs_names if f not in test_funcs_names
177
+ ]
178
+
179
+ for test_func_name in untested_funcs_names:
180
+ test_module_content += f"""
181
+
182
+ def {test_func_name}() -> None:
183
+ \"\"\"Test func for {reverse_make_test_obj_name(test_func_name)}.\"\"\"
184
+ raise {NotImplementedError.__name__}
185
+ """
186
+
187
+ return test_module_content
188
+
189
+
190
+ def get_test_classes_content(
191
+ module: ModuleType,
192
+ test_module: ModuleType,
193
+ test_module_content: str,
194
+ ) -> str:
195
+ """Generate test class content for a module.
196
+
197
+ Args:
198
+ module: The source module containing classes to test
199
+ test_module: The test module to add class tests to
200
+ test_module_content: The current content of the test module
201
+
202
+ Returns:
203
+ The updated test module content with class tests added
204
+
205
+ This function:
206
+ 1. Identifies all classes in the source module
207
+ 2. Determines which classes and methods don't have corresponding tests
208
+ 3. Generates skeleton test classes and methods for untested classes and methods
209
+ 4. Inserts the new test classes into the existing content
210
+ if the class already exists
211
+
212
+ Raises:
213
+ ValueError: If a test class declaration appears multiple
214
+ times in the test module
215
+
216
+ """
217
+ classes = get_all_cls_from_module(module)
218
+ test_classes = get_all_cls_from_module(test_module)
219
+
220
+ class_to_methods = {
221
+ c: get_all_methods_from_cls(c, exclude_parent_methods=True) for c in classes
222
+ }
223
+ test_class_to_methods = {
224
+ tc: get_all_methods_from_cls(tc, exclude_parent_methods=True)
225
+ for tc in test_classes
226
+ }
227
+
228
+ supposed_test_class_to_methods_names = {
229
+ make_test_obj_name(c): [make_test_obj_name(m) for m in ms]
230
+ for c, ms in class_to_methods.items()
231
+ }
232
+ test_class_to_methods_names = {
233
+ get_isolated_obj_name(tc): [get_isolated_obj_name(tm) for tm in tms]
234
+ for tc, tms in test_class_to_methods.items()
235
+ }
236
+
237
+ untested_test_class_to_methods_names: dict[str, list[str]] = {}
238
+ for (
239
+ test_class_name,
240
+ supposed_test_methods_names,
241
+ ) in supposed_test_class_to_methods_names.items():
242
+ test_methods_names = test_class_to_methods_names.get(test_class_name, [])
243
+ untested_methods_names = [
244
+ tmn for tmn in supposed_test_methods_names if tmn not in test_methods_names
245
+ ]
246
+ if (
247
+ not supposed_test_methods_names
248
+ and test_class_name not in test_class_to_methods_names
249
+ ):
250
+ untested_test_class_to_methods_names[test_class_name] = []
251
+ if untested_methods_names:
252
+ untested_test_class_to_methods_names[test_class_name] = (
253
+ untested_methods_names
254
+ )
255
+
256
+ for (
257
+ test_class_name,
258
+ untested_methods_names,
259
+ ) in untested_test_class_to_methods_names.items():
260
+ test_class_declaration = f"""
261
+ class {test_class_name}:
262
+ \"\"\"Test class for {reverse_make_test_obj_name(test_class_name)}.\"\"\"
263
+ """
264
+ test_class_content = test_class_declaration
265
+ for untested_method_name in untested_methods_names:
266
+ test_class_content += f"""
267
+ def {untested_method_name}(self) -> None:
268
+ \"\"\"Test method for {reverse_make_test_obj_name(untested_method_name)}.\"\"\"
269
+ raise {NotImplementedError.__name__}
270
+ """
271
+ parts = test_module_content.split(test_class_declaration)
272
+ expected_parts = 2
273
+ if len(parts) > expected_parts:
274
+ msg = f"Found {len(parts)} parts, expected 2"
275
+ raise ValueError(msg)
276
+ parts.insert(1, test_class_content)
277
+ test_module_content = "".join(parts)
278
+
279
+ return test_module_content
280
+
281
+
282
+ def main() -> None:
283
+ """Entry point for the create_tests script.
284
+
285
+ Calls the create_tests function to generate all test files.
286
+ """
287
+ create_tests()
288
+
289
+
290
+ if __name__ == "__main__":
291
+ main()
@@ -1,28 +1,28 @@
1
- """Testing fixtures for pytest.
2
-
3
- This module provides custom fixtures for pytest that can be used to
4
- automate common testing tasks and provide consistent setup and teardown
5
- for tests.
6
- """
7
-
8
- import functools
9
-
10
- import pytest
11
-
12
- function_fixture = functools.partial(pytest.fixture, scope="function")
13
- class_fixture = functools.partial(pytest.fixture, scope="class")
14
- module_fixture = functools.partial(pytest.fixture, scope="module")
15
- package_fixture = functools.partial(pytest.fixture, scope="package")
16
- session_fixture = functools.partial(pytest.fixture, scope="session")
17
-
18
- autouse_function_fixture = functools.partial(
19
- pytest.fixture, scope="function", autouse=True
20
- )
21
- autouse_class_fixture = functools.partial(pytest.fixture, scope="class", autouse=True)
22
- autouse_module_fixture = functools.partial(pytest.fixture, scope="module", autouse=True)
23
- autouse_package_fixture = functools.partial(
24
- pytest.fixture, scope="package", autouse=True
25
- )
26
- autouse_session_fixture = functools.partial(
27
- pytest.fixture, scope="session", autouse=True
28
- )
1
+ """Testing fixtures for pytest.
2
+
3
+ This module provides custom fixtures for pytest that can be used to
4
+ automate common testing tasks and provide consistent setup and teardown
5
+ for tests.
6
+ """
7
+
8
+ import functools
9
+
10
+ import pytest
11
+
12
+ function_fixture = functools.partial(pytest.fixture, scope="function")
13
+ class_fixture = functools.partial(pytest.fixture, scope="class")
14
+ module_fixture = functools.partial(pytest.fixture, scope="module")
15
+ package_fixture = functools.partial(pytest.fixture, scope="package")
16
+ session_fixture = functools.partial(pytest.fixture, scope="session")
17
+
18
+ autouse_function_fixture = functools.partial(
19
+ pytest.fixture, scope="function", autouse=True
20
+ )
21
+ autouse_class_fixture = functools.partial(pytest.fixture, scope="class", autouse=True)
22
+ autouse_module_fixture = functools.partial(pytest.fixture, scope="module", autouse=True)
23
+ autouse_package_fixture = functools.partial(
24
+ pytest.fixture, scope="package", autouse=True
25
+ )
26
+ autouse_session_fixture = functools.partial(
27
+ pytest.fixture, scope="session", autouse=True
28
+ )
@@ -1 +1 @@
1
- """__init__ module for winipedia_utils.testing.tests.base.fixtures."""
1
+ """__init__ module for winipedia_utils.testing.tests.base.fixtures."""
@@ -1,6 +1,6 @@
1
- """Fixtures for testing.
2
-
3
- This module provides custom fixtures for pytest that can be used to
4
- automate common testing tasks and provide consistent setup and teardown
5
- for tests.
6
- """
1
+ """Fixtures for testing.
2
+
3
+ This module provides custom fixtures for pytest that can be used to
4
+ automate common testing tasks and provide consistent setup and teardown
5
+ for tests.
6
+ """