'Test to verify fix for https://github.com/andresriancho/w3af/issues/6723
"w3af running long time more than 24h"'

def test_parser_timeout(self):

    mmpdp = 'w3af.core.data.parsers.mp_document_parser.%s'
    kmpdp = (mmpdp % 'MultiProcessingDocumentParser.%s')
    modp = 'w3af.core.data.parsers.document_parser.%s'
    with patch((mmpdp % 'om.out')) as om_mock:
        with patch((kmpdp % 'PARSER_TIMEOUT'), new_callable=PropertyMock) as timeout_mock:
            with patch((kmpdp % 'MAX_WORKERS'), new_callable=PropertyMock) as max_workers_mock:
                with patch((modp % 'DocumentParser.PARSERS'), new_callable=PropertyMock) as parsers_mock:
                    html = '<html>DelayedParser!</html>'
                    http_resp = _build_http_response(html, u'text/html')
                    timeout_mock.return_value = 1
                    max_workers_mock.return_value = 1
                    parsers_mock.return_value = [DelayedParser, HTMLParser]
                    try:
                        self.mpdoc.get_document_parser_for(http_resp)
                    except BaseFrameworkException:
                        self._is_timeout_exception_message(om_mock, http_resp)
                    else:
                        self.assertTrue(False)
                    html = '<html>foo-</html>'
                    http_resp = _build_http_response(html, u'text/html')
                    doc_parser = self.mpdoc.get_document_parser_for(http_resp)
                    self.assertIsInstance(doc_parser._parser, HTMLParser)
