Skip to content

Commit

Permalink
Replace py.io.StdCaptureFD with _pytest.capture.MultiCapture. Refs de…
Browse files Browse the repository at this point in the history
  • Loading branch information
fschulze committed Aug 30, 2023
1 parent 56c2667 commit 95f013b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions client/testing/conftest.py
@@ -1,4 +1,5 @@
from __future__ import print_function
from _pytest import capture
from contextlib import closing
from devpi_common.metadata import parse_version
from io import BytesIO
Expand Down Expand Up @@ -571,8 +572,11 @@ def doit(*args, **kwargs):
def out_devpi(devpi):
def out_devpi_func(*args, **kwargs):
from _pytest.pytester import RunResult
cap = py.io.StdCaptureFD()
cap.startall()
cap = capture.MultiCapture(
in_=capture.FDCapture(0),
out=capture.FDCapture(1),
err=capture.FDCapture(2))
cap.start_capturing()
now = time.time()
ret = 0
try:
Expand All @@ -581,7 +585,8 @@ def out_devpi_func(*args, **kwargs):
if getattr(hub, "sysex", None):
ret = hub.sysex.args[0]
finally:
out, err = cap.reset()
(out, err) = cap.readouterr()
cap.stop_capturing()
del cap
except:
print(out)
Expand Down
11 changes: 8 additions & 3 deletions server/test_devpi_server/conftest.py
@@ -1,3 +1,4 @@
from _pytest import capture
import re
from webtest.forms import Upload
import json
Expand Down Expand Up @@ -1040,8 +1041,11 @@ def devpi(server_dir, args):
from _pytest.pytester import RunResult
m = MonkeyPatch()
m.setenv("DEVPISERVER_SERVERDIR", getattr(server_dir, 'strpath', server_dir))
cap = py.io.StdCaptureFD()
cap.startall()
cap = capture.MultiCapture(
in_=capture.FDCapture(0),
out=capture.FDCapture(1),
err=capture.FDCapture(2))
cap.start_capturing()
now = time.time()
if args[0] == 'devpi-gen-config':
m.setattr("sys.argv", [devpigenconfig])
Expand All @@ -1059,7 +1063,8 @@ def devpi(server_dir, args):
entry_point(argv=args)
finally:
m.undo()
out, err = cap.reset()
(out, err) = cap.readouterr()
cap.stop_capturing()
del cap
return RunResult(
0, out.split("\n"), err.split("\n"), time.time() - now)
Expand Down

0 comments on commit 95f013b

Please sign in to comment.