Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_local_execute_basic_pass_show_on_standard_newline_flush has \r\n in output #2841

Closed
frenzymadness opened this issue Jan 9, 2023 · 2 comments
Labels
bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@frenzymadness
Copy link

When I run test_local_execute_basic_pass_show_on_standard_newline_flush or test_local_execute_write_a_lot in our Fedora Linux build system they fail because the output from the tox contains \r\n instead of just \n.

The complete output is:

# python3 -m pytest -vsx -k "test_local_execute_basic_pass_show_on_standard_newline_flush"
==================================== test session starts =====================================
platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /builddir/build/BUILD/tox-4.2.6, configfile: pyproject.toml, testpaths: tests
plugins: xdist-3.1.0, cov-4.0.0, mock-3.10.0, flaky-3.7.0
collected 1405 items / 1404 deselected / 1 selected                                          

tests/execute/local_subprocess/test_local_subprocess.py::test_local_execute_basic_pass_show_on_standard_newline_flush FAILED

========================================== FAILURES ==========================================
________________ test_local_execute_basic_pass_show_on_standard_newline_flush ________________

caplog = <_pytest.logging.LogCaptureFixture object at 0x7f75e0b766d0>

    def test_local_execute_basic_pass_show_on_standard_newline_flush(caplog: LogCaptureFixture) -> None:
        caplog.set_level(logging.NOTSET)
        executor = LocalSubProcessExecutor(colored=False)
        request = ExecuteRequest(
            cmd=[sys.executable, "-c", "import sys; print('out'); print('yay')"],
            cwd=Path(),
            env=os.environ.copy(),
            stdin=StdinSource.OFF,
            run_id="",
        )
        out_err = FakeOutErr()
        with executor.call(request, show=True, out_err=out_err.out_err, env=MagicMock()) as status:
            while status.exit_code is None:  # pragma: no branch
                status.wait()
        outcome = status.outcome
        assert outcome is not None
        assert repr(outcome)
        assert bool(outcome) is True, outcome
        assert outcome.exit_code == Outcome.OK
        assert not outcome.err
>       assert outcome.out == f"out{os.linesep}yay{os.linesep}"
E       AssertionError: assert 'out\r\nyay\r\n' == 'out\nyay\n'
E         - out
E         + out
E         ?    +
E         - yay
E         + yay
E         ?    +

caplog     = <_pytest.logging.LogCaptureFixture object at 0x7f75e0b766d0>
executor   = <tox.execute.local_sub_process.LocalSubProcessExecutor object at 0x7f75e1614790>
out_err    = <tests.execute.local_subprocess.test_local_subprocess.FakeOutErr object at 0x7f75e0f7d290>
outcome    = Outcome: exit 0 in 0.01 seconds for /usr/bin/python3 -c 'import sys; print('"'"'out'"'"'); print('"'"'yay'"'"')'
request    = ExecuteRequest(cmd=['/usr/bin/python3', '-c', "import sys; print('out'); print('yay')"], cwd=PosixPath('.'), env=..., stdin=<StdinSource.OFF: 0>)
status     = LocalSubprocessExecuteStatus(pid=188, returncode=0)

tests/execute/local_subprocess/test_local_subprocess.py:98: AssertionError
================================== short test summary info ===================================
FAILED tests/execute/local_subprocess/test_local_subprocess.py::test_local_execute_basic_pass_show_on_standard_newline_flush - AssertionError: assert 'out\r\nyay\r\n' == 'out\nyay\n'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================= 1 failed, 1404 deselected in 0.55s =============================

I have no idea why this is happening. As you can see, the running process has \n as os.linesep and I don't know why tox running in the test would have anything else.

@gaborbernat gaborbernat added bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. labels Jan 9, 2023
@gaborbernat
Copy link
Member

PR welcome.

@frenzymadness
Copy link
Author

I'm no longer able to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

2 participants