def expect(self, text):
<EOL>end_time = time.time() + self.timeout<EOL>buf = '<STR_LIT>'<EOL>while (end_time - time.time()) > <NUM_LIT:0.0>:<EOL><INDENT>reads, _, _ = select.select([self.fd], [], [], end_time - time.time())<EOL>if len(reads) > <NUM_LIT:0>:<EOL><INDENT>try:<EOL><INDENT>buf = remove_ansi_escape_sequences(buf + self.read())<EOL><DEDENT>except EOFError:<EOL><INDENT>print('<STR_LIT>' % len(buf))<EOL>assert buf == text<EOL><DEDENT>if buf == text:<EOL><INDENT>return<EOL><DEDENT>elif len(buf) >= len(text):<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>time.sleep(self.timeout/<NUM_LIT:10>)<EOL><DEDENT><DEDENT>assert buf == text<EOL>
Read until equals text or timeout.