Hello community,
here is the log from the commit of package python-pytest-socket for
openSUSE:Factory checked in at 2020-04-14 15:11:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-socket (Old)
and /work/SRC/openSUSE:Factory/.python-pytest-socket.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-socket"
Tue Apr 14 15:11:32 2020 rev:2 rq:793783 version:0.3.4
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-pytest-socket/python-pytest-socket.changes
2019-07-23 22:44:55.610659540 +0200
+++
/work/SRC/openSUSE:Factory/.python-pytest-socket.new.2738/python-pytest-socket.changes
2020-04-14 16:32:16.512149334 +0200
@@ -1,0 +2,10 @@
+Tue Apr 14 09:06:47 UTC 2020 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.4.3:
+ * Drop support for unsupported versions of Python #23
+ * Convert toolchain from pip/tox/twine to poetry
+ * Replace TravisCI and Appveyor with GitHub Actions #36
+ * Update for correct test output #31
+ * Add renovatebot for dependecy updates #26
+
+-------------------------------------------------------------------
Old:
----
pytest-socket-0.3.3.tar.gz
New:
----
pytest-socket-0.3.4.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pytest-socket.spec ++++++
--- /var/tmp/diff_new_pack.bQQGzE/_old 2020-04-14 16:32:16.968149682 +0200
+++ /var/tmp/diff_new_pack.bQQGzE/_new 2020-04-14 16:32:16.972149685 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-pytest-socket
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,27 +12,27 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
+#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define skip_python2 1
Name: python-pytest-socket
-Version: 0.3.3
+Version: 0.3.4
Release: 0
-License: MIT
Summary: Pytest Plugin to disable socket
-Url: https://github.com/miketheman/pytest-socket
-Group: Development/Languages/Python
-Source:
https://github.com/miketheman/pytest-socket/archive/%{version}.tar.gz#/pytest-socket-%{version}.tar.gz
+License: MIT
+URL: https://github.com/miketheman/pytest-socket
+Source:
https://files.pythonhosted.org/packages/source/p/pytest-socket/pytest-socket-%{version}.tar.gz
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
+Requires: python-pytest >= 3.6.3
+BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module pytest >= 3.6.3}
# /SECTION
-Requires: python-pytest >= 3.6.3
-BuildArch: noarch
-
%python_subpackages
%description
@@ -49,8 +49,8 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
# Tests require a network connection
-# %%check
-# %%pytest
+#%%check
+#%%pytest
%files %{python_files}
%doc README.rst
++++++ pytest-socket-0.3.3.tar.gz -> pytest-socket-0.3.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/.codeclimate.yml
new/pytest-socket-0.3.4/.codeclimate.yml
--- old/pytest-socket-0.3.3/.codeclimate.yml 2019-02-09 19:20:35.000000000
+0100
+++ new/pytest-socket-0.3.4/.codeclimate.yml 1970-01-01 01:00:00.000000000
+0100
@@ -1,19 +0,0 @@
----
-plugins:
- duplication:
- enabled: true
- config:
- languages:
- - python
- fixme:
- enabled: true
- radon:
- enabled: true
-exclude_patterns:
-- "*.egg-info/"
-- .cache/
-- .tox/
-- __pycache__/
-- dist/
-- htmlcov/
-- tests/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/.editorconfig
new/pytest-socket-0.3.4/.editorconfig
--- old/pytest-socket-0.3.3/.editorconfig 2019-02-09 19:20:35.000000000
+0100
+++ new/pytest-socket-0.3.4/.editorconfig 1970-01-01 01:00:00.000000000
+0100
@@ -1,19 +0,0 @@
-# http://editorconfig.org
-
-root = true
-
-[*]
-indent_style = space
-insert_final_newline = true
-trim_trailing_whitespace = true
-end_of_line = lf
-charset = utf-8
-
-[*.py]
-indent_size = 4
-
-[*.yml]
-indent_size = 2
-
-[Makefile]
-indent_style = tab
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/.gitignore
new/pytest-socket-0.3.4/.gitignore
--- old/pytest-socket-0.3.3/.gitignore 2019-02-09 19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/.gitignore 1970-01-01 01:00:00.000000000 +0100
@@ -1,74 +0,0 @@
-# Byte-compiled / optimized / DLL files
-__pycache__/
-*.py[cod]
-*$py.class
-
-# C extensions
-*.so
-
-# Distribution / packaging
-.Python
-env/
-build/
-develop-eggs/
-dist/
-downloads/
-eggs/
-.eggs/
-lib/
-lib64/
-parts/
-sdist/
-var/
-*.egg-info/
-.installed.cfg
-*.egg
-
-# PyInstaller
-# Usually these files are written by a python script from a template
-# before PyInstaller builds the exe, so as to inject date/other infos into it.
-*.manifest
-*.spec
-
-# Installer logs
-pip-log.txt
-pip-delete-this-directory.txt
-
-# Unit test / coverage reports
-htmlcov/
-.tox/
-.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xml
-*,cover
-.hypothesis/
-
-# Translations
-*.mo
-*.pot
-
-# Django stuff:
-*.log
-local_settings.py
-
-# Flask instance folder
-instance/
-
-# Sphinx documentation
-docs/_build/
-
-# MkDocs documentation
-/site/
-
-# PyBuilder
-target/
-
-# IPython Notebook
-.ipynb_checkpoints
-
-# pyenv
-.python-version
-
-.pytest_cache/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/.travis.yml
new/pytest-socket-0.3.4/.travis.yml
--- old/pytest-socket-0.3.3/.travis.yml 2019-02-09 19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/.travis.yml 1970-01-01 01:00:00.000000000 +0100
@@ -1,51 +0,0 @@
-# Config file for automatic testing at travis-ci.org
-
-env:
- global:
- -
CC_TEST_REPORTER_ID=fc447195f19e98b977d2e7d2332d15528c51e91473505e61b9eb1cc402dd676a
-
-# Required for 3.7 for now. See
https://github.com/travis-ci/travis-ci/issues/9069#issuecomment-425720905
-sudo: required
-dist: xenial
-language: python
-
-python:
- - "2.7"
- - "3.4"
- - "3.5"
- - "3.6"
- - "3.7"
-matrix:
- include:
- - python: "3.6"
- env: TOXENV=coverage
- - python: "3.6"
- env: TOXENV=flake8
-
-install:
- - pip install tox-travis
-
-before_script:
- - if [ "$TOXENV" = "coverage" ]; then
- curl -L
https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
> ./cc-test-reporter;
- fi
- - if [ "$TOXENV" = "coverage" ]; then
- chmod +x ./cc-test-reporter;
- fi
- - if [ "$TOXENV" = "coverage" ]; then
- ./cc-test-reporter before-build;
- fi
-
-script:
- - tox -v
-
-after_script:
- - if [ "$TOXENV" = "coverage" ]; then
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT;
- fi
-
-before_cache:
- - rm -rf $HOME/.cache/pip/log
-cache:
- directories:
- - $HOME/.cache/pip
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/CHANGELOG.rst
new/pytest-socket-0.3.4/CHANGELOG.rst
--- old/pytest-socket-0.3.3/CHANGELOG.rst 2019-02-09 19:20:35.000000000
+0100
+++ new/pytest-socket-0.3.4/CHANGELOG.rst 1970-01-01 01:00:00.000000000
+0100
@@ -1,55 +0,0 @@
-=============
-pytest-socket
-=============
-
-This document records all notable changes to `pytest-socket
<https://pypi.python.org/pypi/pytest-socket>`_.
-This project attempts to adhere to `Semantic Versioning <http://semver.org/>`_.
-
-`0.3.3`_ (2019-02-09)
----------------------
-
-* Fix hostname check when unicode on Python 2.7.x #22
-
-`0.3.2`_ (2019-01-07)
----------------------
-
-* Update support for Pytest 4.1.x
-* Test package on Python 3.7.x
-* Stop testing on pypy
-
-`0.3.1`_ (2018-07-16)
----------------------
-
-* Update minimum required pytest version
-
-`0.3.0`_ (2018-07-15)
----------------------
-
-* Add support for allowing specific lists of hosts via IP Addresses
-* Change the inherited exception class in tests
-* Add codeclimate to travis output
-* Add coverage reporting
-* Drop support for Python 3.3
-
-`0.2.0`_ (2017-07-15)
----------------------
-
-* Reorganized API, requires explicit activation
-* Added Python 3.x compatibility
-* Added ``ini`` setting
-* Test all Python versions
-* Relax py.test version requirement
-
-
-`0.1.0`_ (2017-06-01)
----------------------
-
-* Initial public release
-
-
-.. _0.1.0: https://github.com/miketheman/pytest-socket/releases/tag/0.1.0
-.. _0.2.0: https://github.com/miketheman/pytest-socket/compare/0.1.0...0.2.0
-.. _0.3.0: https://github.com/miketheman/pytest-socket/compare/0.2.0...0.3.0
-.. _0.3.1: https://github.com/miketheman/pytest-socket/compare/0.3.0...0.3.1
-.. _0.3.2: https://github.com/miketheman/pytest-socket/compare/0.3.1...0.3.2
-.. _0.3.3: https://github.com/miketheman/pytest-socket/compare/0.3.2...0.3.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/MANIFEST.in
new/pytest-socket-0.3.4/MANIFEST.in
--- old/pytest-socket-0.3.3/MANIFEST.in 2019-02-09 19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/MANIFEST.in 1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-include LICENSE
-include README.rst
-
-recursive-exclude * __pycache__
-recursive-exclude * *.py[co]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/Makefile
new/pytest-socket-0.3.4/Makefile
--- old/pytest-socket-0.3.3/Makefile 2019-02-09 19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/Makefile 1970-01-01 01:00:00.000000000 +0100
@@ -1,25 +0,0 @@
-.PHONY: all clean test
-
-TOX := $(shell command -v tox 2> /dev/null)
-
-all: test
-
-clean:
- @find . -name \*.pyc -name __pycache__ -delete
- @rm -fr .cache/ .coverage* .pytest_cache/ .tox/ *.egg-info/ dist/
htmlcov/
-
-test:
-ifndef TOX
- $(error "tox is not available, run `pip install tox`")
-endif
- @tox
-
-build: clean
- @python setup.py sdist
-
-testrelease: build
- # Requires a `[pypitest]` section in ~/.pypirc
- @twine upload -r pypitest dist/*
-
-release: build
- @twine upload dist/*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/PKG-INFO
new/pytest-socket-0.3.4/PKG-INFO
--- old/pytest-socket-0.3.3/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
+++ new/pytest-socket-0.3.4/PKG-INFO 2020-04-11 01:11:21.589583900 +0200
@@ -0,0 +1,169 @@
+Metadata-Version: 2.1
+Name: pytest-socket
+Version: 0.3.4
+Summary: Pytest Plugin to disable socket calls during tests
+Home-page: https://pypi.org/project/pytest-socket/
+License: MIT
+Author: Mike Fiedler
+Author-email: [email protected]
+Requires-Python: >=3.5,<4.0
+Classifier: Development Status :: 4 - Beta
+Classifier: Framework :: Pytest
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Topic :: Software Development :: Testing
+Requires-Dist: pytest (>=3.6.3)
+Project-URL: Bug Tracker, https://github.com/miketheman/pytest-socket/issues
+Project-URL: Repository, https://github.com/miketheman/pytest-socket
+Description-Content-Type: text/x-rst
+
+=============
+pytest-socket
+=============
+
+.. image:: https://img.shields.io/pypi/v/pytest-socket.svg
+ :target: https://pypi.python.org/pypi/pytest-socket
+
+.. image:: https://img.shields.io/pypi/pyversions/pytest-socket.svg
+ :target: https://pypi.python.org/pypi/pytest-socket
+
+.. image::
https://github.com/miketheman/pytest-socket/workflows/Python%20Tests/badge.svg
+ :target:
https://github.com/miketheman/pytest-socket/actions?query=workflow%3A%22Python+Tests%22
+ :alt: Python Tests
+
+.. image::
https://api.codeclimate.com/v1/badges/1608a75b1c3a20211992/maintainability
+ :target:
https://codeclimate.com/github/miketheman/pytest-socket/maintainability
+ :alt: Maintainability
+
+.. image::
https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket.svg?type=shield
+ :target:
https://app.fossa.io/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket?ref=badge_shield
+ :alt: FOSSA Status
+
+
+A plugin to use with Pytest to disable or restrict ``socket`` calls during
tests to ensure network calls are prevented.
+
+----
+
+This `Pytest`_ plugin was generated with `Cookiecutter`_ along with
`@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template.
+
+
+Features
+--------
+
+* Disables all network calls flowing through Python's ``socket`` interface.
+
+
+Requirements
+------------
+
+* `Pytest`_ 3.6.3 or greater
+
+
+Installation
+------------
+
+You can install "pytest-socket" via `pip`_ from `PyPI`_::
+
+ $ pip install pytest-socket
+
+
+Usage
+-----
+
+* Run ``pytest --disable-socket``, tests should fail on any access to
``socket`` or libraries using
+ socket with a ``SocketBlockedError``.
+
+ To add this flag as the default behavior, add this section to your
``pytest.ini`` or ``setup.cfg``:
+
+ .. code:: ini
+
+ [pytest]
+ addopts = --disable-socket
+
+
+ or update your ``conftest.py`` to include:
+
+ .. code:: python
+
+ from pytest_socket import disable_socket
+
+ def pytest_runtest_setup():
+ disable_socket()
+
+
+* To enable specific tests use of ``socket``, pass in the fixture to the test
or use a marker:
+
+ .. code:: python
+
+ def test_explicitly_enable_socket(socket_enabled):
+ assert socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+
+ @pytest.mark.enable_socket
+ def test_explicitly_enable_socket_with_mark():
+ assert socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+* To allow only specific hosts per-test:
+
+ .. code:: python
+
+ @pytest.mark.allow_hosts(['127.0.0.1'])
+ def test_explicitly_enable_socket_with_mark():
+ assert socket.socket.connect(('127.0.0.1', 80))
+
+or for whole test run
+
+ .. code:: ini
+
+ [pytest]
+ addopts = --allow-hosts=127.0.0.1,127.0.1.1
+
+
+Contributing
+------------
+Contributions are very welcome. Tests can be run with `pytest`_, please ensure
+the coverage at least stays the same before you submit a pull request.
+
+License
+-------
+
+Distributed under the terms of the `MIT`_ license, "pytest-socket" is free and
open source software
+
+.. image::
https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket.svg?type=large
+ :target:
https://app.fossa.io/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket?ref=badge_large
+ :alt: FOSSA Status
+
+Issues
+------
+
+If you encounter any problems, please `file an issue`_ along with a detailed
description.
+
+
+References
+----------
+
+This plugin came about due to the efforts by `@hangtwenty`_ solving a
`StackOverflow question`_,
+then converted into a pytest plugin by `@miketheman`_.
+
+
+.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
+.. _`@hackebrot`: https://github.com/hackebrot
+.. _`MIT`: http://opensource.org/licenses/MIT
+.. _`cookiecutter-pytest-plugin`:
https://github.com/pytest-dev/cookiecutter-pytest-plugin
+.. _`file an issue`: https://github.com/miketheman/pytest-socket/issues
+.. _`pytest`: https://github.com/pytest-dev/pytest
+.. _`tox`: https://tox.readthedocs.io/en/latest/
+.. _`pip`: https://pypi.python.org/pypi/pip/
+.. _`PyPI`: https://pypi.python.org/pypi
+.. _`@hangtwenty`: https://github.com/hangtwenty
+.. _`StackOverflow question`: https://stackoverflow.com/a/30064664
+.. _`@miketheman`: https://github.com/miketheman
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/README.rst
new/pytest-socket-0.3.4/README.rst
--- old/pytest-socket-0.3.3/README.rst 2019-02-09 19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/README.rst 2020-04-10 23:59:18.202035700 +0200
@@ -8,18 +8,19 @@
.. image:: https://img.shields.io/pypi/pyversions/pytest-socket.svg
:target: https://pypi.python.org/pypi/pytest-socket
-.. image:: https://travis-ci.org/miketheman/pytest-socket.svg?branch=master
- :target: https://travis-ci.org/miketheman/pytest-socket
- :alt: See Build Status on Travis CI
-
-.. image::
https://ci.appveyor.com/api/projects/status/github/miketheman/pytest-socket?branch=master&svg=true
- :target:
https://ci.appveyor.com/project/miketheman/pytest-socket/branch/master
- :alt: See Build Status on AppVeyor
+.. image::
https://github.com/miketheman/pytest-socket/workflows/Python%20Tests/badge.svg
+ :target:
https://github.com/miketheman/pytest-socket/actions?query=workflow%3A%22Python+Tests%22
+ :alt: Python Tests
.. image::
https://api.codeclimate.com/v1/badges/1608a75b1c3a20211992/maintainability
:target:
https://codeclimate.com/github/miketheman/pytest-socket/maintainability
:alt: Maintainability
+.. image::
https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket.svg?type=shield
+ :target:
https://app.fossa.io/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket?ref=badge_shield
+ :alt: FOSSA Status
+
+
A plugin to use with Pytest to disable or restrict ``socket`` calls during
tests to ensure network calls are prevented.
----
@@ -101,7 +102,7 @@
Contributing
------------
-Contributions are very welcome. Tests can be run with `tox`_, please ensure
+Contributions are very welcome. Tests can be run with `pytest`_, please ensure
the coverage at least stays the same before you submit a pull request.
License
@@ -109,6 +110,9 @@
Distributed under the terms of the `MIT`_ license, "pytest-socket" is free and
open source software
+.. image::
https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket.svg?type=large
+ :target:
https://app.fossa.io/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket?ref=badge_large
+ :alt: FOSSA Status
Issues
------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/appveyor.yml
new/pytest-socket-0.3.4/appveyor.yml
--- old/pytest-socket-0.3.3/appveyor.yml 2019-02-09 19:20:35.000000000
+0100
+++ new/pytest-socket-0.3.4/appveyor.yml 1970-01-01 01:00:00.000000000
+0100
@@ -1,43 +0,0 @@
-# What Python version is installed where:
-# http://www.appveyor.com/docs/installed-software#python
-
-environment:
- matrix:
- - PYTHON: "C:\\Python27"
- TOX_ENV: "py27"
-
- - PYTHON: "C:\\Python34"
- TOX_ENV: "py34"
-
- - PYTHON: "C:\\Python35"
- TOX_ENV: "py35"
-
- - PYTHON: "C:\\Python36"
- TOX_ENV: "py36"
-
- - PYTHON: "C:\\Python37"
- TOX_ENV: "py37"
-
-init:
- - "%PYTHON%/python -V"
- - "%PYTHON%/python -c \"import struct;print( 8 * struct.calcsize(\'P\'))\""
-
-install:
- - "%PYTHON%/Scripts/easy_install -U pip"
- - "%PYTHON%/Scripts/pip install tox"
- - "%PYTHON%/Scripts/pip install wheel"
-
-build: false # Not a C# project, build stuff at the test step instead.
-
-test_script:
- - "%PYTHON%/Scripts/tox -v -e %TOX_ENV%"
-
-after_test:
- - "%PYTHON%/python setup.py bdist_wheel"
- - ps: "ls dist"
-
-artifacts:
- - path: dist\*
-
-#on_success:
-# - TODO: upload the content of dist/*.whl to a public wheelhouse
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/pyproject.toml
new/pytest-socket-0.3.4/pyproject.toml
--- old/pytest-socket-0.3.3/pyproject.toml 1970-01-01 01:00:00.000000000
+0100
+++ new/pytest-socket-0.3.4/pyproject.toml 2020-04-11 01:03:01.577754000
+0200
@@ -0,0 +1,47 @@
+[tool.poetry]
+name = "pytest-socket"
+version = "0.3.4"
+description = "Pytest Plugin to disable socket calls during tests"
+authors = ["Mike Fiedler <[email protected]>"]
+license = "MIT"
+readme = "README.rst"
+homepage = "https://pypi.org/project/pytest-socket/"
+repository = "https://github.com/miketheman/pytest-socket"
+include = [
+ "LICENSE",
+ "README.rst",
+]
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Framework :: Pytest",
+ "Intended Audience :: Developers",
+ "Topic :: Software Development :: Testing",
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 3.5",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: Implementation :: CPython",
+ "Operating System :: OS Independent",
+ "License :: OSI Approved :: MIT License",
+]
+
+[tool.poetry.dependencies]
+python = "^3.5"
+pytest = ">=3.6.3"
+
+[tool.poetry.dev-dependencies]
+pytest = "^5.4"
+pytest-cov = "^2.8.1"
+pytest-httpbin = "^1.0"
+pytest-flake8 = "^1.0.4"
+
+[tool.poetry.plugins.pytest11]
+socket = 'pytest_socket'
+
+[tool.poetry.urls]
+"Bug Tracker" = "https://github.com/miketheman/pytest-socket/issues"
+
+[build-system]
+requires = ["poetry>=0.12"]
+build-backend = "poetry.masonry.api"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/pytest_socket.py
new/pytest-socket-0.3.4/pytest_socket.py
--- old/pytest-socket-0.3.3/pytest_socket.py 2019-02-09 19:20:35.000000000
+0100
+++ new/pytest-socket-0.3.4/pytest_socket.py 2020-04-11 01:02:31.848008000
+0200
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
import socket
-import sys
import pytest
_true_socket = socket.socket
_true_connect = socket.socket.connect
-is_py2 = sys.version_info[0] == 2
class SocketBlockedError(RuntimeError):
@@ -108,20 +106,11 @@
return host
-def host_from_address_py2(address):
- host = address[0]
- if isinstance(host, str) or isinstance(host, unicode): # noqa F821
- return host
-
-
def host_from_connect_args(args):
address = args[0]
if isinstance(address, tuple):
- if is_py2:
- return host_from_address_py2(address)
- else:
- return host_from_address(address)
+ return host_from_address(address)
def socket_allow_hosts(allowed=None):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/setup.py
new/pytest-socket-0.3.4/setup.py
--- old/pytest-socket-0.3.3/setup.py 2019-02-09 19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/setup.py 2020-04-11 01:11:21.588532000 +0200
@@ -1,48 +1,29 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
-import os
-import codecs
from setuptools import setup
+modules = \
+['pytest_socket']
+install_requires = \
+['pytest>=3.6.3']
+
+entry_points = \
+{'pytest11': ['socket = pytest_socket']}
-def read(fname):
- file_path = os.path.join(os.path.dirname(__file__), fname)
- return codecs.open(file_path, encoding='utf-8').read()
+setup_kwargs = {
+ 'name': 'pytest-socket',
+ 'version': '0.3.4',
+ 'description': 'Pytest Plugin to disable socket calls during tests',
+ 'long_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://github.com/miketheman/pytest-socket/workflows/Python%20Tests/badge.svg\n
:target:
https://github.com/miketheman/pytest-socket/actions?query=workflow%3A%22Python+Tests%22\n
:alt: Python Tests\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\n.. image::
https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket.svg?type=shield\n
:target:
https://app.fossa.io/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket?ref=badge_shield\n
:alt: FOSSA Status\n\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 `pytest`_, 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.. image::
https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket.svg?type=large\n
:target:
https://app.fossa.io/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket?ref=badge_large\n
:alt: FOSSA Status\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\n',
+ 'author': 'Mike Fiedler',
+ 'author_email': '[email protected]',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'url': 'https://pypi.org/project/pytest-socket/',
+ 'py_modules': modules,
+ 'install_requires': install_requires,
+ 'entry_points': entry_points,
+ 'python_requires': '>=3.5,<4.0',
+}
-setup(
- name='pytest-socket',
- version='0.3.3',
- author='Mike Fiedler',
- author_email='[email protected]',
- maintainer='Mike Fiedler',
- maintainer_email='[email protected]',
- license='MIT',
- url='https://github.com/miketheman/pytest-socket',
- description='Pytest Plugin to disable socket calls during tests',
- long_description=read('README.rst'),
- py_modules=['pytest_socket'],
- install_requires=['pytest>=3.6.3'],
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'Framework :: Pytest',
- 'Intended Audience :: Developers',
- 'Topic :: Software Development :: Testing',
- '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',
- 'Operating System :: OS Independent',
- 'License :: OSI Approved :: MIT License',
- ],
- entry_points={
- 'pytest11': [
- 'socket = pytest_socket',
- ],
- },
-)
+setup(**setup_kwargs)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/tests/conftest.py
new/pytest-socket-0.3.4/tests/conftest.py
--- old/pytest-socket-0.3.3/tests/conftest.py 2019-02-09 19:20:35.000000000
+0100
+++ new/pytest-socket-0.3.4/tests/conftest.py 1970-01-01 01:00:00.000000000
+0100
@@ -1 +0,0 @@
-pytest_plugins = 'pytester'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/tests/test_restrict_hosts.py
new/pytest-socket-0.3.4/tests/test_restrict_hosts.py
--- old/pytest-socket-0.3.3/tests/test_restrict_hosts.py 2019-02-09
19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/tests/test_restrict_hosts.py 1970-01-01
01:00:00.000000000 +0100
@@ -1,247 +0,0 @@
-# -*- coding: utf-8 -*-
-import pytest
-
-try:
- from urllib.parse import urlparse
-except ImportError:
- from urlparse import urlparse
-
-import inspect
-
-
-localhost = '127.0.0.1'
-
-connect_code_template = """
- import socket
- import pytest
-
- {3}
- def {2}():
- socket.socket().connect(('{0}', {1}))
-"""
-
-connect_unicode_code_template = """
- import socket
- import pytest
-
- {3}
- def {2}():
- socket.socket().connect((u'{0}', {1}))
-"""
-
-# `contextlib` used because otherwise 2.7 was occasionally hanging due to
exception cases:
-urlopen_code_template = """
- import pytest
- import contextlib
- try:
- from urllib.request import urlopen
- except ImportError:
- from urllib2 import urlopen
-
- {3}
- def {2}():
- with contextlib.closing(urlopen('http://{0}:{1}/')) as x:
- assert x.getcode() == 200
-"""
-
-
-def assert_host_blocked(result, host):
- result.stdout.fnmatch_lines('*A test tried to use socket.socket.connect()
with host "{0}"*'.format(host))
-
-
[email protected]
-def assert_connect(httpbin, testdir):
- def assert_socket_connect(should_pass, **kwargs):
- # get the name of the calling function
- test_name = inspect.stack()[1][3]
- test_url = urlparse(httpbin.url)
-
- mark = ''
- cli_arg = kwargs.get('cli_arg', None)
- code_template = kwargs.get('code_template', connect_code_template)
- mark_arg = kwargs.get('mark_arg', None)
-
- if mark_arg and isinstance(mark_arg, str):
- mark = '@pytest.mark.allow_hosts("{0}")'.format(mark_arg)
- elif mark_arg and isinstance(mark_arg, list):
- mark =
'@pytest.mark.allow_hosts(["{0}"])'.format('","'.join(mark_arg))
- code = code_template.format(test_url.hostname, test_url.port,
test_name, mark)
- testdir.makepyfile(code)
-
- if cli_arg:
- result = testdir.runpytest("--verbose",
'--allow-hosts={0}'.format(cli_arg))
- else:
- result = testdir.runpytest("--verbose")
-
- if should_pass:
- result.assert_outcomes(1, 0, 0)
- else:
- result.assert_outcomes(0, 0, 1)
- assert_host_blocked(result, test_url.hostname)
- return assert_socket_connect
-
-
-def test_help_message(testdir):
- result = testdir.runpytest(
- '--help',
- )
- result.stdout.fnmatch_lines([
- 'socket:',
- '*--allow-hosts=ALLOWED_HOSTS_CSV',
- '*Only allow specified hosts through',
- '*socket.socket.connect((host, port)).'
- ])
-
-
-def test_marker_help_message(testdir):
- result = testdir.runpytest(
- '--markers',
- )
- result.stdout.fnmatch_lines([
- '@pytest.mark.allow_hosts([[]hosts[]]): Restrict socket connection to
defined list of hosts',
- ])
-
-
-def test_default_connect_enabled(assert_connect):
- assert_connect(True)
-
-
-def test_single_cli_arg_connect_enabled(assert_connect):
- assert_connect(True, cli_arg=localhost)
-
-
-def test_single_cli_arg_connect_unicode_enabled(assert_connect):
- assert_connect(True, cli_arg=localhost,
code_template=connect_unicode_code_template)
-
-
-def test_multiple_cli_arg_connect_enabled(assert_connect):
- assert_connect(True, cli_arg=localhost + ',1.2.3.4')
-
-
-def test_single_mark_arg_connect_enabled(assert_connect):
- assert_connect(True, mark_arg=localhost)
-
-
-def test_multiple_mark_arg_csv_connect_enabled(assert_connect):
- assert_connect(True, mark_arg=localhost + ',1.2.3.4')
-
-
-def test_multiple_mark_arg_list_connect_enabled(assert_connect):
- assert_connect(True, mark_arg=[localhost, '1.2.3.4'])
-
-
-def test_mark_cli_conflict_mark_wins_connect_enabled(assert_connect):
- assert_connect(True, mark_arg=[localhost], cli_arg='1.2.3.4')
-
-
-def test_single_cli_arg_connect_disabled(assert_connect):
- assert_connect(False, cli_arg='1.2.3.4',
code_template=connect_unicode_code_template)
-
-
-def test_multiple_cli_arg_connect_disabled(assert_connect):
- assert_connect(False, cli_arg='5.6.7.8,1.2.3.4')
-
-
-def test_single_mark_arg_connect_disabled(assert_connect):
- assert_connect(False, mark_arg='1.2.3.4')
-
-
-def test_multiple_mark_arg_csv_connect_disabled(assert_connect):
- assert_connect(False, mark_arg='5.6.7.8,1.2.3.4')
-
-
-def test_multiple_mark_arg_list_connect_disabled(assert_connect):
- assert_connect(False, mark_arg=['5.6.7.8', '1.2.3.4'])
-
-
-def test_mark_cli_conflict_mark_wins_connect_disabled(assert_connect):
- assert_connect(False, mark_arg=['1.2.3.4'], cli_arg=localhost)
-
-
-def test_default_urlopen_succeeds_by_default(assert_connect):
- assert_connect(True, code_template=urlopen_code_template)
-
-
-def test_single_cli_arg_urlopen_enabled(assert_connect):
- assert_connect(True, cli_arg=localhost + ',1.2.3.4',
code_template=urlopen_code_template)
-
-
-def test_single_mark_arg_urlopen_enabled(assert_connect):
- assert_connect(True, mark_arg=[localhost, '1.2.3.4'],
code_template=urlopen_code_template)
-
-
-def test_global_restrict_via_config_fail(testdir):
- testdir.makepyfile("""
- import socket
-
- def test_global_restrict_via_config_fail():
- socket.socket().connect(('127.0.0.1', 80))
- """)
- testdir.makeini("""
- [pytest]
- addopts = --allow-hosts=2.2.2.2
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(0, 0, 1)
- assert_host_blocked(result, '127.0.0.1')
-
-
-def test_global_restrict_via_config_pass(testdir, httpbin):
- test_url = urlparse(httpbin.url)
- testdir.makepyfile("""
- import socket
-
- def test_global_restrict_via_config_pass():
- socket.socket().connect(('{0}', {1}))
- """.format(test_url.hostname, test_url.port))
- testdir.makeini("""
- [pytest]
- addopts = --allow-hosts={0}
- """.format(test_url.hostname))
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(1, 0, 0)
-
-
-def test_test_isolation(testdir, httpbin):
- test_url = urlparse(httpbin.url)
- testdir.makepyfile("""
- import pytest
- import socket
-
- @pytest.mark.allow_hosts('{0}')
- def test_pass():
- socket.socket().connect(('{0}', {1}))
-
- @pytest.mark.allow_hosts('2.2.2.2')
- def test_fail():
- socket.socket().connect(('{0}', {1}))
-
- def test_pass_2():
- socket.socket().connect(('{0}', {1}))
- """.format(test_url.hostname, test_url.port))
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(2, 0, 1)
- assert_host_blocked(result, test_url.hostname)
-
-
-def test_conflicting_cli_vs_marks(testdir, httpbin):
- test_url = urlparse(httpbin.url)
- testdir.makepyfile("""
- import pytest
- import socket
-
- @pytest.mark.allow_hosts('{0}')
- def test_pass():
- socket.socket().connect(('{0}', {1}))
-
- @pytest.mark.allow_hosts('2.2.2.2')
- def test_fail():
- socket.socket().connect(('{0}', {1}))
-
- def test_fail_2():
- socket.socket().connect(('2.2.2.2', {1}))
- """.format(test_url.hostname, test_url.port))
- result = testdir.runpytest("--verbose", '--allow-hosts=1.2.3.4')
- result.assert_outcomes(1, 0, 2)
- assert_host_blocked(result, '2.2.2.2')
- assert_host_blocked(result, test_url.hostname)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/tests/test_socket.py
new/pytest-socket-0.3.4/tests/test_socket.py
--- old/pytest-socket-0.3.3/tests/test_socket.py 2019-02-09
19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/tests/test_socket.py 1970-01-01
01:00:00.000000000 +0100
@@ -1,219 +0,0 @@
-# -*- coding: utf-8 -*-
-import pytest
-
-from pytest_socket import enable_socket
-
-
[email protected](autouse=True)
-def reenable_socket():
- # The tests can leave the socket disabled in the global scope.
- # Fix that by automatically re-enabling it after each test
- yield
- enable_socket()
-
-
-def assert_socket_blocked(result):
- result.stdout.fnmatch_lines("""
- *SocketBlockedError: A test tried to use socket.socket.*
- """)
-
-
-def test_socket_enabled_by_default(testdir):
- testdir.makepyfile("""
- import socket
-
- def test_socket():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(1, 0, 0)
- with pytest.raises(BaseException):
- assert_socket_blocked(result)
-
-
-def test_global_disable_via_fixture(testdir):
- testdir.makepyfile("""
- import pytest
- import pytest_socket
- import socket
-
- @pytest.fixture(autouse=True)
- def disable_socket_for_all():
- pytest_socket.disable_socket()
-
- def test_socket():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(0, 0, 1)
- assert_socket_blocked(result)
-
-
-def test_global_disable_via_cli_flag(testdir):
- testdir.makepyfile("""
- import socket
-
- def test_socket():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose", "--disable-socket")
- result.assert_outcomes(0, 0, 1)
- assert_socket_blocked(result)
-
-
-def test_help_message(testdir):
- result = testdir.runpytest(
- '--help',
- )
- result.stdout.fnmatch_lines([
- 'socket:',
- '*--disable-socket*Disable socket.socket by default to block network'
- ])
-
-
-def test_global_disable_via_config(testdir):
- testdir.makepyfile("""
- import socket
-
- def test_socket():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- testdir.makeini("""
- [pytest]
- addopts = --disable-socket
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(0, 0, 1)
- assert_socket_blocked(result)
-
-
-def test_disable_socket_marker(testdir):
- testdir.makepyfile("""
- import pytest
- import socket
-
- @pytest.mark.disable_socket
- def test_socket():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(0, 0, 1)
- assert_socket_blocked(result)
-
-
-def test_enable_socket_marker(testdir):
- testdir.makepyfile("""
- import pytest
- import socket
-
- @pytest.mark.enable_socket
- def test_socket():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose", "--disable-socket")
- result.assert_outcomes(0, 0, 1)
- assert_socket_blocked(result)
-
-
-def test_urllib_succeeds_by_default(testdir):
- testdir.makepyfile("""
- try:
- from urllib.request import urlopen
- except ImportError:
- from urllib2 import urlopen
-
- def test_disable_socket_urllib():
- assert urlopen('http://httpbin.org/get').getcode() == 200
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(1, 0, 0)
-
-
-def test_enabled_urllib_succeeds(testdir):
- testdir.makepyfile("""
- import pytest
- import pytest_socket
- try:
- from urllib.request import urlopen
- except ImportError:
- from urllib2 import urlopen
-
- @pytest.mark.enable_socket
- def test_disable_socket_urllib():
- assert urlopen('http://httpbin.org/get').getcode() == 200
- """)
- result = testdir.runpytest("--verbose", "--disable-socket")
- result.assert_outcomes(0, 0, 1)
- assert_socket_blocked(result)
-
-
-def test_disabled_urllib_fails(testdir):
- testdir.makepyfile("""
- import pytest
- try:
- from urllib.request import urlopen
- except ImportError:
- from urllib2 import urlopen
-
- @pytest.mark.disable_socket
- def test_disable_socket_urllib():
- assert urlopen('http://httpbin.org/get').getcode() == 200
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(0, 0, 1)
- assert_socket_blocked(result)
-
-
-def test_double_call_does_nothing(testdir):
- testdir.makepyfile("""
- import pytest
- import pytest_socket
- import socket
-
- def test_double_enabled():
- pytest_socket.enable_socket()
- pytest_socket.enable_socket()
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-
- def test_double_disabled():
- pytest_socket.disable_socket()
- pytest_socket.disable_socket()
- with pytest.raises(pytest_socket.SocketBlockedError):
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-
- def test_disable_enable():
- pytest_socket.disable_socket()
- pytest_socket.enable_socket()
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(3, 0, 0)
- with pytest.raises(BaseException):
- assert_socket_blocked(result)
-
-
-def test_socket_enabled_fixture(testdir, socket_enabled):
- testdir.makepyfile("""
- import socket
- def test_socket_enabled(socket_enabled):
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose")
- result.assert_outcomes(1, 0, 0)
- with pytest.raises(BaseException):
- assert_socket_blocked(result)
-
-
-def test_mix_and_match(testdir, socket_enabled):
- testdir.makepyfile("""
- import socket
-
- def test_socket1():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- def test_socket_enabled(socket_enabled):
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- def test_socket2():
- socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- """)
- result = testdir.runpytest("--verbose", "--disable-socket")
- result.assert_outcomes(1, 0, 2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-socket-0.3.3/tox.ini
new/pytest-socket-0.3.4/tox.ini
--- old/pytest-socket-0.3.3/tox.ini 2019-02-09 19:20:35.000000000 +0100
+++ new/pytest-socket-0.3.4/tox.ini 1970-01-01 01:00:00.000000000 +0100
@@ -1,35 +0,0 @@
-# For more information about tox, see https://tox.readthedocs.io/en/latest/
-[tox]
-envlist = py27,py34,py35,py36,py37,flake8,coverage
-
-
-[testenv]
-deps =
- pytest
- pytest-httpbin
-commands = pytest {posargs:tests}
-
-[testenv:flake8]
-basepython = python3.6
-deps = flake8
-skip_install = true
-commands = flake8 pytest_socket.py setup.py tests
-
-[flake8]
-exclude = .direnv,.git,.tox
-max-complexity = 10
-max-line-length = 160
-
-[testenv:coverage]
-basepython = python3.6
-deps =
- {[testenv]deps}
- coverage
-commands = coverage erase
- coverage run {envbindir}/pytest {posargs:tests}
- coverage report
- coverage xml
-
-[coverage:report]
-include = *pytest_socket*
-omit = *tests*