import pytest import lxml.etree class ValidatingClient(object): def __init__(self, client): self.client = client def request(self, url, method, exp_status=200, params={}): if not url.startswith('/quotes/'): url = '/quotes/' + url if method == 'get': response = self.client.get(url) elif method == 'post': response = self.client.post(url, params) else: raise RuntimeError('Unknown method %s for %s' % (method, url)) assert response.status_code == exp_status if response.status_code != 200: return None assert response.charset == 'utf-8' document = response.content.decode(response.charset) print 'For url %s got page:\n%s' % (url, document) lxml.etree.fromstring(document.replace('
', '
')) assert '