Skip to main content

A nose plugin to detect tests making http calls.

Project description

A nose and pytest plugin that can detect tests making external http calls. With nose, it adds a single artificial failure with all the results:

$ nosetests -v --with-detecthttp
test_that_makes_request (example.ExampleTests) ... ok
test_with_no_request (example.ExampleTests) ... ok

FAIL: Tests made external http calls
- example.ExampleTests:


Ran 2 tests in 0.063s

FAILED (failures=1)

With pytest, failures are added to individual tests:

$ pytest --with-detecthttp

item = <TestCaseFunction 'test_that_makes_request'>

    def pytest_runtest_teardown(item):
        # Note unmocked interactions collected during runtest_call.
        # This is raised here so that pytest doesn't mark it as an internal error.

        report = item.config._detecthttp_reports.pop(item.nodeid, None)
        if item.config._detecthttp_enabled and report:
>           raise report
E           UnmockedRequestsDetected: detecthttp noticed the following requests during this test:
E                 GET

detecthttp/ UnmockedRequestsDetected
...2 passed, 1 error in 0.35 seconds

Localhost is automatically ignored. To ignore other hosts, use the –vcr-ignore-host option, which takes a comma-delimited list:

$ nosetests -v --with-detecthttp
test_that_makes_request (example.ExampleTests) ... ok
test_with_no_request (example.ExampleTests) ... ok

Ran 2 tests in 0.110s


Under the hood, this wraps every test in a separate cassette. Since’s hooks are in the stdlib, this approach won’t detect requests made with clients like PycURL.



released 2018-12-18

  • add pytest support


released 2018-09-12

  • breaking: ignore host flag now accepts comma-separated values rather than being provided multiple times


released 2017-08-15

  • add –vcr-ignore-host option to ignore custom hosts


released 2015-10-16

  • python 3 support


released 2014-11-24

  • initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nose-detecthttp, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size nose-detecthttp-1.1.0.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page