Page MenuHomePhabricator

test_https_cert_error is failing because two warnings are logged instead of one
Closed, DeclinedPublic

Description

https://travis-ci.org/wikimedia/pywikibot-core/jobs/209768127#L4197

=================================== FAILURES ===================================

________________ HttpsCertificateTestCase.test_https_cert_error ________________

self = <tests.http_tests.HttpsCertificateTestCase testMethod=test_https_cert_error>

    def test_https_cert_error(self):

        """Test if http.fetch respects disable_ssl_certificate_validation."""

        self.assertRaisesRegex(pywikibot.FatalServerError, self.CERT_VERIFY_FAILED_RE,

                               http.fetch,

                               uri='https://testssl-expire-r2i2.disig.sk/index.en.html')

        http.session.close()  # clear the connection

    

        with warnings.catch_warnings(record=True) as warning_log:

            response = http.fetch(

                uri='https://testssl-expire-r2i2.disig.sk/index.en.html',

                disable_ssl_certificate_validation=True)

        r = response.content

        self.assertIsInstance(r, unicode)

        self.assertTrue(re.search(r'<title>.*</title>', r))

        http.session.close()  # clear the connection

    

        # Verify that it now fails again

        self.assertRaisesRegex(pywikibot.FatalServerError, self.CERT_VERIFY_FAILED_RE,

                               http.fetch,

                               uri='https://testssl-expire-r2i2.disig.sk/index.en.html')

        http.session.close()  # clear the connection

    

        # Verify that the warning occurred

>       self.assertEqual(len(warning_log), 1)

E       AssertionError: 2 != 1

Event Timeline

I ran this test with python 3.4 on tool labs, but the test passed successfully.

Then created a fork to test this under travis enviroment. Again could not reproduce the issue.

Maybe it has been a temporary problem. I'm going to mark this as decline for now.