Skip to content

capfd not working in 3.3.1 #3033

@trrichard

Description

@trrichard

Fixtures that use capfd don't seem to work in version 3.3.1 running on Ubuntu 14.04 LTS with anaconda 3.6.3

import sys

@pytest.fixture()
def fix(capfd):
    yield None
    out, err = capfd.readouterr()
    stdout_filename = "/tmp/stdout"
    stderr_filename = "/tmp/stderr"
    mode = 'w'
    with open(stdout_filename, mode) as stdout:
        stdout.write(out)
    with open(stderr_filename, mode) as stderr:
        stderr.write(err)

def test_a(fix):
    print("lolcatz")
    print("this is a test")
    sys.stderr.write("err")

The stdout and stderr files end up empty after running that test. Using this set of pytest dependencies

certifi (2017.11.5)
pip (9.0.1)
pluggy (0.6.0)
py (1.5.2)
pytest (3.3.1)
setuptools (38.2.4)
six (1.11.0)
wheel (0.30.0)

Steps of replication are

  1. Create the above test
  2. Run pytest on it.
  3. cat /tmp/std* (they will be empty)
  4. Downgrade pytest ( pip install autohil==3.2.5 )
  5. Run the test again
  6. cat /tmp/std*

Metadata

Metadata

Assignees

Labels

plugin: capturerelated to the capture builtin plugintype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions