Skip to main content

Pytest plugin for intercepting outgoing connection requests during pytest run.

Project description

Python versions supported License

build Code coverage Package stability PyPi version

This package provides a plugin for pytest framework for intercepting outgoing connection requests during test runs.


The pytest-intercept-remote plugin can be installed by using:

$ pip install pytest-intercept-remote

or by:

$ git clone
$ cd pytest-intercept-remote
$ pip install .

The plugin will register automatically with pytest framework and will be ready to use.


The default dump file is .intercepted which can be overridden by:

  • either specifing intercept_dump_file in the ini file

  • or by adding -o intercept_dump_file=[dump file] option

$ pytest --intercept-remote -o intercept_dump_file=urls.json


Intercepting requests

The urls can be intercepted using --intercept-remote option;

$ pytest --intercept-remote

The tests trying to connect to internet will xfail.

Remote status

Once the requests are intercepted, they can be pinged for their status by using --remote-status=[show/only/no] option.

  • --remote-status=show will append the ping functions to pytest run;

  • --remote-status=only will only ping the requests and deselect all other tests;

$ pytest --remote-status=show
$ pytest --remote-status=only


Use tox to make sure the plugin is working:

$ git clone
$ cd pytest-intercept-remote
$ tox -e py38

See tox for more info.


This plugin is licenced under a 3-clause BSD style licence - see the LICENCE file.

Project details

Download files

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

Source Distribution

pytest-intercept-remote-1.25.tar.gz (9.5 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page