hunterMakesPy 0.3.2__py3-none-any.whl → 0.3.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.
- hunterMakesPy/__init__.py +3 -14
- hunterMakesPy/dataStructures.py +1 -1
- hunterMakesPy/filesystemToolkit.py +0 -1
- hunterMakesPy/parseParameters.py +13 -24
- hunterMakesPy/pytestForYourUse.py +1 -2
- hunterMakesPy/tests/conftest.py +79 -5
- hunterMakesPy/tests/test_coping.py +258 -153
- hunterMakesPy/tests/test_dataStructures.py +250 -69
- hunterMakesPy/tests/test_filesystemToolkit.py +245 -131
- hunterMakesPy/tests/test_parseParameters.py +63 -7
- hunterMakesPy/tests/test_theTypes.py +420 -0
- hunterMakesPy/theTypes.py +6 -4
- {huntermakespy-0.3.2.dist-info → huntermakespy-0.3.4.dist-info}/METADATA +1 -1
- huntermakespy-0.3.4.dist-info/RECORD +21 -0
- huntermakespy-0.3.2.dist-info/RECORD +0 -20
- {huntermakespy-0.3.2.dist-info → huntermakespy-0.3.4.dist-info}/WHEEL +0 -0
- {huntermakespy-0.3.2.dist-info → huntermakespy-0.3.4.dist-info}/licenses/LICENSE +0 -0
- {huntermakespy-0.3.2.dist-info → huntermakespy-0.3.4.dist-info}/top_level.txt +0 -0
hunterMakesPy/__init__.py
CHANGED
|
@@ -8,26 +8,15 @@ This package provides:
|
|
|
8
8
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
# isort: split
|
|
12
11
|
from hunterMakesPy.theTypes import identifierDotAttribute as identifierDotAttribute, Ordinals as Ordinals
|
|
13
12
|
|
|
14
|
-
# isort: split
|
|
15
13
|
from hunterMakesPy.coping import PackageSettings as PackageSettings, raiseIfNone as raiseIfNone
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
from hunterMakesPy.parseParameters import (
|
|
19
|
-
defineConcurrencyLimit as defineConcurrencyLimit, intInnit as intInnit, oopsieKwargsie as oopsieKwargsie)
|
|
15
|
+
from hunterMakesPy.parseParameters import defineConcurrencyLimit, intInnit, oopsieKwargsie
|
|
20
16
|
|
|
21
|
-
# isort: split
|
|
22
17
|
from hunterMakesPy.filesystemToolkit import (
|
|
23
|
-
importLogicalPath2Identifier
|
|
24
|
-
importPathFilename2Identifier as importPathFilename2Identifier, makeDirsSafely as makeDirsSafely,
|
|
25
|
-
writePython as writePython, writeStringToHere as writeStringToHere)
|
|
18
|
+
importLogicalPath2Identifier, importPathFilename2Identifier, makeDirsSafely, writePython, writeStringToHere)
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
from hunterMakesPy.dataStructures import (
|
|
29
|
-
autoDecodingRLE as autoDecodingRLE, stringItUp as stringItUp,
|
|
30
|
-
updateExtendPolishDictionaryLists as updateExtendPolishDictionaryLists)
|
|
20
|
+
from hunterMakesPy.dataStructures import autoDecodingRLE, stringItUp, updateExtendPolishDictionaryLists
|
|
31
21
|
|
|
32
|
-
# isort: split
|
|
33
22
|
from hunterMakesPy._theSSOT import settingsPackage # pyright: ignore[reportUnusedImport]
|
hunterMakesPy/dataStructures.py
CHANGED
|
@@ -267,7 +267,7 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[str, list[小于
|
|
|
267
267
|
for keyName, keyValue in dictionaryListTarget.items():
|
|
268
268
|
try:
|
|
269
269
|
ImaStr = str(keyName)
|
|
270
|
-
ImaList = list(keyValue)
|
|
270
|
+
ImaList: list[小于] = list(keyValue)
|
|
271
271
|
ePluribusUnum.setdefault(ImaStr, []).extend(ImaList)
|
|
272
272
|
except TypeError:
|
|
273
273
|
if killErroneousDataTypes:
|
hunterMakesPy/parseParameters.py
CHANGED
|
@@ -148,21 +148,18 @@ def defineConcurrencyLimit(*, limit: bool | float | int | None, cpuTotal: int =
|
|
|
148
148
|
limit = limitFromString
|
|
149
149
|
if isinstance(limit, float) and abs(limit) >= 1:
|
|
150
150
|
limit = round(limit)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
concurrencyLimit = cpuTotal - abs(int(limit))
|
|
164
|
-
case _:
|
|
165
|
-
pass
|
|
151
|
+
if limit is None or limit is False or limit == 0:
|
|
152
|
+
pass
|
|
153
|
+
elif limit is True:
|
|
154
|
+
concurrencyLimit = 1
|
|
155
|
+
elif limit >= 1:
|
|
156
|
+
concurrencyLimit = int(limit)
|
|
157
|
+
elif 0 < limit < 1:
|
|
158
|
+
concurrencyLimit = round(limit * cpuTotal)
|
|
159
|
+
elif -1 < limit < 0:
|
|
160
|
+
concurrencyLimit = cpuTotal - abs(round(limit * cpuTotal))
|
|
161
|
+
elif limit <= -1:
|
|
162
|
+
concurrencyLimit = cpuTotal - abs(int(limit))
|
|
166
163
|
|
|
167
164
|
return max(int(concurrencyLimit), 1)
|
|
168
165
|
|
|
@@ -208,7 +205,7 @@ def intInnit(listInt_Allegedly: Iterable[Any], parameterName: str | None = None,
|
|
|
208
205
|
parameterType = parameterType or list
|
|
209
206
|
|
|
210
207
|
if not listInt_Allegedly:
|
|
211
|
-
message = f"I did not receive a value for {parameterName}, but it is required."
|
|
208
|
+
message: str = f"I did not receive a value for {parameterName}, but it is required."
|
|
212
209
|
raise ValueError(message)
|
|
213
210
|
|
|
214
211
|
# Be nice, and assume the input container is valid and every element is valid.
|
|
@@ -319,11 +316,3 @@ def oopsieKwargsie(huh: Any) -> bool | None | str:
|
|
|
319
316
|
if formatted == str(None):
|
|
320
317
|
return None
|
|
321
318
|
return huh
|
|
322
|
-
|
|
323
|
-
if __name__ == '__main__':
|
|
324
|
-
# Frankly, I cannot remember the precise reason I put this in some modules. It solved a concurrency problem I was having at the time,
|
|
325
|
-
# but it felt like a hack at the time and it feels even more like a hack now. I suspect I will eventually learn enough so that I can
|
|
326
|
-
# come full circle: know why I added it, know how I already fixed the real issue, and know that I can safely remove this. # noqa: ERA001
|
|
327
|
-
multiprocessing.set_start_method('spawn')
|
|
328
|
-
|
|
329
|
-
# Well, actually, I don't want to be programming for so long that I learn that much. I want to heal and do things in my areas of competency.
|
|
@@ -6,5 +6,4 @@ Note: These test functions are now in `hunterMakesPy.tests` with all other tests
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
from hunterMakesPy.tests.test_parseParameters import (
|
|
9
|
-
PytestFor_defineConcurrencyLimit
|
|
10
|
-
PytestFor_oopsieKwargsie as PytestFor_oopsieKwargsie)
|
|
9
|
+
PytestFor_defineConcurrencyLimit, PytestFor_intInnit, PytestFor_oopsieKwargsie)
|
hunterMakesPy/tests/conftest.py
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
"""Configuration and fixtures for pytest.
|
|
2
|
+
|
|
3
|
+
(AI generated docstring)
|
|
4
|
+
|
|
5
|
+
This module provides shared fixtures and utility functions for the test suite,
|
|
6
|
+
including data paths, source code samples, and standardized assertion helpers.
|
|
7
|
+
|
|
8
|
+
"""
|
|
1
9
|
# pyright: standard
|
|
2
10
|
from collections.abc import Callable
|
|
3
11
|
from typing import Any
|
|
@@ -6,11 +14,26 @@ import pathlib
|
|
|
6
14
|
import pytest
|
|
7
15
|
|
|
8
16
|
# SSOT for test data paths and filenames
|
|
9
|
-
pathDataSamples = pathlib.Path("hunterMakesPy/tests/dataSamples")
|
|
17
|
+
pathDataSamples: pathlib.Path = pathlib.Path("hunterMakesPy/tests/dataSamples")
|
|
10
18
|
|
|
11
19
|
# Fixture to provide a temporary directory for filesystem tests
|
|
12
20
|
@pytest.fixture
|
|
13
21
|
def pathTmpTesting(tmp_path: pathlib.Path) -> pathlib.Path:
|
|
22
|
+
"""Provide a temporary directory for filesystem tests.
|
|
23
|
+
|
|
24
|
+
(AI generated docstring)
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
tmp_path : pathlib.Path
|
|
29
|
+
The pytest built-in temporary path fixture.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
pathTmpTesting : pathlib.Path
|
|
34
|
+
The path to the temporary directory.
|
|
35
|
+
|
|
36
|
+
"""
|
|
14
37
|
return tmp_path
|
|
15
38
|
|
|
16
39
|
# Fixture for predictable Python source code samples
|
|
@@ -44,7 +67,27 @@ def listFileContentsFibonacci() -> list[str]:
|
|
|
44
67
|
return ['fibonacci8', 'fibonacci13', 'fibonacci21', 'fibonacci34']
|
|
45
68
|
|
|
46
69
|
def uniformTestFailureMessage(expected: Any, actual: Any, functionName: str, *arguments: Any, **keywordArguments: Any) -> str:
|
|
47
|
-
"""Format assertion message for any test comparison.
|
|
70
|
+
"""Format assertion message for any test comparison.
|
|
71
|
+
|
|
72
|
+
Parameters
|
|
73
|
+
----------
|
|
74
|
+
expected : Any
|
|
75
|
+
The expected value or outcome.
|
|
76
|
+
actual : Any
|
|
77
|
+
The actual value or outcome received.
|
|
78
|
+
functionName : str
|
|
79
|
+
The name of the function or test case being executed.
|
|
80
|
+
*arguments : Any
|
|
81
|
+
Positional arguments passed to the function having its return value checked.
|
|
82
|
+
**keywordArguments : Any
|
|
83
|
+
Keyword arguments passed to the function having its return value checked.
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
message : str
|
|
88
|
+
A formatted failure message detailing the expectation vs reality.
|
|
89
|
+
|
|
90
|
+
"""
|
|
48
91
|
listArgumentComponents: list[str] = [str(parameter) for parameter in arguments]
|
|
49
92
|
listKeywordComponents: list[str] = [f"{key}={value}" for key, value in keywordArguments.items()]
|
|
50
93
|
joinedArguments: str = ', '.join(listArgumentComponents + listKeywordComponents)
|
|
@@ -54,7 +97,22 @@ def uniformTestFailureMessage(expected: Any, actual: Any, functionName: str, *ar
|
|
|
54
97
|
f"Got: {actual}")
|
|
55
98
|
|
|
56
99
|
def standardizedEqualTo(expected: Any, functionTarget: Callable[..., Any], *arguments: Any, **keywordArguments: Any) -> None:
|
|
57
|
-
"""Template for most tests to compare
|
|
100
|
+
"""Template for most tests to compare actual outcome with expected outcome.
|
|
101
|
+
|
|
102
|
+
Includes handling for expected errors/exceptions.
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
expected : Any
|
|
107
|
+
The expected return value, or an Exception type if an error is expected.
|
|
108
|
+
functionTarget : Callable[..., Any]
|
|
109
|
+
The function to call and test.
|
|
110
|
+
*arguments : Any
|
|
111
|
+
Positional arguments to pass to `functionTarget`.
|
|
112
|
+
**keywordArguments : Any
|
|
113
|
+
Keyword arguments to pass to `functionTarget`.
|
|
114
|
+
|
|
115
|
+
"""
|
|
58
116
|
if type(expected) == type[Exception]: # noqa: E721
|
|
59
117
|
messageExpected: str = expected.__name__
|
|
60
118
|
else:
|
|
@@ -63,7 +121,23 @@ def standardizedEqualTo(expected: Any, functionTarget: Callable[..., Any], *argu
|
|
|
63
121
|
try:
|
|
64
122
|
messageActual = actual = functionTarget(*arguments, **keywordArguments)
|
|
65
123
|
except Exception as actualError:
|
|
66
|
-
messageActual
|
|
124
|
+
messageActual = type(actualError).__name__
|
|
67
125
|
actual = type(actualError)
|
|
68
126
|
|
|
69
|
-
|
|
127
|
+
functionName: str = getattr(functionTarget, "__name__", functionTarget.__class__.__name__)
|
|
128
|
+
assert actual == expected, uniformTestFailureMessage(messageExpected, messageActual, functionName, *arguments, **keywordArguments)
|
|
129
|
+
|
|
130
|
+
# Why I wish I could figure out how to implement standardized* test functions.
|
|
131
|
+
# ruff: noqa: ERA001
|
|
132
|
+
# standardizedEqualTo(expected, updateExtendPolishDictionaryLists, *value_dictionaryLists, **keywordArguments)
|
|
133
|
+
# NOTE one line of code with `standardizedEqualTo` (above) replaced the following ten lines of code. Use `standardizedEqualTo`.
|
|
134
|
+
# if isinstance(expected, type) and issubclass(expected, Exception):
|
|
135
|
+
# with pytest.raises(expected):
|
|
136
|
+
# updateExtendPolishDictionaryLists(*value_dictionaryLists, **keywordArguments)
|
|
137
|
+
# else:
|
|
138
|
+
# result = updateExtendPolishDictionaryLists(*value_dictionaryLists, **keywordArguments)
|
|
139
|
+
# if description == "Set values": # Special handling for unordered sets
|
|
140
|
+
# for key in result:
|
|
141
|
+
# assert sorted(result[key]) == sorted(expected[key])
|
|
142
|
+
# else:
|
|
143
|
+
# assert result == expected
|