dycw-utilities 0.166.20__py3-none-any.whl → 0.166.22__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.166.20
3
+ Version: 0.166.22
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -12,9 +12,9 @@ Provides-Extra: logging
12
12
  Requires-Dist: coloredlogs<15.1,>=15.0.1; extra == 'logging'
13
13
  Provides-Extra: test
14
14
  Requires-Dist: dycw-pytest-only<2.2,>=2.1.1; extra == 'test'
15
- Requires-Dist: hypothesis<6.139,>=6.138.13; extra == 'test'
15
+ Requires-Dist: hypothesis<6.139,>=6.138.15; extra == 'test'
16
16
  Requires-Dist: pytest-asyncio<1.2,>=1.1.0; extra == 'test'
17
- Requires-Dist: pytest-cov<6.3,>=6.2.1; extra == 'test'
17
+ Requires-Dist: pytest-cov<6.4,>=6.3.0; extra == 'test'
18
18
  Requires-Dist: pytest-instafail<0.6,>=0.5.0; extra == 'test'
19
19
  Requires-Dist: pytest-lazy-fixtures<1.4,>=1.3.4; extra == 'test'
20
20
  Requires-Dist: pytest-randomly<3.17,>=3.16.0; extra == 'test'
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=wFLNw_MUiq5E5vrdStiHh7DVtvzDz9og48O0o8oqaew,61
1
+ utilities/__init__.py,sha256=kLzJ-NA_uNwiMfxxQz3R_tLImGxgR8aWcVnZVygffUU,61
2
2
  utilities/aeventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
3
3
  utilities/altair.py,sha256=nHdpWt8ZwdUwRQN970MvHd5bRWokNqzHcZQEdSHKRuE,9033
4
4
  utilities/asyncio.py,sha256=PUedzQ5deqlSECQ33sam9cRzI9TnygHz3FdOqWJWPTM,15288
@@ -56,7 +56,7 @@ utilities/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  utilities/pydantic_settings.py,sha256=bFr9UDrVhdqTl7O_TPutCLdsQ5rUp--nO76-_F8z0bs,5102
57
57
  utilities/pydantic_settings_sops.py,sha256=m2uB9wDw1PU2CiSL7KwxulDXT0STjOZTu3Ctc2q7jc0,1943
58
58
  utilities/pyinstrument.py,sha256=hnXaL-4HE7wWBI5JKaPfYTpsrXe68YiuZKahHV0VJn8,841
59
- utilities/pytest.py,sha256=Pu8jmeNQq659uQmZsmFj6lb0sHMDsNN3fcd6M21J-ww,7723
59
+ utilities/pytest.py,sha256=pl4j9-GReiYQMZkAFOGxsHIO_DcTHbJ_VaiLPFrw57g,8370
60
60
  utilities/pytest_regressions.py,sha256=ocjHTtfOeiGfQAKIei8pKNd61sxN9dawrJJ9gPt2wzA,4097
61
61
  utilities/random.py,sha256=hZlH4gnAtoaofWswuJYjcygejrY8db4CzP-z_adO2Mo,4165
62
62
  utilities/re.py,sha256=S4h-DLL6ScMPqjboZ_uQ1BVTJajrqV06r_81D--_HCE,4573
@@ -90,9 +90,9 @@ utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
90
90
  utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
91
91
  utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
92
92
  utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
93
- utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
94
- dycw_utilities-0.166.20.dist-info/METADATA,sha256=3JiFhAm75CwYgZNGBSHz8eGLiY7oUcWdnCiu_T_6XqI,1702
95
- dycw_utilities-0.166.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
96
- dycw_utilities-0.166.20.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
97
- dycw_utilities-0.166.20.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
98
- dycw_utilities-0.166.20.dist-info/RECORD,,
93
+ utilities/pytest_plugins/pytest_regressions.py,sha256=mnHYBfdprz50UGVkVzV1bZERZN5CFfoF8YbokGxdFwU,1639
94
+ dycw_utilities-0.166.22.dist-info/METADATA,sha256=kUpn9xV_7K4nYDjf_e2TuE3Y_6L7pPrXUPEnwkxJ0ZY,1702
95
+ dycw_utilities-0.166.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
96
+ dycw_utilities-0.166.22.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
97
+ dycw_utilities-0.166.22.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
98
+ dycw_utilities-0.166.22.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.166.20"
3
+ __version__ = "0.166.22"
utilities/pytest.py CHANGED
@@ -13,7 +13,13 @@ from utilities.atomicwrites import writer
13
13
  from utilities.functools import cache
14
14
  from utilities.hashlib import md5_hash
15
15
  from utilities.os import get_env_var
16
- from utilities.pathlib import ensure_suffix, get_root, get_tail, module_path
16
+ from utilities.pathlib import (
17
+ _GetTailEmptyError,
18
+ ensure_suffix,
19
+ get_root,
20
+ get_tail,
21
+ module_path,
22
+ )
17
23
  from utilities.platform import (
18
24
  IS_LINUX,
19
25
  IS_MAC,
@@ -118,10 +124,15 @@ def node_id_path(
118
124
  path_file, *parts = node_id.split("::")
119
125
  path_file = Path(path_file)
120
126
  if path_file.suffix != ".py":
121
- raise NodeIdToPathError(node_id=node_id)
127
+ raise _NodeIdToPathNotPythonFileError(node_id=node_id)
122
128
  path = path_file.with_suffix("")
123
129
  if root is not None:
124
- path = get_tail(path, root)
130
+ try:
131
+ path = get_tail(path, root)
132
+ except _GetTailEmptyError as error:
133
+ raise _NodeIdToPathNotGetTailError(
134
+ node_id=node_id, path=error.path, root=error.root
135
+ ) from None
125
136
  path = Path(module_path(path), "__".join(parts))
126
137
  if suffix is not None:
127
138
  path = ensure_suffix(path, suffix)
@@ -132,11 +143,26 @@ def node_id_path(
132
143
  class NodeIdToPathError(Exception):
133
144
  node_id: str
134
145
 
146
+
147
+ @dataclass(kw_only=True, slots=True)
148
+ class _NodeIdToPathNotPythonFileError(NodeIdToPathError):
135
149
  @override
136
150
  def __str__(self) -> str:
137
151
  return f"Node ID must be a Python file; got {self.node_id!r}"
138
152
 
139
153
 
154
+ @dataclass(kw_only=True, slots=True)
155
+ class _NodeIdToPathNotGetTailError(NodeIdToPathError):
156
+ path: PathLike
157
+ root: PathLike
158
+
159
+ @override
160
+ def __str__(self) -> str:
161
+ return (
162
+ f"Unable to get the tail of {str(self.path)!r} with root {str(self.root)!r}"
163
+ )
164
+
165
+
140
166
  ##
141
167
 
142
168
 
@@ -41,11 +41,15 @@ else:
41
41
 
42
42
  def _get_path(request: FixtureRequest, /) -> Path:
43
43
  from utilities.pathlib import get_root
44
- from utilities.pytest import node_id_path
44
+ from utilities.pytest import _NodeIdToPathNotGetTailError, node_id_path
45
45
 
46
46
  path = Path(cast("Any", request).fspath)
47
47
  root = Path("src", "tests")
48
- tail = node_id_path(request.node.nodeid, root=root)
48
+ try:
49
+ tail = node_id_path(request.node.nodeid, root=root)
50
+ except _NodeIdToPathNotGetTailError:
51
+ root = Path("tests")
52
+ tail = node_id_path(request.node.nodeid, root=root)
49
53
  return get_root(path).joinpath(root, "regressions", tail)
50
54
 
51
55