diff options
| author | ianb <devnull@localhost> | 2005-11-11 18:51:28 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-11-11 18:51:28 +0000 |
| commit | 32bf96f3f4a78f50e33bf8a6872108bec166e63b (patch) | |
| tree | 8bb799a25c400e8c3ea95dd209bc00b0cbadfa58 /paste/fixture.py | |
| parent | 4a723df23fba4a3aa78a1aad987d99b999c5cf75 (diff) | |
| download | paste-32bf96f3f4a78f50e33bf8a6872108bec166e63b.tar.gz | |
Allow testing for the presence of non-string items (they will be converted to strings); expand the 404 error; add a .form property that means .forms[0]; handle fully-qualified redirect properly
Diffstat (limited to 'paste/fixture.py')
| -rw-r--r-- | paste/fixture.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/paste/fixture.py b/paste/fixture.py index 1500df3..940c52f 100644 --- a/paste/fixture.py +++ b/paste/fixture.py @@ -354,8 +354,8 @@ class TestApp(object): res.status >= 300 and res.status < 400): return raise AppError( - "Bad response: %s (not 200 OK or 3xx redirect)" - % res.full_status) + "Bad response: %s (not 200 OK or 3xx redirect for %s)" + % (res.full_status, res.request.url)) if status != res.status: raise AppError( "Bad response: %s (not %s)" % (res.full_status, status)) @@ -397,6 +397,11 @@ class TestResponse(object): forms = property(forms__get) + def form__get(self): + return self.forms[0] + + form = property(form__get) + _tag_re = re.compile(r'<(/?)([a-z0-9_\-]*)(.*?)>') def _parse_forms(self): @@ -612,6 +617,8 @@ class TestResponse(object): of the response. Whitespace is normalized when searching for a string. """ + if not isinstance(s, (str, unicode)): + s = str(s) return (self.body.find(s) != -1 or self.normal_body.find(s) != -1) @@ -660,6 +667,8 @@ class TestRequest(object): disabled = True def __init__(self, url, environ, expect_errors=False): + if url.startswith('http://localhost'): + url = url[len('http://localhost'):] self.url = url self.environ = environ if environ.get('QUERY_STRING'): |
