Skip to main content

[not actively supported outside of internal Venmo usage]

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 example.py
test_that_makes_request (example.ExampleTests) ... ok
test_with_no_request (example.ExampleTests) ... ok

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

    test_that_makes_request:
      GET http://example.com/


----------------------------------------------------------------------
Ran 2 tests in 0.063s

FAILED (failures=1)

With pytest, failures are added to individual tests:

$ pytest --with-detecthttp example.py
...

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 http://example.com/

detecthttp/pytest.py:82: 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 --vcr-ignore-host=example.com example.py
test_that_makes_request (example.ExampleTests) ... ok
test_with_no_request (example.ExampleTests) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.110s

OK

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

History

1.2.1

  • Add Python 3 support

1.1.0

released 2018-12-18

  • add pytest support

1.0.0

released 2018-09-12

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

0.2.0

released 2017-08-15

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

0.1.3

released 2015-10-16

  • python 3 support

0.1.1

released 2014-11-24

  • initial release

Release files for nose-detecthttp 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nose-detecthttp 1.2.1
File Size Uploaded
nose-detecthttp-1.2.1.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nose-detecthttp 1.2.1
File Interpreter ABI Platform
nose_detecthttp-1.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 13.1 kB

Release files / nose-detecthttp-1.2.1.tar.gz

Download URL nose-detecthttp-1.2.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0b0c39b7e23666ecd8a87c6fbdddb247c58ba96dec29317cac9ccc9fddb3a97f
BLAKE2b-256 checksum
How to use checksums
be530023e928569bf992a165ae9f6e0f8c71732b9bc1f4802e8ff9bc3bd6b5cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

Release files / nose_detecthttp-1.2.1-py2.py3-none-any.whl

Download URL nose_detecthttp-1.2.1-py2.py3-none-any.whl
Size 7.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ea55241f47af6fd94ea3c8bef56602516dde980015341d337c5fbec901bdc0af
BLAKE2b-256 checksum
How to use checksums
c3d7a77446331145149cf9ac749ce5fe750e7925bac85c162546faa66b7bf081
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.1.0

1 release file

1.0.0

1 release file

0.2.0

1 release file

0.1.3

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page