Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
devanshshukla99 committed May 22, 2021
1 parent b83396b commit a5473d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
16 changes: 11 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ pytest-intercept-remote
|license| |build| |coverage| |status|


This package provides a plugin for ``pytest`` framework to intercept outgoing connection requests and dumps them to a file.
This package provides a plugin for ``pytest`` framework for intercepting outgoing connection requests during test runs.

Installation
------------

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

.. code-block:: bash
$ pip install pytest-intercept-remote
or by:

.. code-block:: bash
$ git clone https://github.com/devanshshukla99/pytest-intercept-remote
Expand All @@ -22,10 +28,10 @@ The ``pytest-intercept-remote`` plugin can be installed by using:
The plugin will register automatically with ``pytest`` framework and will be ready to use.

Config
------
Configuration
-------------

The default dump file can be configured by specifing ``intercept_dump_file`` in the ini file or by overriding it by ``-o intercept_dump_file``.
The default dump file is ``.intercepted`` which can be overrided by specifing ``intercept_dump_file`` in the ini file or by adding ``-o intercept_dump_file=[dump file]`` option.

.. code-block:: bash
Expand All @@ -34,7 +40,7 @@ The default dump file can be configured by specifing ``intercept_dump_file`` in
Usage
-----

This plugin can be used by using ``--intercept-remote`` option;
The urls can be intercepted using ``--intercept-remote`` option;

.. code-block:: bash
Expand Down
7 changes: 3 additions & 4 deletions pytest_intercept_remote/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@


def pytest_addoption(parser):
DEFAULT_DUMP_FILE = "remote_urls.json"
DEFAULT_DUMP_FILE = ".intercepted"

parser.addoption("--intercept-remote", action="store_true", default=False,
parser.addoption("--intercept-remote", dest="intercept_remote", action="store_true", default=False,
help="Intercepts outgoing connections requests.")
parser.addini("intercept_dump_file", "filepath at which intercepted requests are dumped",
type="string", default=DEFAULT_DUMP_FILE)
Expand All @@ -23,7 +23,6 @@ def pytest_configure(config):
print("Intercept outgoing requests: disabled")

intercept_remote = config.getoption('--intercept-remote')

if intercept_remote:
global mpatch
intercept_patch(mpatch)
Expand Down Expand Up @@ -87,7 +86,6 @@ def intercept_dump(config):
Dumps intercepted requests to ini option ``intercept_dump_file``.
"""
global _requests_urls, _urllib_urls, _sockets_urls

_urls = {
'urls_urllib': _urllib_urls,
'urls_requests': _requests_urls,
Expand All @@ -101,6 +99,7 @@ def intercepted_urls():
"""
Pytest fixture to get the list of intercepted urls in a test
"""
global _requests_urls, _urllib_urls, _sockets_urls
_urls = {
'urls_urllib': _urllib_urls,
'urls_requests': _requests_urls,
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ url = https://github.com/devanshshukla99/pytest-intercept-remote
author = devanshshukla99
author_email = [email protected]
classifiers =
Development Status :: 3 - Alpha
Development Status :: 4 - Beta
Framework :: Pytest
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Expand Down Expand Up @@ -48,6 +48,7 @@ minversion = 4.6
testpaths = tests

[coverage:run]
disable_warnings = no-data-collected
omit =
*/__init__*
*/_version.py
Expand Down

0 comments on commit a5473d1

Please sign in to comment.