pytest-regtest 2.3.3__py3-none-any.whl → 2.3.5__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.
@@ -18,7 +18,6 @@ from .register_third_party_handlers import (
18
18
  register_pandas_handler,
19
19
  register_polars_handler,
20
20
  )
21
-
22
21
  from .snapshot_handler import register_python_object_handler
23
22
 
24
23
  __version__ = _version(__package__)
@@ -145,8 +145,7 @@ class NumpyHandler(BaseSnapshotHandler):
145
145
  " entries"
146
146
  )
147
147
  lines.append(
148
- f"up to given precision settings rtol={self.rtol:e} and"
149
- f" atol={self.atol:e}"
148
+ f"up to given precision settings rtol={self.rtol:e} and atol={self.atol:e}"
150
149
  )
151
150
 
152
151
  return lines
@@ -75,21 +75,16 @@ class DataFrameHandler(BaseSnapshotHandler):
75
75
  def extract(df, selector):
76
76
  return df[[n for (n, t) in zip(df.columns, df.dtypes) if selector(t)]]
77
77
 
78
- current_reduced_floats = extract(
79
- current_reduced, lambda t: t.type is np.float64
80
- ).to_numpy()
78
+ def is_float(t):
79
+ return t.type in (np.float64, np.float32)
81
80
 
82
- current_reduced_other = extract(
83
- current_reduced, lambda t: t.type is not np.float64
84
- )
81
+ current_reduced_floats = extract(current_reduced, is_float).to_numpy()
85
82
 
86
- recorded_reduced_floats = extract(
87
- recorded_reduced, lambda t: t.type is np.float64
88
- ).to_numpy()
83
+ current_reduced_other = extract(current_reduced, lambda t: not is_float(t))
89
84
 
90
- recorded_reduced_other = extract(
91
- recorded_reduced, lambda t: t.type is not np.float64
92
- )
85
+ recorded_reduced_floats = extract(recorded_reduced, is_float).to_numpy()
86
+
87
+ recorded_reduced_other = extract(recorded_reduced, lambda t: not is_float(t))
93
88
 
94
89
  return np.allclose(
95
90
  current_reduced_floats,
@@ -97,7 +92,7 @@ class DataFrameHandler(BaseSnapshotHandler):
97
92
  atol=self.atol,
98
93
  rtol=self.rtol,
99
94
  equal_nan=True,
100
- ) and (current_reduced_other == recorded_reduced_other).all(axis=None)
95
+ ) and current_reduced_other.equals(recorded_reduced_other)
101
96
 
102
97
  def show_differences(self, current, recorded, has_markup):
103
98
  lines = []
@@ -108,10 +108,6 @@ class PytestRegtestPlugin:
108
108
  if output_exception is not None:
109
109
  raise output_exception
110
110
 
111
- if item.get_closest_marker("xfail") and item.config.getvalue("--regtest-reset"):
112
- # enforce consistency with xfail:
113
- assert False
114
-
115
111
  def check_recorded_output(self, item):
116
112
  test_folder = item.fspath.dirname
117
113
  regtest_stream = item.regtest_stream
@@ -127,6 +123,14 @@ class PytestRegtestPlugin:
127
123
  consider_line_endings = config.getvalue("--regtest-consider-line-endings")
128
124
  reset = config.getvalue("--regtest-reset")
129
125
 
126
+ # Skip reset for xfail tests that are actually expected to fail
127
+ xfail_marker = item.get_closest_marker("xfail")
128
+ if xfail_marker:
129
+ # Check if xfail condition evaluates to True
130
+ condition = xfail_marker.kwargs.get("condition", True)
131
+ if condition is True or (condition is not False and condition):
132
+ reset = False
133
+
130
134
  if reset:
131
135
  os.makedirs(os.path.dirname(recorded_output_path), exist_ok=True)
132
136
  with open(recorded_output_path + ".out", "w", encoding="utf-8") as fh:
@@ -252,10 +256,6 @@ class SnapshotPlugin:
252
256
  if snapshot_exception is not None:
253
257
  raise snapshot_exception
254
258
 
255
- if item.get_closest_marker("xfail") and item.config.getvalue("--regtest-reset"):
256
- # enforce fail
257
- assert False
258
-
259
259
  def check_snapshots(self, item):
260
260
  results = []
261
261
 
@@ -287,6 +287,14 @@ class SnapshotPlugin:
287
287
 
288
288
  reset = config.getvalue("--regtest-reset")
289
289
 
290
+ # Skip reset for xfail tests that are actually expected to fail
291
+ xfail_marker = item.get_closest_marker("xfail")
292
+ if xfail_marker:
293
+ # Check if xfail condition evaluates to True
294
+ condition = xfail_marker.kwargs.get("condition", True)
295
+ if condition is True or (condition is not False and condition):
296
+ reset = False
297
+
290
298
  if reset:
291
299
  os.makedirs(recorded_output_path, exist_ok=True)
292
300
  handler.save(recorded_output_path, obj)
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pytest-regtest
3
- Version: 2.3.3
3
+ Version: 2.3.5
4
4
  Summary: pytest plugin for snapshot regression testing
5
5
  Author-email: Uwe Schmitt <uwe.schmitt@id.ethz.ch>
6
- License: MIT License
6
+ License-Expression: MIT
7
7
  Project-URL: Source, https://gitlab.com/uweschmitt/pytest-regtest
