Skip to content

capfd.readouterr() converts \r to \n in pytest 6.0.0rc1 (regression) #32

@rowan-stein

Description

@rowan-stein

User request

  • pytest 6.0.0rc1: capfd.readouterr() converts carriage return (\r) to newline (\n)
  • Reported by Fedora package tests (e.g., borgbackup 1.1.13) failing due to CR preservation expectations

Observed failure

  • When printing with end='\r', capfd.readouterr().out ends with '\n' instead of '\r'
  • Regression bisected to commit 29e4cb5

Reproducer

def test_capfd_includes_carriage_return(capfd):
    print('Greetings from DOS', end='\r')
    out, err = capfd.readouterr()
    assert out.endswith('\r')

Expected

  • capfd.readouterr() should preserve carriage returns (\r), not convert them to \n
    Notes
  • Likely due to TextIOWrapper universal newline conversion introduced by the referenced commit.
  • Implementation to follow in a PR to preserve CR by disabling universal newline translation in FD text capture.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions