def behaves_like_regular_responder_by_default(self): r = FailingResponder( pattern='ju[^ ]{2}', response='how high?', sentinel='lolnope', ) eq_(list(r.submit('jump, wait, jump, wait')), ['how high?'] * 2)
def raises_failure_exception_when_sentinel_detected(self): r = FailingResponder( pattern="ju[^ ]{2}", response="how high?", sentinel="lolnope" ) # Behaves normally initially assert list(r.submit("jump")) == ["how high?"] # But then! try: r.submit("lolnope") except ResponseNotAccepted as e: message = str(e) # Expect useful bits in exception text err = "Didn't see pattern in {!r}".format(message) assert "ju[^ ]{2}" in message, err err = "Didn't see failure sentinel in {!r}".format(message) assert "lolnope" in message, err else: assert False, "Did not raise ResponseNotAccepted!"
def raises_failure_exception_when_sentinel_detected(self): r = FailingResponder( pattern='ju[^ ]{2}', response='how high?', sentinel='lolnope', ) # Behaves normally initially eq_(list(r.submit('jump')), ['how high?']) # But then! try: r.submit('lolnope') except ResponseNotAccepted as e: message = str(e) # Expect useful bits in exception text err = "Didn't see pattern in {!r}".format(message) ok_("ju[^ ]{2}" in message, err) err = "Didn't see failure sentinel in {!r}".format(message) ok_("lolnope" in message, err) else: assert False, "Did not raise ResponseNotAccepted!"
def raises_failure_exception_when_sentinel_detected(self): r = FailingResponder( pattern='ju[^ ]{2}', response='how high?', sentinel='lolnope', ) # Behaves normally initially eq_(list(r.submit('jump')), ['how high?']) # But then! try: r.submit('lolnope') except ResponseNotAccepted as e: message = str(e) # Expect useful bits in exception text err = "Didn't see pattern in {0!r}".format(message) ok_("ju[^ ]{2}" in message, err) err = "Didn't see failure sentinel in {0!r}".format(message) ok_("lolnope" in message, err) else: assert False, "Did not raise ResponseNotAccepted!"
def behaves_like_regular_responder_by_default(self): r = FailingResponder( pattern="ju[^ ]{2}", response="how high?", sentinel="lolnope" ) assert list(r.submit("jump, wait, jump, wait")) == ["how high?"] * 2