question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, I’d like to use httpretty to speed up my tests as we have some lookups to googleapis and others. Is it possible set allow_net_connect = False, mock the desired requests with fixtures and still allow some urls, such as a local Elastic Search server?

This is what my TestCase looks like:

class MockedHTTPTestsMixin(object):

    def run(self, result=None):
        httpretty.enable()
        httpretty.HTTPretty.allow_net_connect = False

        httpretty.register_uri(
            httpretty.GET,
            r'http://maps.googleapis.com/maps/api/geocode/json?.*',
            body=google_json,
        )

        try:
            super(MockedHTTPTestsMixin, self).run(result)
        finally:
            httpretty.disable()
            httpretty.reset()

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:7
  • Comments:5

github_iconTop GitHub Comments

4reactions
timc13commented, Jun 13, 2017

allowing a whitelist of hostnames would be nice (so it could work in a containerized environment)

2reactions
sloriacommented, Jun 21, 2018

I am also interested in this. We need to block all outgoing requests to 3rd-party APIs whilst allowing requests to Elasticsearch. A whitelist of hostnames as @timc13 suggested, would solve this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable local file links
In Google Chrome, links to local files are disabled, unlike IE. This extension allows you to open a link to a local file...
Read more >
Restrictions on File Urls - text/plain
Similarly, the Enable Local File Links extension simply adds a click event listener to every page loaded in the browser.
Read more >
url - How to specify a local file within html using the file: scheme?
The file: URL scheme refers to a file on the client machine. There is no hostname in the file: scheme; you just provide...
Read more >
Why local links are disabled by default in modern browsers?
For example, in the settings of NoScript you can choose Advanced->Trusted and mark "Allow local links". Now open Firefox console and execute ...
Read more >
How to enable local file links in Firefox (on Windows)
I found threads like this to enable links to local files: How do I instruct Firefox to allow me to open file:/// URLs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found