X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=quotes%2Fconftest.py;h=26ac8efe0b44e9db997681542358e62e7c125349;hb=8e7c1ea13e2ab23eafb24ba2106b0dde9085f9b4;hp=5cdf30a8431f17093e24322ca3e8ba8892103adb;hpb=bb8b5bd36c5f921ba31635bb858db3d4788ef0e9;p=djsite.git diff --git a/quotes/conftest.py b/quotes/conftest.py index 5cdf30a..26ac8ef 100644 --- a/quotes/conftest.py +++ b/quotes/conftest.py @@ -1,11 +1,13 @@ import pytest import lxml.etree +import html5lib +import urlparse 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 @@ -17,18 +19,40 @@ class ValidatingClient(object): 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) - lxml.etree.fromstring(document) + print 'For url %s got page:\n%s' % (url, document) + lxml.etree.fromstring(document.replace('
', '
')) + + parser = html5lib.HTMLParser(strict=True) + parser.parse(document) + assert '