winipedia-utils 0.2.63__py3-none-any.whl → 0.3.7__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.
- winipedia_utils/concurrent/concurrent.py +7 -2
- winipedia_utils/concurrent/multiprocessing.py +1 -2
- winipedia_utils/concurrent/multithreading.py +2 -2
- winipedia_utils/git/gitignore/config.py +54 -0
- winipedia_utils/git/gitignore/gitignore.py +5 -63
- winipedia_utils/git/pre_commit/config.py +45 -58
- winipedia_utils/git/pre_commit/hooks.py +13 -13
- winipedia_utils/git/pre_commit/run_hooks.py +2 -2
- winipedia_utils/git/workflows/base/base.py +102 -52
- winipedia_utils/git/workflows/publish.py +25 -49
- winipedia_utils/git/workflows/release.py +22 -48
- winipedia_utils/iterating/iterate.py +59 -1
- winipedia_utils/modules/class_.py +60 -10
- winipedia_utils/modules/function.py +18 -1
- winipedia_utils/modules/package.py +16 -7
- winipedia_utils/projects/poetry/config.py +122 -110
- winipedia_utils/projects/poetry/poetry.py +1 -8
- winipedia_utils/projects/project.py +7 -13
- winipedia_utils/setup.py +11 -29
- winipedia_utils/testing/config.py +95 -0
- winipedia_utils/testing/create_tests.py +4 -18
- winipedia_utils/testing/skip.py +10 -0
- winipedia_utils/testing/tests/base/fixtures/scopes/class_.py +3 -3
- winipedia_utils/testing/tests/base/fixtures/scopes/module.py +6 -4
- winipedia_utils/testing/tests/base/fixtures/scopes/session.py +28 -176
- winipedia_utils/testing/tests/base/utils/utils.py +11 -55
- winipedia_utils/text/config.py +143 -0
- winipedia_utils-0.3.7.dist-info/METADATA +324 -0
- {winipedia_utils-0.2.63.dist-info → winipedia_utils-0.3.7.dist-info}/RECORD +31 -28
- winipedia_utils/consts.py +0 -21
- winipedia_utils-0.2.63.dist-info/METADATA +0 -738
- {winipedia_utils-0.2.63.dist-info → winipedia_utils-0.3.7.dist-info}/WHEEL +0 -0
- {winipedia_utils-0.2.63.dist-info → winipedia_utils-0.3.7.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,115 +3,127 @@
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
from winipedia_utils.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
"
|
|
6
|
+
from winipedia_utils.modules.package import get_src_package
|
|
7
|
+
from winipedia_utils.projects.project import make_name_from_package
|
|
8
|
+
from winipedia_utils.testing.convention import TESTS_PACKAGE_NAME
|
|
9
|
+
from winipedia_utils.text.config import ConfigFile, TomlConfigFile
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class PyProjectTomlConfig(TomlConfigFile):
|
|
13
|
+
"""Config file for pyproject.toml."""
|
|
14
|
+
|
|
15
|
+
PATH = Path("pyproject.toml")
|
|
16
|
+
|
|
17
|
+
def get_path(self) -> Path:
|
|
18
|
+
"""Get the path to the config file."""
|
|
19
|
+
return self.PATH
|
|
20
|
+
|
|
21
|
+
def get_configs(self) -> dict[str, Any]:
|
|
22
|
+
"""Get the config."""
|
|
23
|
+
return {
|
|
24
|
+
"project": {
|
|
25
|
+
"name": make_name_from_package(get_src_package(), capitalize=False),
|
|
26
|
+
"readme": "README.md",
|
|
27
|
+
"dynamic": ["dependencies"],
|
|
28
|
+
},
|
|
29
|
+
"build-system": {
|
|
30
|
+
"requires": ["poetry-core>=2.0.0,<3.0.0"],
|
|
31
|
+
"build-backend": "poetry.core.masonry.api",
|
|
32
|
+
},
|
|
33
|
+
"tool": {
|
|
34
|
+
"poetry": {
|
|
35
|
+
"packages": [{"include": get_src_package().__name__}],
|
|
36
|
+
"group": {
|
|
37
|
+
"dev": {
|
|
38
|
+
"dependencies": dict.fromkeys(
|
|
39
|
+
[
|
|
40
|
+
"ruff",
|
|
41
|
+
"pre-commit",
|
|
42
|
+
"mypy",
|
|
43
|
+
"pytest",
|
|
44
|
+
"bandit",
|
|
45
|
+
"types-setuptools",
|
|
46
|
+
"types-tqdm",
|
|
47
|
+
"types-defusedxml",
|
|
48
|
+
"types-pyyaml",
|
|
49
|
+
"pytest-mock",
|
|
50
|
+
],
|
|
51
|
+
"*",
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
"ruff": {
|
|
57
|
+
"exclude": [".*", "**/migrations/*.py"],
|
|
58
|
+
"lint": {
|
|
59
|
+
"select": ["ALL"],
|
|
60
|
+
"ignore": ["D203", "D213", "COM812", "ANN401"],
|
|
61
|
+
"fixable": ["ALL"],
|
|
62
|
+
"pydocstyle": {"convention": "google"},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
"mypy": {
|
|
66
|
+
"strict": True,
|
|
67
|
+
"warn_unreachable": True,
|
|
68
|
+
"show_error_codes": True,
|
|
69
|
+
"files": ".",
|
|
59
70
|
},
|
|
71
|
+
"pytest": {"ini_options": {"testpaths": [TESTS_PACKAGE_NAME]}},
|
|
72
|
+
"bandit": {},
|
|
60
73
|
},
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
dump_pyproject_toml(toml)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
def get_package_name(self) -> str:
|
|
77
|
+
"""Get the package name."""
|
|
78
|
+
project_dict = self.load().get("project", {})
|
|
79
|
+
package_name = str(project_dict.get("name", ""))
|
|
80
|
+
return package_name.replace("-", "_")
|
|
81
|
+
|
|
82
|
+
def get_dev_dependencies(self) -> set[str]:
|
|
83
|
+
"""Get the dev dependencies."""
|
|
84
|
+
dev_dependencies = set(
|
|
85
|
+
self.load()
|
|
86
|
+
.get("tool", {})
|
|
87
|
+
.get("poetry", {})
|
|
88
|
+
.get("group", {})
|
|
89
|
+
.get("dev", {})
|
|
90
|
+
.get("dependencies", {})
|
|
91
|
+
.keys()
|
|
92
|
+
)
|
|
93
|
+
if not dev_dependencies:
|
|
94
|
+
dev_dependencies = set(
|
|
95
|
+
self.load().get("dependency-groups", {}).get("dev", [])
|
|
96
|
+
)
|
|
97
|
+
dev_dependencies = {d.split("(")[0].strip() for d in dev_dependencies}
|
|
98
|
+
return dev_dependencies
|
|
99
|
+
|
|
100
|
+
def get_expected_dev_dependencies(self) -> set[str]:
|
|
101
|
+
"""Get the expected dev dependencies."""
|
|
102
|
+
return set(
|
|
103
|
+
self.get_configs()["tool"]["poetry"]["group"]["dev"]["dependencies"].keys()
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class PyTypedConfigFile(ConfigFile):
|
|
108
|
+
"""Config file for py.typed."""
|
|
109
|
+
|
|
110
|
+
def get_path(self) -> Path:
|
|
111
|
+
"""Get the path to the config file."""
|
|
112
|
+
toml_config = PyProjectTomlConfig()
|
|
113
|
+
package_name = toml_config.get_package_name()
|
|
114
|
+
return Path(package_name) / "py.typed"
|
|
115
|
+
|
|
116
|
+
def load(self) -> dict[str, Any]:
|
|
117
|
+
"""Load the config file."""
|
|
118
|
+
return {}
|
|
119
|
+
|
|
120
|
+
def dump(self, config: dict[str, Any]) -> None:
|
|
121
|
+
"""Dump the config file."""
|
|
122
|
+
if config:
|
|
123
|
+
msg = "Cannot dump to py.typed file."
|
|
124
|
+
raise ValueError(msg)
|
|
125
|
+
self.path.touch()
|
|
126
|
+
|
|
127
|
+
def get_configs(self) -> dict[str, Any]:
|
|
128
|
+
"""Get the config."""
|
|
129
|
+
return {}
|
|
@@ -5,9 +5,8 @@ This module provides utility functions for working with Python projects
|
|
|
5
5
|
|
|
6
6
|
import sys
|
|
7
7
|
|
|
8
|
-
from winipedia_utils.consts import _DEV_DEPENDENCIES
|
|
9
8
|
from winipedia_utils.logging.logger import get_logger
|
|
10
|
-
from winipedia_utils.os.os import
|
|
9
|
+
from winipedia_utils.os.os import which_with_raise
|
|
11
10
|
|
|
12
11
|
logger = get_logger(__name__)
|
|
13
12
|
|
|
@@ -23,9 +22,3 @@ POETRY_ADD_DEV_ARGS = [*POETRY_ADD_ARGS, "--group", "dev"]
|
|
|
23
22
|
POETRY_RUN_PYTHON_ARGS = [*POETRY_RUN_ARGS, sys.executable]
|
|
24
23
|
|
|
25
24
|
POETRY_RUN_RUFF_ARGS = [*POETRY_RUN_ARGS, "ruff"]
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def _install_dev_dependencies() -> None:
|
|
29
|
-
"""Install winipedia_utils dev dependencies as dev dependencies."""
|
|
30
|
-
logger.info("Adding dev dependencies: %s", _DEV_DEPENDENCIES)
|
|
31
|
-
run_subprocess([*POETRY_ADD_DEV_ARGS, *_DEV_DEPENDENCIES], check=True)
|
|
@@ -2,23 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
from types import ModuleType
|
|
4
4
|
|
|
5
|
-
from winipedia_utils.modules.module import create_module
|
|
6
|
-
from winipedia_utils.modules.package import get_src_package
|
|
7
|
-
from winipedia_utils.projects.poetry.config import get_poetry_package_name
|
|
5
|
+
from winipedia_utils.modules.module import create_module
|
|
8
6
|
|
|
9
7
|
|
|
10
|
-
def
|
|
8
|
+
def create_project_root() -> None:
|
|
11
9
|
"""Create the project root."""
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
from winipedia_utils.projects.poetry.config import ( # noqa: PLC0415 # avoid circular import
|
|
11
|
+
PyProjectTomlConfig,
|
|
12
|
+
)
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
src_package_name = get_src_package().__name__
|
|
20
|
-
py_typed_path = to_path(src_package_name, is_package=True) / "py.typed"
|
|
21
|
-
py_typed_path.touch()
|
|
14
|
+
src_package_name = PyProjectTomlConfig().get_package_name()
|
|
15
|
+
create_module(src_package_name, is_package=True)
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
def make_name_from_package(
|
winipedia_utils/setup.py
CHANGED
|
@@ -9,51 +9,33 @@ This script is intended to be called once at the beginning of a project.
|
|
|
9
9
|
from collections.abc import Callable
|
|
10
10
|
from typing import Any
|
|
11
11
|
|
|
12
|
-
from winipedia_utils.git.
|
|
13
|
-
from winipedia_utils.git.pre_commit.config import (
|
|
14
|
-
_add_package_hook_to_pre_commit_config,
|
|
15
|
-
_pre_commit_install,
|
|
16
|
-
)
|
|
17
|
-
from winipedia_utils.git.pre_commit.run_hooks import _run_all_hooks
|
|
18
|
-
from winipedia_utils.git.workflows.publish import _add_publish_workflow
|
|
19
|
-
from winipedia_utils.git.workflows.release import _add_release_workflow
|
|
12
|
+
from winipedia_utils.git.pre_commit.run_hooks import run_all
|
|
20
13
|
from winipedia_utils.logging.logger import get_logger
|
|
21
|
-
from winipedia_utils.projects.
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
from winipedia_utils.projects.poetry.poetry import (
|
|
25
|
-
_install_dev_dependencies,
|
|
26
|
-
)
|
|
27
|
-
from winipedia_utils.projects.project import _create_project_root
|
|
14
|
+
from winipedia_utils.projects.project import create_project_root
|
|
15
|
+
from winipedia_utils.text.config import ConfigFile
|
|
28
16
|
|
|
29
17
|
logger = get_logger(__name__)
|
|
30
18
|
|
|
31
19
|
|
|
32
|
-
SETUP_STEPS = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_add_package_patterns_to_gitignore,
|
|
37
|
-
_add_release_workflow,
|
|
38
|
-
_add_publish_workflow,
|
|
39
|
-
_add_configurations_to_pyproject_toml,
|
|
40
|
-
_create_project_root,
|
|
41
|
-
_run_all_hooks,
|
|
20
|
+
SETUP_STEPS: list[Callable[..., Any]] = [
|
|
21
|
+
ConfigFile.init_config_files,
|
|
22
|
+
create_project_root,
|
|
23
|
+
run_all,
|
|
42
24
|
]
|
|
43
25
|
|
|
44
26
|
|
|
45
|
-
def
|
|
27
|
+
def get_setup_steps() -> list[Callable[..., Any]]:
|
|
46
28
|
"""Get the setup steps."""
|
|
47
29
|
return SETUP_STEPS
|
|
48
30
|
|
|
49
31
|
|
|
50
|
-
def
|
|
32
|
+
def setup() -> None:
|
|
51
33
|
"""Set up the project."""
|
|
52
|
-
for step in
|
|
34
|
+
for step in get_setup_steps():
|
|
53
35
|
logger.info("Running setup step: %s", step.__name__)
|
|
54
36
|
step()
|
|
55
37
|
logger.info("Setup complete!")
|
|
56
38
|
|
|
57
39
|
|
|
58
40
|
if __name__ == "__main__":
|
|
59
|
-
|
|
41
|
+
setup()
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Config utilities for testing."""
|
|
2
|
+
|
|
3
|
+
from abc import abstractmethod
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from winipedia_utils.testing.convention import TESTS_PACKAGE_NAME
|
|
8
|
+
from winipedia_utils.text.config import ConfigFile
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PythonConfigFile(ConfigFile):
|
|
12
|
+
"""Base class for python config files."""
|
|
13
|
+
|
|
14
|
+
CONTENT_KEY = "content"
|
|
15
|
+
|
|
16
|
+
def load(self) -> dict[str, str]:
|
|
17
|
+
"""Load the config file."""
|
|
18
|
+
return {self.CONTENT_KEY: self.path.read_text()}
|
|
19
|
+
|
|
20
|
+
def dump(self, config: dict[str, Any]) -> None:
|
|
21
|
+
"""Dump the config file."""
|
|
22
|
+
self.path.write_text(config[self.CONTENT_KEY])
|
|
23
|
+
|
|
24
|
+
def get_configs(self) -> dict[str, Any]:
|
|
25
|
+
"""Get the config."""
|
|
26
|
+
return {self.CONTENT_KEY: self.get_content()}
|
|
27
|
+
|
|
28
|
+
@abstractmethod
|
|
29
|
+
def get_content(self) -> str:
|
|
30
|
+
"""Get the content."""
|
|
31
|
+
return self.load()[self.CONTENT_KEY]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ConftestConfigFile(PythonConfigFile):
|
|
35
|
+
"""Config file for conftest.py."""
|
|
36
|
+
|
|
37
|
+
PATH = Path(f"{TESTS_PACKAGE_NAME}/conftest.py")
|
|
38
|
+
|
|
39
|
+
def get_path(self) -> Path:
|
|
40
|
+
"""Get the path to the config file."""
|
|
41
|
+
return self.PATH
|
|
42
|
+
|
|
43
|
+
def get_content(self) -> str:
|
|
44
|
+
"""Get the config content."""
|
|
45
|
+
return '''"""Pytest configuration for tests.
|
|
46
|
+
|
|
47
|
+
This module configures pytest plugins for the test suite, setting up the necessary
|
|
48
|
+
fixtures and hooks for the different
|
|
49
|
+
test scopes (function, class, module, package, session).
|
|
50
|
+
It also import custom plugins from tests/base/scopes.
|
|
51
|
+
This file should not be modified manually.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
pytest_plugins = ["winipedia_utils.testing.tests.conftest"]
|
|
55
|
+
'''
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ZeroTestConfigFile(PythonConfigFile):
|
|
59
|
+
"""Config file for test_0.py."""
|
|
60
|
+
|
|
61
|
+
PATH = Path(f"{TESTS_PACKAGE_NAME}/test_0.py")
|
|
62
|
+
|
|
63
|
+
def get_path(self) -> Path:
|
|
64
|
+
"""Get the path to the config file."""
|
|
65
|
+
return self.PATH
|
|
66
|
+
|
|
67
|
+
def get_content(self) -> str:
|
|
68
|
+
"""Get the config."""
|
|
69
|
+
return '''"""Contains an empty test."""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_0() -> None:
|
|
73
|
+
"""Empty test.
|
|
74
|
+
|
|
75
|
+
Exists so that when no tests are written yet the base fixtures are executed.
|
|
76
|
+
"""
|
|
77
|
+
'''
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class ExperimentConfigFile(PythonConfigFile):
|
|
81
|
+
"""Config file for experiment.py.
|
|
82
|
+
|
|
83
|
+
Is at root level and in .gitignore for experimentation.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
PATH = Path("experiment.py")
|
|
87
|
+
|
|
88
|
+
def get_path(self) -> Path:
|
|
89
|
+
"""Get the path to the config file."""
|
|
90
|
+
return self.PATH
|
|
91
|
+
|
|
92
|
+
def get_content(self) -> str:
|
|
93
|
+
"""Get the config."""
|
|
94
|
+
return '''"""This file is for experimentation and is ignored by git."""
|
|
95
|
+
'''
|
|
@@ -6,7 +6,6 @@ It creates the basic test structure and generates skeleton test functions with
|
|
|
6
6
|
NotImplementedError to indicate tests that need to be written.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
from pathlib import Path
|
|
10
9
|
from types import ModuleType
|
|
11
10
|
from typing import cast
|
|
12
11
|
|
|
@@ -28,19 +27,13 @@ from winipedia_utils.modules.package import (
|
|
|
28
27
|
walk_package,
|
|
29
28
|
)
|
|
30
29
|
from winipedia_utils.testing import tests
|
|
30
|
+
from winipedia_utils.testing.config import ConftestConfigFile, ZeroTestConfigFile
|
|
31
31
|
from winipedia_utils.testing.convention import (
|
|
32
|
-
TESTS_PACKAGE_NAME,
|
|
33
32
|
get_test_obj_from_obj,
|
|
34
33
|
make_test_obj_importpath_from_obj,
|
|
35
34
|
make_test_obj_name,
|
|
36
35
|
reverse_make_test_obj_name,
|
|
37
36
|
)
|
|
38
|
-
from winipedia_utils.testing.tests.base.utils.utils import (
|
|
39
|
-
_conftest_content_is_correct,
|
|
40
|
-
_get_conftest_content,
|
|
41
|
-
_get_test_0_content,
|
|
42
|
-
_test_0_content_is_correct,
|
|
43
|
-
)
|
|
44
37
|
|
|
45
38
|
|
|
46
39
|
def create_tests() -> None:
|
|
@@ -63,21 +56,14 @@ def create_tests_base() -> None:
|
|
|
63
56
|
4. Creates a conftest.py file with the appropriate pytest plugin configuration
|
|
64
57
|
5. Does not overwrite anything if it already exists except conftest.py
|
|
65
58
|
"""
|
|
66
|
-
tests_path = Path(TESTS_PACKAGE_NAME)
|
|
67
59
|
copy_package(
|
|
68
60
|
src_package=tests,
|
|
69
61
|
dst=".",
|
|
70
62
|
with_file_content=False,
|
|
71
63
|
)
|
|
72
|
-
# write
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if not _conftest_content_is_correct(conftest_path):
|
|
76
|
-
conftest_path.write_text(_get_conftest_content())
|
|
77
|
-
|
|
78
|
-
test_0_path = tests_path / "test_0.py"
|
|
79
|
-
if not _test_0_content_is_correct(test_0_path):
|
|
80
|
-
test_0_path.write_text(_get_test_0_content())
|
|
64
|
+
# write the config files
|
|
65
|
+
_ = ConftestConfigFile()
|
|
66
|
+
_ = ZeroTestConfigFile()
|
|
81
67
|
|
|
82
68
|
|
|
83
69
|
def create_tests_for_src_package() -> None:
|
|
@@ -9,11 +9,11 @@ mechanism.
|
|
|
9
9
|
import pytest
|
|
10
10
|
|
|
11
11
|
from winipedia_utils.testing.fixtures import autouse_class_fixture
|
|
12
|
-
from winipedia_utils.testing.tests.base.utils.utils import
|
|
12
|
+
from winipedia_utils.testing.tests.base.utils.utils import assert_no_untested_objs
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
@autouse_class_fixture
|
|
16
|
-
def
|
|
16
|
+
def assert_all_methods_tested(request: pytest.FixtureRequest) -> None:
|
|
17
17
|
"""Verify that all methods in a class have corresponding tests.
|
|
18
18
|
|
|
19
19
|
This fixture runs automatically for each test class and checks that every
|
|
@@ -30,4 +30,4 @@ def _test_all_methods_tested(request: pytest.FixtureRequest) -> None:
|
|
|
30
30
|
class_ = request.node.cls
|
|
31
31
|
if class_ is None:
|
|
32
32
|
return
|
|
33
|
-
|
|
33
|
+
assert_no_untested_objs(class_)
|
|
@@ -8,12 +8,14 @@ mechanism.
|
|
|
8
8
|
|
|
9
9
|
import pytest
|
|
10
10
|
|
|
11
|
+
from winipedia_utils.modules.module import to_module_name
|
|
12
|
+
from winipedia_utils.testing.config import ZeroTestConfigFile
|
|
11
13
|
from winipedia_utils.testing.fixtures import autouse_module_fixture
|
|
12
|
-
from winipedia_utils.testing.tests.base.utils.utils import
|
|
14
|
+
from winipedia_utils.testing.tests.base.utils.utils import assert_no_untested_objs
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
@autouse_module_fixture
|
|
16
|
-
def
|
|
18
|
+
def assert_all_funcs_and_classes_tested(request: pytest.FixtureRequest) -> None:
|
|
17
19
|
"""Verify that all functions and classes in a module have corresponding tests.
|
|
18
20
|
|
|
19
21
|
This fixture runs automatically for each test module and checks that every
|
|
@@ -28,6 +30,6 @@ def _test_all_funcs_and_classes_tested(request: pytest.FixtureRequest) -> None:
|
|
|
28
30
|
|
|
29
31
|
"""
|
|
30
32
|
module = request.module
|
|
31
|
-
if module.__name__ ==
|
|
33
|
+
if module.__name__ == to_module_name(ZeroTestConfigFile().get_path()):
|
|
32
34
|
return
|
|
33
|
-
|
|
35
|
+
assert_no_untested_objs(module)
|