Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for overrides #257

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

demianbrecht
Copy link

I have a use case where the 'localhost' value baked in for gethostname is insufficient as the hostname is actually meaningful. This patch provides the capability to override what httpretty patches. Currently, I'm simply mocking the attributes after .enable() is called, but there's something about mocking the mocker that doesn't sit well with me ;) Kinda makes me think that this is something that should be supported.

If there's no opposition to the proposed addition, I'll add the feature to the docs before merge.

@gabrielfalcao
Copy link
Owner

Hey, first of all, sorry for taking so long to answer.

Secondly, I'm sorry that the CI server build failed, I'll be glad to merge this under 2 conditions:

  • The travis build passes
  • Also add an alias for your feature:
overrides = {
    'socket': {
        'gethostname': _GETHOSTNAME,
        'gethostbyname': _GETHOSTBYNAME,
        'getaddrinfo': _GETADDRINFO,
    },
}

@httpretty.activate(with_overrides=overrides)
def test_something():
    requests.get("http://whatever.com")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants