plexus-python-common 1.1.91__tar.gz → 1.1.93__tar.gz

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.
Files changed (70) hide show
  1. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/.github/workflows/pr.yml +1 -1
  2. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/.github/workflows/push.yml +1 -1
  3. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/PKG-INFO +2 -2
  4. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/pyproject.toml +3 -2
  5. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/testutils.py +41 -27
  6. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus_python_common.egg-info/PKG-INFO +2 -2
  7. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus_python_common.egg-info/requires.txt +1 -1
  8. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/testutils_test.py +19 -0
  9. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/.editorconfig +0 -0
  10. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/.gitignore +0 -0
  11. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/MANIFEST.in +0 -0
  12. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/README.md +0 -0
  13. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/VERSION +0 -0
  14. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/config/config.cfg +0 -0
  15. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/csvutils/data.csv +0 -0
  16. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/csvutils/data.tsv +0 -0
  17. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.baz/file.bar.baz +0 -0
  18. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.baz/file.foo.bar +0 -0
  19. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.baz/file.foo.baz +0 -0
  20. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
  21. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
  22. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
  23. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
  24. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.foo/file.bar +0 -0
  25. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.foo/file.baz +0 -0
  26. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/resources/unittest/pathutils/dir.foo/file.foo +0 -0
  27. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/setup.cfg +0 -0
  28. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/setup.py +0 -0
  29. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/__init__.py +0 -0
  30. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/__init__.py +0 -0
  31. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/argutils.py +0 -0
  32. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/config.py +0 -0
  33. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/csvutils.py +0 -0
  34. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/dbutils.py +0 -0
  35. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/dtutils.py +0 -0
  36. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/funcutils.py +0 -0
  37. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/iterutils.py +0 -0
  38. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/jsonutils.py +0 -0
  39. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/logger.py +0 -0
  40. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/numutils.py +0 -0
  41. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/pathutils.py +0 -0
  42. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/randutils.py +0 -0
  43. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/retry.py +0 -0
  44. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/span.py +0 -0
  45. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/strutils.py +0 -0
  46. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus/common/utils/typeutils.py +0 -0
  47. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus_python_common.egg-info/SOURCES.txt +0 -0
  48. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus_python_common.egg-info/dependency_links.txt +0 -0
  49. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus_python_common.egg-info/not-zip-safe +0 -0
  50. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/src/plexus_python_common.egg-info/top_level.txt +0 -0
  51. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/__init__.py +0 -0
  52. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/__init__.py +0 -0
  53. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/__init__.py +0 -0
  54. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/argutils_test.py +0 -0
  55. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/config_test.py +0 -0
  56. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/csvutils_test.py +0 -0
  57. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/dbutils_test.py +0 -0
  58. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/dtutils_test.py +0 -0
  59. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/funcutils_test.py +0 -0
  60. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/iterutils_test.py +0 -0
  61. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/jsonutils_test.py +0 -0
  62. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/logger_test.py +0 -0
  63. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/numutils_test.py +0 -0
  64. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/pathutils_test.py +0 -0
  65. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/randutils_test.py +0 -0
  66. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/retry_test.py +0 -0
  67. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/span_test.py +0 -0
  68. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/strutils_test.py +0 -0
  69. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/plexus_tests/common/utils/typeutils_test.py +0 -0
  70. {plexus_python_common-1.1.91 → plexus_python_common-1.1.93}/test/testenv.py +0 -0
@@ -9,7 +9,7 @@ env:
9
9
 
10
10
  jobs:
11
11
  build:
12
- runs-on: ubuntu-latest
12
+ runs-on: ubuntu-24.04
13
13
  container:
14
14
  image: ruyangshou/plexus-basedev-ci:latest
15
15
  options: --user github
@@ -9,7 +9,7 @@ env:
9
9
 
10
10
  jobs:
11
11
  push:
12
- runs-on: ubuntu-latest
12
+ runs-on: ubuntu-24.04
13
13
  container:
14
14
  image: ruyangshou/plexus-basedev-ci:latest
15
15
  options: --user github
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plexus-python-common
3
- Version: 1.1.91
3
+ Version: 1.1.93
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.12
6
6
  Classifier: Programming Language :: Python :: 3.13
@@ -20,4 +20,4 @@ Requires-Dist: pytest-cov>=5.0; extra == "test"
20
20
  Requires-Dist: pytest-mysql>=3.0; extra == "test"
21
21
  Requires-Dist: pytest-order>=1.3; extra == "test"
22
22
  Requires-Dist: pytest-postgresql>=6.1; extra == "test"
23
- Requires-Dist: pytest>=8.3; extra == "test"
23
+ Requires-Dist: pytest>=9.2; extra == "test"
@@ -21,7 +21,7 @@ test = [
21
21
  "pytest-mysql>=3.0",
22
22
  "pytest-order>=1.3",
23
23
  "pytest-postgresql>=6.1",
24
- "pytest>=8.3",
24
+ "pytest>=9.2",
25
25
  ]
26
26
 
27
27
  [project]
@@ -53,7 +53,7 @@ test = [
53
53
  "pytest-mysql>=3.0",
54
54
  "pytest-order>=1.3",
55
55
  "pytest-postgresql>=6.1",
56
- "pytest>=8.3",
56
+ "pytest>=9.2",
57
57
  ]
58
58
 
59
59
  [tool.setuptools]
@@ -67,6 +67,7 @@ namespaces = true
67
67
 
68
68
  [tool.pytest.ini_options]
69
69
  pythonpath = ["src"]
70
+ asyncio_default_fixture_loop_scope = "function"
70
71
 
71
72
  [tool.coverage.run]
72
73
  branch = true
@@ -4,7 +4,7 @@ from decimal import Decimal
4
4
  from typing import Any, Protocol
5
5
 
6
6
  import pytest
7
- from _pytest.python_api import ApproxBase, ApproxDecimal, ApproxMapping, ApproxScalar, ApproxSequenceLike
7
+ from _pytest.approx import ApproxDecimal, ApproxMapping, ApproxSequenceLike
8
8
 
9
9
  from plexus.common.utils.numutils import to_decimal
10
10
 
@@ -16,8 +16,14 @@ __all__ = [
16
16
  "throw_callee",
17
17
  ]
18
18
 
19
+ SupportApprox = int | float | str | bool | list | tuple | dict | Decimal | datetime.datetime | datetime.date | datetime.time | datetime.timedelta | None
20
+
21
+
22
+ class ApproxNestedMixin(pytest.Approx):
23
+ def __init__(self, expected, rel: SupportApprox = None, abs: SupportApprox = None, nan_ok: bool = False):
24
+ # Bypass the container constructors, which reject nested values.
25
+ pytest.Approx.__init__(self, expected, rel, abs, nan_ok)
19
26
 
20
- class ApproxNestedMixin(ApproxBase):
21
27
  def __repr__(self) -> str:
22
28
 
23
29
  def recur_repr_helper(obj):
@@ -28,42 +34,50 @@ class ApproxNestedMixin(ApproxBase):
28
34
  elif isinstance(obj, list):
29
35
  return list(recur_repr_helper(o) for o in obj)
30
36
  else:
31
- return self._approx_scalar(obj)
37
+ return nested_approx(obj, self.rel, self.abs, self.nan_ok)
32
38
 
33
39
  return "approx({!r})".format(recur_repr_helper(self.expected))
34
40
 
35
- def _approx_scalar(self, x) -> ApproxScalar:
36
- if isinstance(x, Decimal):
37
- return ApproxDecimal(x, to_decimal(self.rel), to_decimal(self.abs), self.nan_ok)
38
- return ApproxScalar(x, self.rel, self.abs, self.nan_ok)
39
-
40
- def _check_type(self):
41
- pass
42
-
43
41
 
44
42
  class ApproxNestedSequenceLike(ApproxNestedMixin, ApproxSequenceLike):
45
43
 
46
- def _yield_comparisons(self, actual):
47
- for k in range(len(self.expected)):
48
- mapping = nested_approx(self.expected[k], self.rel, self.abs, self.nan_ok)
49
- if isinstance(mapping, ApproxScalar):
50
- yield actual[k], self.expected[k]
51
- else:
52
- yield from mapping._yield_comparisons(actual[k])
44
+ def __eq__(self, actual):
45
+ if not isinstance(actual, (list, tuple)) or len(actual) != len(self.expected):
46
+ return False
47
+ return all(
48
+ value == nested_approx(expected, self.rel, self.abs, self.nan_ok)
49
+ for value, expected in zip(actual, self.expected)
50
+ )
53
51
 
54
52
 
55
53
  class ApproxNestedMapping(ApproxNestedMixin, ApproxMapping):
56
54
 