8
8
  Project-URL: Documentation, https://pytest-regtest.readthedocs.org
9
9
  Classifier: Intended Audience :: Developers
@@ -11,10 +11,10 @@ Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
- Classifier: License :: OSI Approved :: MIT License
15
14
  Description-Content-Type: text/markdown
16
15
  License-File: LICENSE.txt
17
- Requires-Dist: pytest >7.2
16
+ Requires-Dist: pytest>7.2
17
+ Dynamic: license-file
18
18
 
19
19
  ![](https://gitlab.com/uweschmitt/pytest-regtest/badges/main/pipeline.svg)
20
20
  ![](https://gitlab.com/uweschmitt/pytest-regtest/badges/main/coverage.svg?job=coverage)
@@ -0,0 +1,14 @@
1
+ pytest_regtest/__init__.py,sha256=GiURR8QAsu7GAVtbBEnwr1nNIcemLlcX7H5APQCb1ok,2535
2
+ pytest_regtest/numpy_handler.py,sha256=iuCN4fPr8ldEPeS5henmfmGg7nhFDjLMisgwotpm5rA,7157
3
+ pytest_regtest/pandas_handler.py,sha256=iDo5i5nSAYVWlOAps3pB3cbJmRvq1gHsWBF5y8f2M2c,4446
4
+ pytest_regtest/polars_handler.py,sha256=G25GmzZo95MzHoehvKXiv-SV8TkKA4TnLEqQ-nZa3d8,3796
5
+ pytest_regtest/pytest_regtest.py,sha256=c6k2NV-yWOecf4AjGgP1k_1oNXf5XD65aqqLYmRB5R8,22897
6
+ pytest_regtest/register_third_party_handlers.py,sha256=mfmcyeMKuxFykkKLO7T1Tz5RPitn1pKLYRM7B9lA1Kg,1132
7
+ pytest_regtest/snapshot_handler.py,sha256=MbWpNYOSkhQRs6U0qLT1kz5CV6JCay26yHntju8h9uU,6046
8
+ pytest_regtest/utils.py,sha256=2jYTlV_qL5hH6FCeg7T1HJJvKual-Kux2scJ9_aB1lY,811
9
+ pytest_regtest-2.3.5.dist-info/licenses/LICENSE.txt,sha256=Tue36uAzpW79-9WAqzkwPhsDDVd1X-VWUmdZ0MfGYvk,1068
10
+ pytest_regtest-2.3.5.dist-info/METADATA,sha256=iMW7--UXXOHC0LILMuzLpF1BK3kCxph0rOkEUHRnS3U,3249
11
+ pytest_regtest-2.3.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ pytest_regtest-2.3.5.dist-info/entry_points.txt,sha256=4VuIhXeMGhDo0ATbaUfyjND0atofmZjV_P-o6_uEk2s,36
13
+ pytest_regtest-2.3.5.dist-info/top_level.txt,sha256=vnqUV6AhbIRzZqEfkFhZBBSMoo-tvRkYGeo4KKida1U,15
14
+ pytest_regtest-2.3.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.4.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,14 +0,0 @@
1
- pytest_regtest/__init__.py,sha256=q3wEEi3ZZXaN5CXc0jKCeupbAl73t64Fz1pFNcYYPYo,2536
2
- pytest_regtest/numpy_handler.py,sha256=hKrVY9dId-45rUR_83w9jbUWgUhd0ABk8uLbOhgm0IM,7173
3
- pytest_regtest/pandas_handler.py,sha256=7vKaHyODcKMltgn9MbbbL1FsOBQK994dEY5fVlDoQ1g,4528
4
- pytest_regtest/polars_handler.py,sha256=G25GmzZo95MzHoehvKXiv-SV8TkKA4TnLEqQ-nZa3d8,3796
5
- pytest_regtest/pytest_regtest.py,sha256=anNCLTTRwe5dy7i_kcrLzeaiP1CskLDevn9FxYdAMJ4,22432
6
- pytest_regtest/register_third_party_handlers.py,sha256=mfmcyeMKuxFykkKLO7T1Tz5RPitn1pKLYRM7B9lA1Kg,1132
7
- pytest_regtest/snapshot_handler.py,sha256=MbWpNYOSkhQRs6U0qLT1kz5CV6JCay26yHntju8h9uU,6046
8
- pytest_regtest/utils.py,sha256=2jYTlV_qL5hH6FCeg7T1HJJvKual-Kux2scJ9_aB1lY,811
9
- pytest_regtest-2.3.3.dist-info/LICENSE.txt,sha256=Tue36uAzpW79-9WAqzkwPhsDDVd1X-VWUmdZ0MfGYvk,1068
10
- pytest_regtest-2.3.3.dist-info/METADATA,sha256=JWpJlvyy6SttnRPRePup4ySvc4MZS92LjuPDwWC8aCc,3276
11
- pytest_regtest-2.3.3.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
12
- pytest_regtest-2.3.3.dist-info/entry_points.txt,sha256=4VuIhXeMGhDo0ATbaUfyjND0atofmZjV_P-o6_uEk2s,36
13
- pytest_regtest-2.3.3.dist-info/top_level.txt,sha256=vnqUV6AhbIRzZqEfkFhZBBSMoo-tvRkYGeo4KKida1U,15
14
- pytest_regtest-2.3.3.dist-info/RECORD,,