[issue31158] test_pty: test_basic() fails randomly on Travis CI

STINNER Victor report at bugs.python.org
Thu Sep 28 16:18:31 EDT 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

Cornelius:Here is a PoC: I checked out your code and stressed my system with it. (...) AssertionError: ..."

Did you get this failure with my PR 3802?

Cornelius: "We have b'For my pet fish, Eric.\r\n' in the pty buffer. We read b'For my pet fish, Eric.\r' from the buffer into s2. Now len(s2) == len(expected) but a b'\n' is still unread in the buffer. This would make the test fail. I admit, this is a corner case, but also an argument that a clean test case may want to have a readline function."

Right. I can just modify my condition from "len(s2) < len(expected)" to "b'\n' not in s2".

Cornelius: "I also added a pull request which I cannot get to fail on my system. What do you think, haypo?"

Your code calls read(1) in a loop until it gets the newline character b'\n'.

Is it better to os.read(1024) in a loop until the output string contains b'\n'?

I have no strong preference.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31158>
_______________________________________


More information about the Python-bugs-list mailing list