Skip to content

Commit 92ff462

Browse files
committed
Workaround pytest issue 5997
It seems that the bug described in pytest-dev/pytest#5997 is preventing stderr to be captured by capsys. The workaround consists in using both `capfd` and `--capture=tee-sys` (or just `-s`).
1 parent d088f71 commit 92ff462

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tests/test_django.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_cli_without_django(tmpfolder):
111111
assert not Path(path).exists()
112112

113113

114-
def test_cli_with_django_and_update(tmpfolder, capsys):
114+
def test_cli_with_django_and_update(tmpfolder, capfd):
115115
# Given a project exists
116116
create_project(project_path=PROJ_NAME, config_files=NO_CONFIG)
117117
# NO_CONFIG: avoid extra config from dev's machine interference
@@ -122,7 +122,7 @@ def test_cli_with_django_and_update(tmpfolder, capsys):
122122
# --no-config: avoid extra config from dev's machine interference
123123

124124
# then a warning should be displayed
125-
out, err = capsys.readouterr()
125+
out, err = capfd.readouterr()
126126
assert all(
127127
warn in out + err
128128
for warn in ("external tools", "not supported", "will be ignored")

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ extras =
2525
all
2626
testing
2727
commands =
28-
pytest {posargs}
28+
pytest --capture=tee-sys {posargs}
29+
# --capture=tee-sys is need otherwise the test fails, I believe this is related to:
30+
# https://github.com/pytest-dev/pytest/issues/5997
2931

3032

3133
[testenv:{clean,build}]

0 commit comments

Comments
 (0)