pytest-arraydiff 0.6.0__py3-none-any.whl → 0.7.0__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.
@@ -43,7 +43,7 @@ abstractstaticmethod = abc.abstractstaticmethod
43
43
  abstractclassmethod = abc.abstractclassmethod
44
44
 
45
45
 
46
- class BaseDiff(object, metaclass=abc.ABCMeta):
46
+ class BaseDiff(metaclass=abc.ABCMeta):
47
47
 
48
48
  @abstractstaticmethod
49
49
  def read(filename):
@@ -83,8 +83,8 @@ class SimpleArrayDiff(BaseDiff):
83
83
  try:
84
84
  np.testing.assert_allclose(array_ref, array_new, atol=atol, rtol=rtol)
85
85
  except AssertionError as exc:
86
- message = "\n\na: {0}".format(test_file) + '\n'
87
- message += "b: {0}".format(reference_file) + '\n'
86
+ message = f"\n\na: {test_file}" + '\n'
87
+ message += f"b: {reference_file}" + '\n'
88
88
  message += exc.args[0]
89
89
  return False, message
90
90
  else:
@@ -160,8 +160,8 @@ class PDHDFDiff(BaseDiff):
160
160
  try:
161
161
  pdt.assert_frame_equal(ref_data, test_data)
162
162
  except AssertionError as exc:
163
- message = "\n\na: {0}".format(test_file) + '\n'
164
- message += "b: {0}".format(reference_file) + '\n'
163
+ message = f"\n\na: {test_file}" + '\n'
164
+ message += f"b: {reference_file}" + '\n'
165
165
  message += exc.args[0]
166
166
  return False, message
167
167
  else:
@@ -240,18 +240,24 @@ def wrap_array_interceptor(plugin, item):
240
240
  # Only intercept array on marked array tests
241
241
  if item.get_closest_marker('array_compare') is not None:
242
242
 
243
+ # Guard against wrapping more than once (e.g. when pytest-run-parallel
244
+ # runs the same item multiple times).
245
+ if getattr(item.obj, '_arraydiff_wrapped', False):
246
+ return
247
+
243
248
  # Use the full test name as a key to ensure correct array is being retrieved
244
249
  test_name = generate_test_name(item)
245
250
 
246
251
  def array_interceptor(store, obj):
247
252
  def wrapper(*args, **kwargs):
248
253
  store.return_value[test_name] = obj(*args, **kwargs)
254
+ wrapper._arraydiff_wrapped = True
249
255
  return wrapper
250
256
 
251
257
  item.obj = array_interceptor(plugin, item.obj)
252
258
 
253
259
 
254
- class ArrayComparison(object):
260
+ class ArrayComparison:
255
261
 
256
262
  def __init__(self, config, reference_dir=None, generate_dir=None, default_format='text'):
257
263
  self.config = config
@@ -260,6 +266,10 @@ class ArrayComparison(object):
260
266
  self.default_format = default_format
261
267
  self.return_value = {}
262
268
 
269
+ def pytest_collection_modifyitems(self, items):
270
+ for item in items:
271
+ wrap_array_interceptor(self, item)
272
+
263
273
  @pytest.hookimpl(hookwrapper=True)
264
274
  def pytest_runtest_call(self, item):
265
275
 
@@ -272,7 +282,7 @@ class ArrayComparison(object):
272
282
  file_format = compare.kwargs.get('file_format', self.default_format)
273
283
 
274
284
  if file_format not in FORMATS:
275
- raise ValueError("Unknown format: {0}".format(file_format))
285
+ raise ValueError(f"Unknown format: {file_format}")
276
286
 
277
287
  if 'extension' in compare.kwargs:
278
288
  extension = compare.kwargs['extension']
@@ -298,8 +308,6 @@ class ArrayComparison(object):
298
308
 
299
309
  baseline_remote = reference_dir.startswith('http')
300
310
 
301
- # Run test and get array object
302
- wrap_array_interceptor(self, item)
303
311
  yield
304
312
  test_name = generate_test_name(item)
305
313
  if test_name not in self.return_value:
@@ -310,8 +318,10 @@ class ArrayComparison(object):
310
318
  # Find test name to use as plot name
311
319
  filename = compare.kwargs.get('filename', None)
312
320
  if filename is None:
313
- filename = item.name + '.' + extension
314
- if not single_reference:
321
+ if single_reference:
322
+ filename = item.originalname + '.' + extension
323
+ else:
324
+ filename = item.name + '.' + extension
315
325
  filename = filename.replace('[', '_').replace(']', '_')
316
326
  filename = filename.replace('_.' + extension, '.' + extension)
317
327
 
@@ -370,11 +380,6 @@ class ArrayInterceptor:
370
380
  self.config = config
371
381
  self.return_value = {}
372
382
 
373
- @pytest.hookimpl(hookwrapper=True)
374
- def pytest_runtest_call(self, item):
375
-
376
- if item.get_closest_marker('array_compare') is not None:
383
+ def pytest_collection_modifyitems(self, items):
384
+ for item in items:
377
385
  wrap_array_interceptor(self, item)
378
-
379
- yield
380
- return
@@ -1,16 +1,34 @@
1
- # file generated by setuptools_scm
1
+ # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
3
13
  TYPE_CHECKING = False
4
14
  if TYPE_CHECKING:
5
- from typing import Tuple, Union
15
+ from typing import Tuple
16
+ from typing import Union
17
+
6
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
7
20
  else:
8
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
9
23
 
10
24
  version: str
11
25
  __version__: str
12
26
  __version_tuple__: VERSION_TUPLE
13
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.7.0'
32
+ __version_tuple__ = version_tuple = (0, 7, 0)
14
33
 
