pytest-regtest 2.2.0a2__py2.py3-none-any.whl → 2.2.1__py2.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.
- pytest_regtest/__init__.py +38 -6
- pytest_regtest/numpy_handler.py +13 -0
- pytest_regtest/pytest_regtest.py +285 -194
- pytest_regtest/register_third_party_handlers.py +6 -22
- pytest_regtest/snapshot_handler.py +130 -20
- pytest_regtest-2.2.1.dist-info/METADATA +90 -0
- pytest_regtest-2.2.1.dist-info/RECORD +12 -0
- pytest_regtest-2.2.0a2.dist-info/METADATA +0 -356
- pytest_regtest-2.2.0a2.dist-info/RECORD +0 -12
- {pytest_regtest-2.2.0a2.dist-info → pytest_regtest-2.2.1.dist-info}/WHEEL +0 -0
- {pytest_regtest-2.2.0a2.dist-info → pytest_regtest-2.2.1.dist-info}/entry_points.txt +0 -0
- {pytest_regtest-2.2.0a2.dist-info → pytest_regtest-2.2.1.dist-info}/licenses/LICENSE.txt +0 -0
pytest_regtest/__init__.py
CHANGED
|
@@ -2,13 +2,22 @@ from importlib.metadata import version as _version
|
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
|
-
from . import register_third_party_handlers # noqa: F401
|
|
6
|
-
from .pytest_regtest import PytestRegtestPlugin # noqa: F401
|
|
7
|
-
from .pytest_regtest import RegtestStream # noqa: F401
|
|
8
5
|
from .pytest_regtest import clear_converters # noqa: F401
|
|
9
6
|
from .pytest_regtest import patch_terminal_size # noqa: F401
|
|
10
7
|
from .pytest_regtest import register_converter_post # noqa: F401
|
|
11
8
|
from .pytest_regtest import register_converter_pre # noqa: F401
|
|
9
|
+
from .pytest_regtest import (
|
|
10
|
+
PytestRegtestCommonHooks,
|
|
11
|
+
PytestRegtestPlugin,
|
|
12
|
+
RegtestStream,
|
|
13
|
+
Snapshot,
|
|
14
|
+
SnapshotPlugin,
|
|
15
|
+
)
|
|
16
|
+
from .register_third_party_handlers import (
|
|
17
|
+
register_numpy_handler,
|
|
18
|
+
register_pandas_handler,
|
|
19
|
+
)
|
|
20
|
+
from .snapshot_handler import register_python_object_handler
|
|
12
21
|
|
|
13
22
|
__version__ = _version(__package__)
|
|
14
23
|
|
|
@@ -43,12 +52,17 @@ def pytest_addoption(parser):
|
|
|
43
52
|
"--regtest-disable-stdconv",
|
|
44
53
|
action="store_true",
|
|
45
54
|
default=False,
|
|
46
|
-
help=
|
|
55
|
+
help=(
|
|
56
|
+
"do not apply standard output converters to clean up indeterministic output"
|
|
57
|
+
),
|
|
47
58
|
)
|
|
48
59
|
|
|
49
60
|
|
|
50
61
|
def pytest_configure(config):
|
|
51
|
-
|
|
62
|
+
common = PytestRegtestCommonHooks()
|
|
63
|
+
config.pluginmanager.register(common)
|
|
64
|
+
config.pluginmanager.register(PytestRegtestPlugin(common))
|
|
65
|
+
config.pluginmanager.register(SnapshotPlugin(common))
|
|
52
66
|
|
|
53
67
|
|
|
54
68
|
@pytest.fixture
|
|
@@ -56,7 +70,9 @@ def regtest(request):
|
|
|
56
70
|
yield RegtestStream(request)
|
|
57
71
|
|
|
58
72
|
|
|
59
|
-
|
|
73
|
+
@pytest.fixture
|
|
74
|
+
def snapshot(request):
|
|
75
|
+
yield Snapshot(request)
|
|
60
76
|
|
|
61
77
|
|
|
62
78
|
@pytest.fixture
|
|
@@ -65,3 +81,19 @@ def regtest_all(regtest):
|
|
|
65
81
|
|
|
66
82
|
|
|
67
83
|
snapshot_all_output = regtest_all
|
|
84
|
+
|
|
85
|
+
register_python_object_handler()
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
import pandas # noqa: F401
|
|
89
|
+
|
|
90
|
+
register_pandas_handler()
|
|
91
|
+
except ImportError:
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
import numpy # noqa: F401
|
|
96
|
+
|
|
97
|
+
register_numpy_handler()
|
|
98
|
+
except ImportError:
|
|
99
|
+
pass
|
pytest_regtest/numpy_handler.py
CHANGED
|
@@ -148,6 +148,7 @@ class NumpyHandler(BaseSnapshotHandler):
|
|
|
148
148
|
self, current_obj, current_as_text, recorded_obj, recorded_as_text, has_markup
|
|
149
149
|
):
|
|
150
150
|
sub_diff = []
|
|
151
|
+
|
|
151
152
|
for i, (l1, l2, r1, r2) in enumerate(
|
|
152
153
|
zip(current_as_text, recorded_as_text, current_obj, recorded_obj)
|
|
153
154
|
):
|
|
@@ -193,4 +194,16 @@ class NumpyHandler(BaseSnapshotHandler):
|
|
|
193
194
|
sub_diff.append(f"row {i:3d}: {l1}")
|
|
194
195
|
sub_diff.append(f" {l2}")
|
|
195
196
|
|
|
197
|
+
missing = len(current_as_text) - len(recorded_as_text)
|
|
198
|
+
if missing > 0:
|
|
199
|
+
for i, row in enumerate(current_as_text[-missing:], len(recorded_as_text)):
|
|
200
|
+
# remove duplicate brackets
|
|
201
|
+
row = row.rstrip("]") + "]"
|
|
202
|
+
sub_diff.append(f"row {i:3d}: -{row.lstrip()}")
|
|
203
|
+
if missing < 0:
|
|
204
|
+
for i, row in enumerate(recorded_as_text[missing:], len(current_as_text)):
|
|
205
|
+
# remove duplicate brackets
|
|
206
|
+
row = row.rstrip("]") + "]"
|
|
207
|
+
sub_diff.append(f"row {i:3d}: +{row.lstrip()}")
|
|
208
|
+
|
|
196
209
|
return sub_diff
|