Skip to content

Adding support for overrides#257

Open
demianbrecht wants to merge 1 commit intogabrielfalcao:mainfrom
demianbrecht:overrides
Open

Adding support for overrides#257
demianbrecht wants to merge 1 commit intogabrielfalcao:mainfrom
demianbrecht:overrides

Conversation

@demianbrecht
Copy link
Copy Markdown

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
Copy Markdown
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.

2 participants