{ "info": { "author": "Mike Fiedler", "author_email": "miketheman@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Pytest", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Testing" ], "description": "=============\npytest-socket\n=============\n\n.. image:: https://img.shields.io/pypi/v/pytest-socket.svg\n :target: https://pypi.python.org/pypi/pytest-socket\n\n.. image:: https://img.shields.io/pypi/pyversions/pytest-socket.svg\n :target: https://pypi.python.org/pypi/pytest-socket\n\n.. image:: https://travis-ci.org/miketheman/pytest-socket.svg?branch=master\n :target: https://travis-ci.org/miketheman/pytest-socket\n :alt: See Build Status on Travis CI\n\n.. image:: https://ci.appveyor.com/api/projects/status/github/miketheman/pytest-socket?branch=master&svg=true\n :target: https://ci.appveyor.com/project/miketheman/pytest-socket/branch/master\n :alt: See Build Status on AppVeyor\n\n.. image:: https://api.codeclimate.com/v1/badges/1608a75b1c3a20211992/maintainability\n :target: https://codeclimate.com/github/miketheman/pytest-socket/maintainability\n :alt: Maintainability\n\nA plugin to use with Pytest to disable or restrict ``socket`` calls during tests to ensure network calls are prevented.\n\n----\n\nThis `Pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template.\n\n\nFeatures\n--------\n\n* Disables all network calls flowing through Python's ``socket`` interface.\n\n\nRequirements\n------------\n\n* `Pytest`_ 3.6.3 or greater\n\n\nInstallation\n------------\n\nYou can install \"pytest-socket\" via `pip`_ from `PyPI`_::\n\n $ pip install pytest-socket\n\n\nUsage\n-----\n\n* Run ``pytest --disable-socket``, tests should fail on any access to ``socket`` or libraries using\n socket with a ``SocketBlockedError``.\n\n To add this flag as the default behavior, add this section to your ``pytest.ini`` or ``setup.cfg``:\n\n .. code:: ini\n\n [pytest]\n addopts = --disable-socket\n\n\n or update your ``conftest.py`` to include:\n\n .. code:: python\n\n from pytest_socket import disable_socket\n\n def pytest_runtest_setup():\n disable_socket()\n\n\n* To enable specific tests use of ``socket``, pass in the fixture to the test or use a marker:\n\n .. code:: python\n\n def test_explicitly_enable_socket(socket_enabled):\n assert socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n\n\n @pytest.mark.enable_socket\n def test_explicitly_enable_socket_with_mark():\n assert socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n\n* To allow only specific hosts per-test:\n\n .. code:: python\n\n @pytest.mark.allow_hosts(['127.0.0.1'])\n def test_explicitly_enable_socket_with_mark():\n assert socket.socket.connect(('127.0.0.1', 80))\n\nor for whole test run\n\n .. code:: ini\n\n [pytest]\n addopts = --allow-hosts=127.0.0.1,127.0.1.1\n\n\nContributing\n------------\nContributions are very welcome. Tests can be run with `tox`_, please ensure\nthe coverage at least stays the same before you submit a pull request.\n\nLicense\n-------\n\nDistributed under the terms of the `MIT`_ license, \"pytest-socket\" is free and open source software\n\n\nIssues\n------\n\nIf you encounter any problems, please `file an issue`_ along with a detailed description.\n\n\nReferences\n----------\n\nThis plugin came about due to the efforts by `@hangtwenty`_ solving a `StackOverflow question`_,\nthen converted into a pytest plugin by `@miketheman`_.\n\n\n.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter\n.. _`@hackebrot`: https://github.com/hackebrot\n.. _`MIT`: http://opensource.org/licenses/MIT\n.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin\n.. _`file an issue`: https://github.com/miketheman/pytest-socket/issues\n.. _`pytest`: https://github.com/pytest-dev/pytest\n.. _`tox`: https://tox.readthedocs.io/en/latest/\n.. _`pip`: https://pypi.python.org/pypi/pip/\n.. _`PyPI`: https://pypi.python.org/pypi\n.. _`@hangtwenty`: https://github.com/hangtwenty\n.. _`StackOverflow question`: https://stackoverflow.com/a/30064664\n.. _`@miketheman`: https://github.com/miketheman", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/miketheman/pytest-socket", "keywords": "", "license": "MIT", "maintainer": "Mike Fiedler", "maintainer_email": "miketheman@gmail.com", "name": "pytest-socket", "package_url": "https://pypi.org/project/pytest-socket/", "platform": "", "project_url": "https://pypi.org/project/pytest-socket/", "project_urls": { "Homepage": "https://github.com/miketheman/pytest-socket" }, "release_url": "https://pypi.org/project/pytest-socket/0.3.3/", "requires_dist": null, "requires_python": "", "summary": "Pytest Plugin to disable socket calls during tests", "version": "0.3.3" }, "last_serial": 4799966, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "59dd732a5c693d8ad5a5cea2cc5743e9", "sha256": "7089bb3418a1f41d9d29b18dbb65820c47bbe29254f6967bfb421d9ff42abf3d" }, "downloads": -1, "filename": "pytest-socket-0.1.0.tar.gz", "has_sig": false, "md5_digest": "59dd732a5c693d8ad5a5cea2cc5743e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3812, "upload_time": "2017-06-01T16:40:57", "url": "https://files.pythonhosted.org/packages/e4/95/3cd275e3500ddfe5bf12fdf3c7ac75bd72204f76981797785ced00c477a5/pytest-socket-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "467d0b56c7106432553c22c4f3025bc2", "sha256": "b25297375d32661219c6fd7913dc5a9bd9d6f422b404bd4acbfd36b26b0a1546" }, "downloads": -1, "filename": "pytest-socket-0.2.0.tar.gz", "has_sig": false, "md5_digest": "467d0b56c7106432553c22c4f3025bc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4156, "upload_time": "2017-07-15T12:37:40", "url": "https://files.pythonhosted.org/packages/7b/7c/75b6d7542cd883585b334bb2e6f1f80b04bce7f4398c3cc5522e607e0240/pytest-socket-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "7022af527cfd8df68c860de05ce042b9", "sha256": "b82ed132b5a8e9eacef6c6532ace93a37865ff873090459ca360da25a2c7e1aa" }, "downloads": -1, "filename": "pytest-socket-0.3.0.tar.gz", "has_sig": false, "md5_digest": "7022af527cfd8df68c860de05ce042b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4923, "upload_time": "2018-07-15T14:08:24", "url": "https://files.pythonhosted.org/packages/b6/35/77740db342367db69b41bce1eaba63b5881d60f816e3697237935225f6f5/pytest-socket-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "8d3652951ffb57dd6c64dc4685fb6890", "sha256": "bb0857c4a459b7ed4586c51b48ad99920ca82f3314c95ed6de84847c2a8b6eef" }, "downloads": -1, "filename": "pytest-socket-0.3.1.tar.gz", "has_sig": false, "md5_digest": "8d3652951ffb57dd6c64dc4685fb6890", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4920, "upload_time": "2018-07-16T11:46:01", "url": "https://files.pythonhosted.org/packages/c3/3f/a879ee90224e7b46482be0d9fd8abcc4030d800712707740cac5ac2d1326/pytest-socket-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "020d2e42db306c0408bba958f2e91d8c", "sha256": "7012782c865bfe3c7c397fa29753b7a83c482a1be5c43c8b6b3bcaeba794ef2a" }, "downloads": -1, "filename": "pytest-socket-0.3.2.tar.gz", "has_sig": false, "md5_digest": "020d2e42db306c0408bba958f2e91d8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4921, "upload_time": "2019-01-08T00:53:21", "url": "https://files.pythonhosted.org/packages/aa/cc/b9a9f7a992bcb6a48ed39aff057c1043f11bc7889ac84aea849530686c57/pytest-socket-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "5d3a96b1aff2d7a744ae2f002391d14c", "sha256": "a90401b7a6db7091add1e33fc94a29dae6b449fdc469a725bd7cea303d12a7ed" }, "downloads": -1, "filename": "pytest-socket-0.3.3.tar.gz", "has_sig": false, "md5_digest": "5d3a96b1aff2d7a744ae2f002391d14c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5001, "upload_time": "2019-02-09T18:29:25", "url": "https://files.pythonhosted.org/packages/20/ee/3baa774789ae1f998fe7795f09d06beb026189ca7846ac6d6662ec35c279/pytest-socket-0.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5d3a96b1aff2d7a744ae2f002391d14c", "sha256": "a90401b7a6db7091add1e33fc94a29dae6b449fdc469a725bd7cea303d12a7ed" }, "downloads": -1, "filename": "pytest-socket-0.3.3.tar.gz", "has_sig": false, "md5_digest": "5d3a96b1aff2d7a744ae2f002391d14c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5001, "upload_time": "2019-02-09T18:29:25", "url": "https://files.pythonhosted.org/packages/20/ee/3baa774789ae1f998fe7795f09d06beb026189ca7846ac6d6662ec35c279/pytest-socket-0.3.3.tar.gz" } ] }