15
- __version__ = version = '0.6.0'
16
- __version_tuple__ = version_tuple = (0, 6, 0)
34
+ __commit_id__ = commit_id = 'gfa97f5625'
@@ -1,37 +1,37 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pytest-arraydiff
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: pytest plugin to help with comparing array output from tests
5
5
  Home-page: https://github.com/astropy/pytest-arraydiff
6
6
  Author: The Astropy Developers
7
7
  Author-email: astropy.team@gmail.com
8
- License: BSD
8
+ License: BSD-3-Clause
9
9
  Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Framework :: Pytest
11
11
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: BSD License
13
12
  Classifier: Operating System :: OS Independent
14
13
  Classifier: Programming Language :: Python
15
14
  Classifier: Programming Language :: Python :: 3
16
15
  Classifier: Programming Language :: Python :: 3 :: Only
17
- Classifier: Programming Language :: Python :: 3.7
18
- Classifier: Programming Language :: Python :: 3.8
19
16
  Classifier: Programming Language :: Python :: 3.9
20
17
  Classifier: Programming Language :: Python :: 3.10
21
18
  Classifier: Programming Language :: Python :: 3.11
22
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
23
21
  Classifier: Programming Language :: Python :: Implementation :: CPython
24
22
  Classifier: Topic :: Software Development :: Testing
25
23
  Classifier: Topic :: Utilities
26
- Requires-Python: >=3.7
24
+ Requires-Python: >=3.9
27
25
  Description-Content-Type: text/x-rst
28
26
  License-File: LICENSE
29
- Requires-Dist: pytest >=4.6
27
+ Requires-Dist: pytest>=6.2
30
28
  Requires-Dist: numpy
31
29
  Provides-Extra: test
32
- Requires-Dist: astropy ; extra == 'test'
33
- Requires-Dist: pandas ; extra == 'test'
34
- Requires-Dist: tables ; extra == 'test'
30
+ Requires-Dist: astropy; extra == "test"
31
+ Requires-Dist: pandas; extra == "test"
32
+ Provides-Extra: test-hdf5
33
+ Requires-Dist: tables; platform_machine != "arm64" and extra == "test-hdf5"
34
+ Dynamic: license-file
35
35
 
36
36
  .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.5811772.svg
37
37
  :target: https://doi.org/10.5281/zenodo.5811772
@@ -41,6 +41,10 @@ Requires-Dist: tables ; extra == 'test'
41
41
  :target: https://github.com/astropy/pytest-arraydiff/actions
42
42
  :alt: CI Status
43
43
 
44
+ .. image:: https://img.shields.io/pypi/v/pytest-arraydiff.svg
45
+ :target: https://pypi.org/project/pytest-arraydiff
46
+ :alt: PyPI Status
47
+
44
48
  About
45
49
  -----
46
50
 
@@ -0,0 +1,9 @@
1
+ pytest_arraydiff/__init__.py,sha256=ICVlMfJSyUfBfTrbT0iaRCQuzdTOdpNCGyxVOwgxXzQ,117
2
+ pytest_arraydiff/plugin.py,sha256=xRBTe_c9tpp-Kxc9B-DuMbYUiKTIhSNWhGx7NJHX-MI,13478
3
+ pytest_arraydiff/version.py,sha256=5yXdxnHKW7crIY91N88sJ7d_GLHu4QN6TQTZj0sr8bE,712
4
+ pytest_arraydiff-0.7.0.dist-info/licenses/LICENSE,sha256=sx9xdEnc-QGbdeT_denLAE1qpXXXIO0qP2TRH-4sKe8,1448
5
+ pytest_arraydiff-0.7.0.dist-info/METADATA,sha256=hXLxmXTKgFpust5iisDJkQQUJacoHWZ3J4WaRuymcWU,8535
6
+ pytest_arraydiff-0.7.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ pytest_arraydiff-0.7.0.dist-info/entry_points.txt,sha256=1mmqAdBTczR-Jj1RtaLXIdnibdhQBqaNCzRSaxhTRpk,54
8
+ pytest_arraydiff-0.7.0.dist-info/top_level.txt,sha256=7fVOoIyJHVuSQkxQKVkfifGCXbQoyqMWSgzmwEBeegQ,17
9
+ pytest_arraydiff-0.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- pytest_arraydiff/__init__.py,sha256=ICVlMfJSyUfBfTrbT0iaRCQuzdTOdpNCGyxVOwgxXzQ,117
2
- pytest_arraydiff/plugin.py,sha256=ikhC5Pchm5WafjWA9LZYYXrcpvd63LXiX4cqh3Tt_tU,13261
3
- pytest_arraydiff/version.py,sha256=2JKwcA-YQ0okV2N-gwTWy_n51igWrPcsKQFm0cnqsvw,411
4
- pytest_arraydiff-0.6.0.dist-info/LICENSE,sha256=sx9xdEnc-QGbdeT_denLAE1qpXXXIO0qP2TRH-4sKe8,1448
5
- pytest_arraydiff-0.6.0.dist-info/METADATA,sha256=0adcJqjMVVKqtLMF-R-xLhMSAW8bY6VKRizZ6DNbPAM,8405
6
- pytest_arraydiff-0.6.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
7
- pytest_arraydiff-0.6.0.dist-info/entry_points.txt,sha256=1mmqAdBTczR-Jj1RtaLXIdnibdhQBqaNCzRSaxhTRpk,54
8
- pytest_arraydiff-0.6.0.dist-info/top_level.txt,sha256=7fVOoIyJHVuSQkxQKVkfifGCXbQoyqMWSgzmwEBeegQ,17
9
- pytest_arraydiff-0.6.0.dist-info/RECORD,,