Skip to content

Mocket fails to mock HTTPS after upgrading urllib3 to 1.26.5 #151

@ghost

Description

Describe the bug
Mocket on version 3.9.41 is not working well with HTTPS URLs.

To Reproduce
Steps to reproduce the behavior:
it's failing your test tests/main/test_httpretty.py::test_rotating_responses_with_requests.

FAILED tests/main/test_httpretty.py::test_rotating_responses_with_requests - requests.exceptions.SSLError: HTTPSConnectionPool(host='api.yahoo.com', port=443): Max retries exceeded with URL...

We have reproduced with these tests:

import requests,json
from unitest import TestCase

HTTPS_URL = "https://google.com"
HTTP_URL = "http://google.com"

class ReproduceSslError(Testcase):

    @mocketize
    def test_mocket_fine(self):
        Entry.single_register(
            Entry.GET,
            HTTP_URL,
            body=json.dumps({"foo":"bar"}),
            headers={"Content-Type": "application/json"}
        )
        response = requests.get(HTTP_URL)

    @mocketize
    def test_mocket_error(self):
        Entry.single_register(
            Entry.GET,
            HTTPS_URL,
            body=json.dumps({"foo":"bar"}),
            headers={"Content-Type": "application/json"}
        )
        response = requests.get(HTTPS_URL)

Expected behavior
It should mock HTTPS requests too.

Docker image (please complete the following information):

  • python:3.8-slim

Additional context

  • Python libs:
    mocket = "==3.9.41"
    requests = "==2.25.1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions