diff -r 75a232b2e477 -r 8e59c2cdcc99 devtools/testlib.py --- a/devtools/testlib.py Thu Feb 10 17:17:54 2011 +0100 +++ b/devtools/testlib.py Fri Feb 11 12:17:47 2011 +0100 @@ -664,13 +664,6 @@ # content validation ####################################################### - def assertDocTestFile(self, testfile): - # doctest returns tuple (failure_count, test_count) - result = self.shell().process_script(testfile) - if result[0] and result[1]: - raise self.failureException("doctest file '%s' failed" - % testfile) - # validators are used to validate (XML, DTD, whatever) view's content # validators availables are : # DTDValidator : validates XML + declared DTD @@ -755,25 +748,35 @@ raise AssertionError, msg, tcbk return self._check_html(output, view, template) + def get_validator(self, view=None, content_type=None, output=None): + if view is not None: + try: + return self.vid_validators[view.__regid__]() + except KeyError: + if content_type is None: + content_type = view.content_type + if content_type is None: + content_type = 'text/html' + if content_type in ('text/html', 'application/xhtml+xml'): + if output and output.startswith(' used in progress widget, unknown in html dtd output = re.sub('', '', output) @@ -816,6 +819,13 @@ msg += u'\nfor content:\n%s' % content raise AssertionError, msg, tcbk + def assertDocTestFile(self, testfile): + # doctest returns tuple (failure_count, test_count) + result = self.shell().process_script(testfile) + if result[0] and result[1]: + raise self.failureException("doctest file '%s' failed" + % testfile) + # deprecated ############################################################### @deprecated('[3.8] use self.execute(...).get_entity(0, 0)')