diff options
author | ianb <devnull@localhost> | 2006-07-15 17:13:37 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2006-07-15 17:13:37 +0000 |
commit | d959df3d5b7eb6c0efcbcc484823ee08628b4b0c (patch) | |
tree | 06b3b963a6c44865bd4069febdc4082403107df1 /paste/fixture.py | |
parent | ccee9055c97a07f2d5bcea842fd81d2f10a1a3cf (diff) | |
download | paste-d959df3d5b7eb6c0efcbcc484823ee08628b4b0c.tar.gz |
Added a 'no' argument to mustcontain
Diffstat (limited to 'paste/fixture.py')
-rw-r--r-- | paste/fixture.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/paste/fixture.py b/paste/fixture.py index 9fb6f34..459973b 100644 --- a/paste/fixture.py +++ b/paste/fixture.py @@ -685,7 +685,7 @@ class TestResponse(object): return (self.body.find(s) != -1 or self.normal_body.find(s) != -1) - def mustcontain(self, *strings): + def mustcontain(self, *strings, **kw): """ Assert that the response contains all of the strings passed in as arguments. @@ -694,12 +694,28 @@ class TestResponse(object): assert string in res """ + if 'no' in kw: + no = kw['no'] + del kw['no'] + if isinstance(no, basestring): + 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 >> sys.stderr, "Actual response (no %r):" % s print >> sys.stderr, self raise IndexError( "Body does not contain string %r" % s) + for no_s in no: + if no_s in self: + print >> sys.stderr, "Actual response (has %r)" % s + print >> sys.stderr, self + raise IndexError( + "Body contains string %r" % s) def __repr__(self): return '<Response %s %r>' % (self.full_status, self.body[:20]) |