def test_print_stderr(self): res = self.app.get('/') res.charset = 'utf-8' res.text = '°C' print_stderr(str(res)) res.charset = None print_stderr(str(res))
def mustcontain(self, *strings, **kw): """mustcontain(*strings, no=[]) Assert that the response contains all of the strings passed in as arguments. Equivalent to:: assert string in res Can take a `no` keyword argument that can be a string or a list of strings which must not be present in the response. """ if 'no' in kw: no = kw['no'] del kw['no'] if isinstance(no, str): no = [no] else: no = [] if kw: raise TypeError("The only keyword argument allowed is 'no'") for s in strings: if s not in self: print_stderr("Actual response (no %r):" % s) print_stderr(str(self)) raise IndexError("Body does not contain string %r" % s) for no_s in no: if no_s in self: print_stderr("Actual response (has %r)" % no_s) print_stderr(str(self)) raise IndexError("Body contains bad string %r" % no_s)
def mustcontain(self, *strings, **kw): """ Assert that the response contains all of the strings passed in as arguments. Equivalent to:: assert string in res """ if 'no' in kw: no = kw['no'] del kw['no'] if isinstance(no, string_types): no = [no] else: no = [] if kw: raise TypeError( "The only keyword argument allowed is 'no'") for s in strings: if not s in self: print_stderr("Actual response (no %r):" % s) print_stderr(str(self)) raise IndexError( "Body does not contain string %r" % s) for no_s in no: if no_s in self: print_stderr("Actual response (has %r)" % no_s) print_stderr(str(self)) raise IndexError( "Body contains bad string %r" % no_s)
def mustcontain(self, *strings, **kw): """mustcontain(*strings, no=[]) Assert that the response contains all of the strings passed in as arguments. Equivalent to:: assert string in res Can take a `no` keyword argument that can be a string or a list of strings which must not be present in the response. """ if "no" in kw: no = kw["no"] del kw["no"] if isinstance(no, string_types): no = [no] else: no = [] if kw: raise TypeError("The only keyword argument allowed is 'no'") for s in strings: if s not in self: print_stderr("Actual response (no %r):" % s) print_stderr(str(self)) raise IndexError("Body does not contain string %r" % s) for no_s in no: if no_s in self: print_stderr("Actual response (has %r)" % no_s) print_stderr(str(self)) raise IndexError("Body contains bad string %r" % no_s)
def test_print_unicode(): print_stderr('°C')