pytest-regtest 2.0.2__tar.gz → 2.0.3__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.
- {pytest-regtest-2.0.2/pytest_regtest/pytest_regtest.egg-info → pytest-regtest-2.0.3}/PKG-INFO +1 -1
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3/pytest_regtest/pytest_regtest.egg-info}/PKG-INFO +1 -1
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.py +19 -1
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/setup.cfg +1 -1
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/tests/test_plugin.py +81 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/LICENSE.txt +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/MANIFEST.in +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/README.md +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pyproject.toml +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/__init__.py +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/SOURCES.txt +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/dependency_links.txt +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/entry_points.txt +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/not-zip-safe +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/requires.txt +0 -0
- {pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import difflib
|
|
2
|
+
import functools
|
|
3
|
+
import inspect
|
|
2
4
|
import os
|
|
3
5
|
import re
|
|
4
6
|
import sys
|
|
@@ -250,7 +252,7 @@ class RegtestStream:
|
|
|
250
252
|
def write(self, what):
|
|
251
253
|
self.buffer.write(what)
|
|
252
254
|
|
|
253
|
-
def flush(self
|
|
255
|
+
def flush(self):
|
|
254
256
|
pass
|
|
255
257
|
|
|
256
258
|
def get_lines(self):
|
|
@@ -303,13 +305,29 @@ _converters_pre = []
|
|
|
303
305
|
_converters_post = []
|
|
304
306
|
|
|
305
307
|
|
|
308
|
+
def _fix_pre_v2_converter_function(function):
|
|
309
|
+
@functools.wraps(function)
|
|
310
|
+
def fixed_converter_function(output, request):
|
|
311
|
+
return function(output)
|
|
312
|
+
|
|
313
|
+
return fixed_converter_function
|
|
314
|
+
|
|
315
|
+
|
|
306
316
|
def register_converter_pre(function):
|
|
307
317
|
if function not in _converters_pre:
|
|
318
|
+
signature = inspect.signature(function)
|
|
319
|
+
# keep downward compatibility:
|
|
320
|
+
if len(signature.parameters) == 1:
|
|
321
|
+
function = _fix_pre_v2_converter_function(function)
|
|
308
322
|
_converters_pre.append(function)
|
|
309
323
|
|
|
310
324
|
|
|
311
325
|
def register_converter_post(function):
|
|
312
326
|
if function not in _converters_post:
|
|
327
|
+
signature = inspect.signature(function)
|
|
328
|
+
# keep downward compatibility:
|
|
329
|
+
if len(signature.parameters) == 1:
|
|
330
|
+
function = _fix_pre_v2_converter_function(function)
|
|
313
331
|
_converters_post.append(function)
|
|
314
332
|
|
|
315
333
|
|
|
@@ -19,6 +19,7 @@ def create_test_regtest_context_manager(testdir):
|
|
|
19
19
|
print(tempfile.gettempdir())
|
|
20
20
|
print(tempfile.mkdtemp())
|
|
21
21
|
print("obj id is", hex(id(tempfile)))
|
|
22
|
+
regtest.flush()
|
|
22
23
|
|
|
23
24
|
"""
|
|
24
25
|
)
|
|
@@ -39,6 +40,7 @@ def create_test_regtest_fh(testdir):
|
|
|
39
40
|
print(tempfile.gettempdir(), file=regtest)
|
|
40
41
|
print(tempfile.mkdtemp(), file=regtest)
|
|
41
42
|
print("obj id is", hex(id(tempfile)), file=regtest)
|
|
43
|
+
regtest.flush()
|
|
42
44
|
|
|
43
45
|
"""
|
|
44
46
|
)
|
|
@@ -149,6 +151,42 @@ def test_failed_test(testdir):
|
|
|
149
151
|
result.assert_outcomes(failed=1)
|
|
150
152
|
|
|
151
153
|
|
|
154
|
+
def test_converter_pre_pre_v2(testdir):
|
|
155
|
+
testdir.makepyfile(
|
|
156
|
+
"""
|
|
157
|
+
import tempfile
|
|
158
|
+
from pytest_regtest import register_converter_pre
|
|
159
|
+
|
|
160
|
+
@register_converter_pre
|
|
161
|
+
def to_upper_conv(line):
|
|
162
|
+
return line.upper()
|
|
163
|
+
|
|
164
|
+
def test_regtest(regtest_all, tmpdir):
|
|
165
|
+
print("this is expected outcome")
|
|
166
|
+
print("obj id is 0xabcdeffff")
|
|
167
|
+
"""
|
|
168
|
+
)
|
|
169
|
+
result = testdir.runpytest_subprocess()
|
|
170
|
+
result.assert_outcomes(failed=1)
|
|
171
|
+
|
|
172
|
+
expected_diff = """
|
|
173
|
+
> --- is
|
|
174
|
+
> +++ tobe
|
|
175
|
+
> @@ -1,2 +0,0 @@
|
|
176
|
+
> -THIS IS EXPECTED OUTCOME
|
|
177
|
+
> -OBJ ID IS 0XABCDEFFFF
|
|
178
|
+
""".strip().split(
|
|
179
|
+
"\n"
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
result.stdout.fnmatch_lines(
|
|
183
|
+
[line.lstrip() for line in expected_diff], consecutive=True
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
result = testdir.runpytest("--regtest-reset")
|
|
187
|
+
result.assert_outcomes(passed=1)
|
|
188
|
+
|
|
189
|
+
|
|
152
190
|
def test_converter_pre(testdir):
|
|
153
191
|
testdir.makepyfile(
|
|
154
192
|
"""
|
|
@@ -185,6 +223,48 @@ def test_converter_pre(testdir):
|
|
|
185
223
|
result.assert_outcomes(passed=1)
|
|
186
224
|
|
|
187
225
|
|
|
226
|
+
def test_converter_post_pre_v2(testdir):
|
|
227
|
+
testdir.makepyfile(
|
|
228
|
+
"""
|
|
229
|
+
import tempfile
|
|
230
|
+
from pytest_regtest import register_converter_post
|
|
231
|
+
|
|
232
|
+
@register_converter_post
|
|
233
|
+
def to_upper_conv(line):
|
|
234
|
+
return line.upper()
|
|
235
|
+
|
|
236
|
+
def test_regtest(regtest_all, tmpdir):
|
|
237
|
+
print("this is expected outcome")
|
|
238
|
+
print(tmpdir.join("test").strpath)
|
|
239
|
+
print(tempfile.gettempdir())
|
|
240
|
+
print(tempfile.mkdtemp())
|
|
241
|
+
print("obj id is", hex(id(tempfile)))
|
|
242
|
+
"""
|
|
243
|
+
)
|
|
244
|
+
result = testdir.runpytest_subprocess()
|
|
245
|
+
result.assert_outcomes(failed=1)
|
|
246
|
+
|
|
247
|
+
expected_diff = """
|
|
248
|
+
> --- is
|
|
249
|
+
> +++ tobe
|
|
250
|
+
> @@ -1,5 +0,0 @@
|
|
251
|
+
> -THIS IS EXPECTED OUTCOME
|
|
252
|
+
> -<TMPDIR_FROM_FIXTURE>/TEST
|
|
253
|
+
> -<TMPDIR_FROM_TEMPFILE_MODULE>
|
|
254
|
+
> -<TMPDIR_FROM_TEMPFILE_MODULE>
|
|
255
|
+
> -OBJ ID IS 0X?????????
|
|
256
|
+
""".strip().split(
|
|
257
|
+
"\n"
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
result.stdout.fnmatch_lines(
|
|
261
|
+
[line.lstrip() for line in expected_diff], consecutive=True
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
result = testdir.runpytest("--regtest-reset")
|
|
265
|
+
result.assert_outcomes(passed=1)
|
|
266
|
+
|
|
267
|
+
|
|
188
268
|
def test_converter_post(testdir):
|
|
189
269
|
testdir.makepyfile(
|
|
190
270
|
"""
|
|
@@ -227,6 +307,7 @@ def test_converter_post(testdir):
|
|
|
227
307
|
result.assert_outcomes(passed=1)
|
|
228
308
|
|
|
229
309
|
|
|
310
|
+
|
|
230
311
|
def test_consider_line_endings(create_test_regtest_fh):
|
|
231
312
|
create_test_regtest_fh.runpytest("--regtest-reset")
|
|
232
313
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/requires.txt
RENAMED
|
File without changes
|
{pytest-regtest-2.0.2 → pytest-regtest-2.0.3}/pytest_regtest/pytest_regtest.egg-info/top_level.txt
RENAMED
|
File without changes
|