winipedia-utils 0.1.2__py3-none-any.whl → 0.1.4__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.
- winipedia_utils/modules/package.py +1 -1
- winipedia_utils/projects/project.py +19 -0
- winipedia_utils/py.typed +1 -0
- winipedia_utils/setup.py +3 -0
- winipedia_utils/testing/create_tests.py +2 -2
- winipedia_utils/testing/tests/base/fixtures/scopes/session.py +41 -3
- {winipedia_utils-0.1.2.dist-info → winipedia_utils-0.1.4.dist-info}/METADATA +3 -3
- {winipedia_utils-0.1.2.dist-info → winipedia_utils-0.1.4.dist-info}/RECORD +10 -8
- {winipedia_utils-0.1.2.dist-info → winipedia_utils-0.1.4.dist-info}/LICENSE +0 -0
- {winipedia_utils-0.1.2.dist-info → winipedia_utils-0.1.4.dist-info}/WHEEL +0 -0
@@ -28,7 +28,7 @@ from winipedia_utils.logging.logger import get_logger
|
|
28
28
|
logger = get_logger(__name__)
|
29
29
|
|
30
30
|
|
31
|
-
def
|
31
|
+
def get_src_package() -> ModuleType:
|
32
32
|
"""Identify and return the main source package of the project.
|
33
33
|
|
34
34
|
Discovers the main source package by finding all top-level packages
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"""Utilities for working with Python projects."""
|
2
|
+
|
3
|
+
from winipedia_utils.modules.module import create_module, to_path
|
4
|
+
from winipedia_utils.modules.package import get_src_package
|
5
|
+
from winipedia_utils.projects.poetry.config import get_poetry_package_name
|
6
|
+
|
7
|
+
|
8
|
+
def _create_project_root() -> None:
|
9
|
+
"""Create the project root."""
|
10
|
+
src_package_name = get_poetry_package_name()
|
11
|
+
create_module(src_package_name, is_package=True)
|
12
|
+
_create_py_typed()
|
13
|
+
|
14
|
+
|
15
|
+
def _create_py_typed() -> None:
|
16
|
+
"""Create the py.typed file."""
|
17
|
+
src_package_name = get_src_package().__name__
|
18
|
+
py_typed_path = to_path(src_package_name, is_package=True) / "py.typed"
|
19
|
+
py_typed_path.touch()
|
winipedia_utils/py.typed
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
winipedia_utils/setup.py
CHANGED
@@ -16,6 +16,7 @@ from winipedia_utils.projects.poetry.config import (
|
|
16
16
|
from winipedia_utils.projects.poetry.poetry import (
|
17
17
|
_install_dev_dependencies,
|
18
18
|
)
|
19
|
+
from winipedia_utils.projects.project import _create_project_root
|
19
20
|
|
20
21
|
logger = get_logger(__name__)
|
21
22
|
|
@@ -30,6 +31,8 @@ def _setup() -> None:
|
|
30
31
|
_add_package_patterns_to_gitignore()
|
31
32
|
# add tool.* configurations to pyproject.toml
|
32
33
|
_add_configurations_to_pyproject_toml()
|
34
|
+
# create the project root
|
35
|
+
_create_project_root()
|
33
36
|
# run pre-commit once, create tests is included here
|
34
37
|
_run_all_hooks()
|
35
38
|
logger.info("Setup complete!")
|
@@ -24,7 +24,7 @@ from winipedia_utils.modules.module import (
|
|
24
24
|
)
|
25
25
|
from winipedia_utils.modules.package import (
|
26
26
|
copy_package,
|
27
|
-
|
27
|
+
get_src_package,
|
28
28
|
walk_package,
|
29
29
|
)
|
30
30
|
from winipedia_utils.testing import tests
|
@@ -80,7 +80,7 @@ def create_tests_for_src_package() -> None:
|
|
80
80
|
This function walks through the source package hierarchy and creates corresponding
|
81
81
|
test packages and modules for each package and module found in the source.
|
82
82
|
"""
|
83
|
-
src_package =
|
83
|
+
src_package = get_src_package()
|
84
84
|
for package, modules in walk_package(src_package):
|
85
85
|
create_test_package(package)
|
86
86
|
for module in modules:
|
@@ -17,7 +17,7 @@ from winipedia_utils.git.pre_commit.config import (
|
|
17
17
|
from winipedia_utils.modules.module import to_path
|
18
18
|
from winipedia_utils.modules.package import (
|
19
19
|
find_packages,
|
20
|
-
|
20
|
+
get_src_package,
|
21
21
|
walk_package,
|
22
22
|
)
|
23
23
|
from winipedia_utils.projects.poetry.config import (
|
@@ -188,7 +188,7 @@ def _test_all_src_code_in_one_package() -> None:
|
|
188
188
|
|
189
189
|
"""
|
190
190
|
packages = find_packages(depth=0)
|
191
|
-
src_package =
|
191
|
+
src_package = get_src_package().__name__
|
192
192
|
expected_packages = {TESTS_PACKAGE_NAME, src_package}
|
193
193
|
assert_with_msg(
|
194
194
|
set(packages) == expected_packages,
|
@@ -196,6 +196,44 @@ def _test_all_src_code_in_one_package() -> None:
|
|
196
196
|
)
|
197
197
|
|
198
198
|
|
199
|
+
@autouse_session_fixture
|
200
|
+
def _test_src_package_correctly_named() -> None:
|
201
|
+
"""Verify that the source package is correctly named.
|
202
|
+
|
203
|
+
This fixture runs once per test session and checks that the source package
|
204
|
+
is correctly named after the project.
|
205
|
+
|
206
|
+
Raises:
|
207
|
+
AssertionError: If the source package is not correctly named
|
208
|
+
|
209
|
+
"""
|
210
|
+
src_package = get_src_package().__name__
|
211
|
+
assert_with_msg(
|
212
|
+
src_package == get_poetry_package_name(),
|
213
|
+
f"Expected source package to be named {get_poetry_package_name()}, "
|
214
|
+
f"but it is named {src_package}",
|
215
|
+
)
|
216
|
+
|
217
|
+
|
218
|
+
@autouse_session_fixture
|
219
|
+
def _test_py_typed_exists() -> None:
|
220
|
+
"""Verify that the py.typed file exists in the source package.
|
221
|
+
|
222
|
+
This fixture runs once per test session and checks that the py.typed file
|
223
|
+
exists in the source package.
|
224
|
+
|
225
|
+
Raises:
|
226
|
+
AssertionError: If the py.typed file doesn't exist
|
227
|
+
|
228
|
+
"""
|
229
|
+
src_package = get_src_package()
|
230
|
+
py_typed_path = to_path(src_package.__name__, is_package=True) / "py.typed"
|
231
|
+
assert_with_msg(
|
232
|
+
py_typed_path.exists(),
|
233
|
+
f"Expected py.typed file to exist at {py_typed_path}",
|
234
|
+
)
|
235
|
+
|
236
|
+
|
199
237
|
@autouse_session_fixture
|
200
238
|
def _test_project_structure_mirrored() -> None:
|
201
239
|
"""Verify that the project structure is mirrored in tests.
|
@@ -207,7 +245,7 @@ def _test_project_structure_mirrored() -> None:
|
|
207
245
|
AssertionError: If any package or module doesn't have a corresponding test
|
208
246
|
|
209
247
|
"""
|
210
|
-
src_package =
|
248
|
+
src_package = get_src_package()
|
211
249
|
|
212
250
|
# we will now go through all the modules in the src package and check
|
213
251
|
# that there is a corresponding test module
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: winipedia-utils
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: A package with many utility functions
|
5
5
|
License: MIT
|
6
6
|
Author: Winipedia
|
@@ -150,11 +150,11 @@ create_tests()
|
|
150
150
|
### Module Introspection
|
151
151
|
|
152
152
|
```python
|
153
|
-
from winipedia_utils.modules.package import
|
153
|
+
from winipedia_utils.modules.package import get_src_package, walk_package
|
154
154
|
from winipedia_utils.modules.function import get_all_functions_from_module
|
155
155
|
|
156
156
|
# Discover your main source package
|
157
|
-
src_package =
|
157
|
+
src_package = get_src_package()
|
158
158
|
|
159
159
|
# Walk through all modules in a package
|
160
160
|
for package, modules in walk_package(src_package):
|
@@ -27,7 +27,7 @@ winipedia_utils/modules/__init__.py,sha256=e3CFaC3FhK4ibknFOv1bqOZxA7XeVwmLqWX7o
|
|
27
27
|
winipedia_utils/modules/class_.py,sha256=RDjal6QYYs9z81DT1mIFrnEhQ9vgN2tCAYN1WWnN24Y,2462
|
28
28
|
winipedia_utils/modules/function.py,sha256=Qn1OPV5dwO-7f3a0f0RpWcrH-E9teGPwldRtwbFYzRM,2551
|
29
29
|
winipedia_utils/modules/module.py,sha256=iJwUJPhVkxyRjJqHVVWh3GNJFiYf45ZdSfR21puQAmw,12673
|
30
|
-
winipedia_utils/modules/package.py,sha256=
|
30
|
+
winipedia_utils/modules/package.py,sha256=jPI7fcJ5VFWO7nRvjB6cGv_mahx0BUej9qhKARSK_Vk,12485
|
31
31
|
winipedia_utils/oop/__init__.py,sha256=wGjsVwLbTVEQWOfDJvN9nlvC-3NmAi8Doc2xIrm6e78,47
|
32
32
|
winipedia_utils/oop/mixins/__init__.py,sha256=PDK-cJcdRUfDUCz36qQ5pmMW07G133WtN49OpmILGNI,54
|
33
33
|
winipedia_utils/oop/mixins/meta.py,sha256=UpHags1j80OABxW4Q3QYt7A7lLIArvgUrGcWeYJaRyU,10576
|
@@ -38,11 +38,13 @@ winipedia_utils/projects/__init__.py,sha256=6oTiSlUMAwO5xnH4SGVnvspzKcxrxo9kn1L4
|
|
38
38
|
winipedia_utils/projects/poetry/__init__.py,sha256=0yNMuu9KmM19od4VBxBV3HLK-RdCsa0e2Zhg33J7RmQ,60
|
39
39
|
winipedia_utils/projects/poetry/config.py,sha256=eEAU-9_uCEeOYx2lTAfydmH3D_YYTx6nOJ204q38BVY,2971
|
40
40
|
winipedia_utils/projects/poetry/poetry.py,sha256=5jyUSMxhCZ7pz9bOaz5E9r7Da9qIrGOp6wcBzI1y7Cg,932
|
41
|
-
winipedia_utils/
|
41
|
+
winipedia_utils/projects/project.py,sha256=GRprpzhasBtV9OtPhQE2HxeufOzcJgbaCZbrW34YnnE,691
|
42
|
+
winipedia_utils/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
43
|
+
winipedia_utils/setup.py,sha256=6zOT-5kXqpADg6wYf-S4ghEY38No_LDQL0YaIRQCFJ0,1560
|
42
44
|
winipedia_utils/testing/__init__.py,sha256=kXhB5xw02ec5xpcW_KV--9CBKdyCjnuR-NZzAJ5tq0g,51
|
43
45
|
winipedia_utils/testing/assertions.py,sha256=0JF4mqVTnLQ1qkAL_FuTwyN_idr00rvVlta7aDdnUXA,851
|
44
46
|
winipedia_utils/testing/convention.py,sha256=NxC_hYaUXshsa6LL6nQoEEKpTzC1KwTloKL8aS2gUPI,5010
|
45
|
-
winipedia_utils/testing/create_tests.py,sha256=
|
47
|
+
winipedia_utils/testing/create_tests.py,sha256=pfjPBFWw0yFd8x0LG5Ym8ohFgjOJ34O0HAGoowKJpcY,9820
|
46
48
|
winipedia_utils/testing/fixtures.py,sha256=e0ax1n1zqzmLawA26k0EtNa3rYSMu10lMNVRjBuIGMs,1061
|
47
49
|
winipedia_utils/testing/tests/__init__.py,sha256=kL-1O6lAO5j4JPOqPdi3dHdbOQ_UXcgPFppj82HhrRU,57
|
48
50
|
winipedia_utils/testing/tests/base/__init__.py,sha256=dBH1yfONmqUC49zshS6BJ4ZgEcw7iFGoFCqRmU7Vhrw,62
|
@@ -53,13 +55,13 @@ winipedia_utils/testing/tests/base/fixtures/scopes/class_.py,sha256=XCx4HZeHbJJ-
|
|
53
55
|
winipedia_utils/testing/tests/base/fixtures/scopes/function.py,sha256=5dW7-IPqJ_3Q2j1vftZL5FYKvNSKufqiHzLTTWYhja4,309
|
54
56
|
winipedia_utils/testing/tests/base/fixtures/scopes/module.py,sha256=V0H9WFrdSV7uj__bXM_GKcCJnjResqI7fFjcxyvNaZk,1169
|
55
57
|
winipedia_utils/testing/tests/base/fixtures/scopes/package.py,sha256=IKOfj6vfyjEQdRV5cJoPRQvALmePpGxWkGy23di00-w,309
|
56
|
-
winipedia_utils/testing/tests/base/fixtures/scopes/session.py,sha256=
|
58
|
+
winipedia_utils/testing/tests/base/fixtures/scopes/session.py,sha256=Wdesvis8BleXjm93jK99JLX4u9Oy2dY0GIx_3ipXYXo,9624
|
57
59
|
winipedia_utils/testing/tests/base/utils/__init__.py,sha256=mC-8dCkp8xarqkQu2QQLrPjHi6Ww9hcixWdHeQHWeRs,68
|
58
60
|
winipedia_utils/testing/tests/base/utils/utils.py,sha256=dUPDrgAxlfREQb33zz23MfzacLLuwjy2AO-PQQp_aSI,2820
|
59
61
|
winipedia_utils/testing/tests/conftest.py,sha256=CvLtsr-KhSPzbQYin6SYZQC1Ez3AzIsqCWhuLuXinAs,826
|
60
62
|
winipedia_utils/text/__init__.py,sha256=j2bwtK6kyeHI6SnoBjpRju0C1W2n2paXBDlNjNtaUxA,48
|
61
63
|
winipedia_utils/text/string.py,sha256=1jbBftlgxffGgSlPnQh3aRPIr8XekEwpSenjFCW6JyM,3478
|
62
|
-
winipedia_utils-0.1.
|
63
|
-
winipedia_utils-0.1.
|
64
|
-
winipedia_utils-0.1.
|
65
|
-
winipedia_utils-0.1.
|
64
|
+
winipedia_utils-0.1.4.dist-info/LICENSE,sha256=3PrKJ2CWNrnyyHaC_r0wPDSukVWgmjOxHr__eQVH7cw,1087
|
65
|
+
winipedia_utils-0.1.4.dist-info/METADATA,sha256=rIJjj27ZrZ5S0jkXaQPzau4lD3Vx-xKKpST4Y_DPt6A,12384
|
66
|
+
winipedia_utils-0.1.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
67
|
+
winipedia_utils-0.1.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|