57
- def _yield_comparisons(self, actual):
58
- for k in self.expected.keys():
59
- mapping = nested_approx(self.expected[k], self.rel, self.abs, self.nan_ok)
60
- if isinstance(mapping, ApproxScalar):
61
- yield actual[k], self.expected[k]
62
- else:
63
- yield from mapping._yield_comparisons(actual[k])
55
+ def __eq__(self, actual):
56
+ if not isinstance(actual, dict) or actual.keys() != self.expected.keys():
57
+ return False
58
+ return all(
59
+ actual[key] == nested_approx(expected, self.rel, self.abs, self.nan_ok)
60
+ for key, expected in self.expected.items()
61
+ )
62
+
63
+
64
+ class ApproxDataTime(pytest.Approx):
65
+
66
+ def __repr__(self) -> str:
67
+ return f"approx({self.expected!r})"
68
+
69
+ def __eq__(self, actual) -> bool:
70
+ return actual == self.expected
64
71
 
65
72
 
66
- def nested_approx(expected, rel: float = None, abs: float = None, nan_ok: bool = False) -> ApproxBase:
73
+ def nested_approx(
74
+ expected,
75
+ rel: SupportApprox = None,
76
+ abs: SupportApprox = None,
77
+ nan_ok: bool = False,
78
+ ) -> pytest.Approx:
79
+ if expected is None or isinstance(expected, str):
80
+ return pytest.approx(expected, nan_ok=nan_ok)
67
81
  if isinstance(expected, dict):
68
82
  return ApproxNestedMapping(expected, rel, abs, nan_ok)
69
83
  if isinstance(expected, (tuple, list)):
@@ -71,7 +85,7 @@ def nested_approx(expected, rel: float = None, abs: float = None, nan_ok: bool =
71
85
  if isinstance(expected, Decimal):
72
86
  return ApproxDecimal(expected, to_decimal(rel), to_decimal(abs), nan_ok)
73
87
  if isinstance(expected, (datetime.datetime, datetime.date, datetime.time, datetime.timedelta)):
74
- return pytest.approx(expected, abs=datetime.timedelta(0))
88
+ return ApproxDataTime(expected, rel, abs, nan_ok)
75
89
  return pytest.approx(expected, rel=rel, abs=abs, nan_ok=nan_ok)
76
90
 
77
91
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plexus-python-common
3
- Version: 1.1.91
3
+ Version: 1.1.93
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.12
6
6
  Classifier: Programming Language :: Python :: 3.13
@@ -20,4 +20,4 @@ Requires-Dist: pytest-cov>=5.0; extra == "test"
20
20
  Requires-Dist: pytest-mysql>=3.0; extra == "test"
21
21
  Requires-Dist: pytest-order>=1.3; extra == "test"
22
22
  Requires-Dist: pytest-postgresql>=6.1; extra == "test"
23
- Requires-Dist: pytest>=8.3; extra == "test"
23
+ Requires-Dist: pytest>=9.2; extra == "test"
@@ -14,4 +14,4 @@ pytest-cov>=5.0
14
14
  pytest-mysql>=3.0
15
15
  pytest-order>=1.3
16
16
  pytest-postgresql>=6.1
17
- pytest>=8.3
17
+ pytest>=9.2
@@ -311,6 +311,25 @@ class TestUtilsTest(unittest.TestCase):
311
311
  assert expect == nested_approx(actual, abs=1.00001e-6)
312
312
  assert actual == nested_approx(expect, abs=1.00001e-6)
313
313
 
314
+ data_nested_approx__structure_mismatch = [
315
+ ([[]], [[1]]),
316
+ ([[1]], [[]]),
317
+ ([[1]], [[1, 2]]),
318
+ ([{}], [{"extra": 1}]),
319
+ ([{"a": 1}], [{}]),
320
+ ([{"a": 1}], [{"b": 1}]),
321
+ ({"nested": []}, {"nested": {}}),
322
+ ({"nested": [1]}, {"nested": None}),
323
+ ({"nested": {"a": 1}}, {"nested": [1]}),
324
+ ]
325
+
326
+ @ddt.idata(data_nested_approx__structure_mismatch)
327
+ @ddt.unpack
328
+ def test_nested_approx__structure_mismatch(self, expect, actual):
329
+ self.assertFalse(actual == nested_approx(expect))
330
+ self.assertFalse(expect == nested_approx(actual))
331
+ self.assertTrue(actual != nested_approx(expect))
332
+
314
333
  def test_return_callee(self):
315
334
  callee = return_callee()
316
335