From cde0d28bf2e55bc7fc80c8846e924243561c418f Mon Sep 17 00:00:00 2001 From: Ghislain Antony Vaillant Date: Mon, 5 Mar 2018 22:30:36 +0000 Subject: [PATCH] New upstream version 1.7.1 --- .gitignore | 4 ++++ .travis.yml | 38 ++++++++++++++++--------------- CHANGELOG.rst | 29 +++++++++++++++++++++++ PKG-INFO | 28 +++++++++++++++-------- README.rst | 19 +++++++++++----- _pytest_mock_version.py | 2 +- pytest_mock.egg-info/PKG-INFO | 28 +++++++++++++++-------- pytest_mock.egg-info/requires.txt | 2 +- setup.py | 11 ++++----- test_pytest_mock.py | 20 ++++++++++++++-- tox.ini | 13 +++++++---- 11 files changed, 136 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index da57959..9874ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ htmlcov/ .tox/ .coverage .cache +.pytest_cache nosetests.xml coverage.xml @@ -56,3 +57,6 @@ docs/_build/ .env* _pytest_mock_version.py + +# IDE +.idea diff --git a/.travis.yml b/.travis.yml index 5f88103..dcb02b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,10 @@ language: python python: - - "2.6" - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" -matrix: - include: - - python: '3.6' - env: TOXENV=linting - install: - pip install tox-travis coveralls @@ -21,14 +14,23 @@ script: after_success: - coveralls -deploy: - provider: pypi - user: nicoddemus - skip_upload_docs: true - distributions: sdist bdist_wheel - password: - secure: OEWrbk09CZRrwFE6sBpRqQHu45zRu1S0Ly1ZeprkFCKxMd9tZOnrYM5qxCDQXxFHIvuyajuJ+qWTOgxUvurQMNsD6DbvJKTJ0R8upH1b1Q95KK8xiJFedhqBEUga5GrInK59oo0Sgblse2jtH5NnHXRUClSdT+iHdLY5sljCTRg= - on: - tags: true - repo: pytest-dev/pytest-mock - condition: $TRAVIS_PYTHON_VERSION = 3.6 +jobs: + include: + - python: '3.6' + env: TOXENV=linting + - python: '3.6' + env: TOXENV=norewrite + - stage: deploy + python: '3.6' + install: pip install -U setuptools setuptools_scm + script: skip + deploy: + provider: pypi + user: nicoddemus + skip_upload_docs: true + distributions: sdist bdist_wheel + password: + secure: OEWrbk09CZRrwFE6sBpRqQHu45zRu1S0Ly1ZeprkFCKxMd9tZOnrYM5qxCDQXxFHIvuyajuJ+qWTOgxUvurQMNsD6DbvJKTJ0R8upH1b1Q95KK8xiJFedhqBEUga5GrInK59oo0Sgblse2jtH5NnHXRUClSdT+iHdLY5sljCTRg= + on: + tags: true + repo: pytest-dev/pytest-mock diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9b7945f..f044847 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,32 @@ +1.7.1 +----- + +* Fix ``setup.py`` to correctly read the ``README.rst``. Thanks `@ghisvail`_ for the fix (`#107`_). + +.. _#107: https://github.com/pytest-dev/pytest-mock/issues/107 + +1.7.0 +----- + +**Incompatible change** + +* ``pytest-mock`` no longer supports Python 2.6 and Python 3.3, following the lead of + ``pytest`` and other projects in the community. Thanks `@hugovk`_ for the PR (`#96`_). + +**Packaging** + +* Fix ``mock`` requirement in Python 2. Thanks `@ghisvail`_ for the report (`#101`_). + +**Internal** + +* Some tests in ``pytest-mock``'s suite are skipped if assertion rewriting is disabled (`#102`_). + +.. _@ghisvail: https://github.com/ghisvail +.. _@hugovk: https://github.com/hugovk +.. _#96: https://github.com/pytest-dev/pytest-mock/pull/96 +.. _#101: https://github.com/pytest-dev/pytest-mock/issues/101 +.. _#102: https://github.com/pytest-dev/pytest-mock/issues/102 + 1.6.3 ----- diff --git a/PKG-INFO b/PKG-INFO index e4952bd..af7d0e3 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,11 +1,12 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: pytest-mock -Version: 1.6.3 +Version: 1.7.1 Summary: Thin-wrapper around the mock package for easier use with py.test Home-page: https://github.com/pytest-dev/pytest-mock/ Author: Bruno Oliveira Author-email: nicoddemus@gmail.com License: MIT +Description-Content-Type: UNKNOWN Description: =========== pytest-mock =========== @@ -52,6 +53,13 @@ Description: =========== .. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg :target: https://pypi.python.org/pypi/pytest-mock/ + + + .. image:: http://www.opensourcecitizen.org/badge?url=github.com/pytest-dev/pytest-mock + :target: http://www.opensourcecitizen.org/project?url=github.com/pytest-dev/pytest-mock + + If you found this library useful, donate some CPU cycles to its + development efforts by clicking above. Thank you! 😇 Usage ===== @@ -161,10 +169,10 @@ Description: =========== E Right contains more items: E {'bar': 4} E Use -v to get the full diff - - - test_foo.py:6: AssertionError - ========================== 1 failed in 0.03 seconds =========================== + + + test_foo.py:6: AssertionError + ========================== 1 failed in 0.03 seconds =========================== This is useful when asserting mock calls with many/nested arguments and trying @@ -199,14 +207,14 @@ Description: =========== mock_use_standalone_module = true This will force the plugin to import ``mock`` instead of the ``unittest.mock`` module bundled with - Python 3.3+. Note that this option is only used in Python 3+, as Python 2 users only have the option + Python 3.4+. Note that this option is only used in Python 3+, as Python 2 users only have the option to use the ``mock`` package from PyPI anyway. Requirements ============ - * Python 2.6+, Python 3.3+ + * Python 2.7, Python 3.4+ * pytest * mock (for Python 2) @@ -337,11 +345,11 @@ Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Software Development :: Testing +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* diff --git a/README.rst b/README.rst index 691c2ca..6cd721e 100644 --- a/README.rst +++ b/README.rst @@ -44,6 +44,13 @@ of a test: .. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg :target: https://pypi.python.org/pypi/pytest-mock/ + + +.. image:: http://www.opensourcecitizen.org/badge?url=github.com/pytest-dev/pytest-mock + :target: http://www.opensourcecitizen.org/project?url=github.com/pytest-dev/pytest-mock + +If you found this library useful, donate some CPU cycles to its +development efforts by clicking above. Thank you! 😇 Usage ===== @@ -153,10 +160,10 @@ diff:: E Right contains more items: E {'bar': 4} E Use -v to get the full diff - - -test_foo.py:6: AssertionError -========================== 1 failed in 0.03 seconds =========================== + + + test_foo.py:6: AssertionError + ========================== 1 failed in 0.03 seconds =========================== This is useful when asserting mock calls with many/nested arguments and trying @@ -191,14 +198,14 @@ than the one that comes with the Python distribution. mock_use_standalone_module = true This will force the plugin to import ``mock`` instead of the ``unittest.mock`` module bundled with -Python 3.3+. Note that this option is only used in Python 3+, as Python 2 users only have the option +Python 3.4+. Note that this option is only used in Python 3+, as Python 2 users only have the option to use the ``mock`` package from PyPI anyway. Requirements ============ -* Python 2.6+, Python 3.3+ +* Python 2.7, Python 3.4+ * pytest * mock (for Python 2) diff --git a/_pytest_mock_version.py b/_pytest_mock_version.py index 33686e7..840ad41 100644 --- a/_pytest_mock_version.py +++ b/_pytest_mock_version.py @@ -1,4 +1,4 @@ # coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control -version = '1.6.3' +version = '1.7.1' diff --git a/pytest_mock.egg-info/PKG-INFO b/pytest_mock.egg-info/PKG-INFO index e4952bd..af7d0e3 100644 --- a/pytest_mock.egg-info/PKG-INFO +++ b/pytest_mock.egg-info/PKG-INFO @@ -1,11 +1,12 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: pytest-mock -Version: 1.6.3 +Version: 1.7.1 Summary: Thin-wrapper around the mock package for easier use with py.test Home-page: https://github.com/pytest-dev/pytest-mock/ Author: Bruno Oliveira Author-email: nicoddemus@gmail.com License: MIT +Description-Content-Type: UNKNOWN Description: =========== pytest-mock =========== @@ -52,6 +53,13 @@ Description: =========== .. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg :target: https://pypi.python.org/pypi/pytest-mock/ + + + .. image:: http://www.opensourcecitizen.org/badge?url=github.com/pytest-dev/pytest-mock + :target: http://www.opensourcecitizen.org/project?url=github.com/pytest-dev/pytest-mock + + If you found this library useful, donate some CPU cycles to its + development efforts by clicking above. Thank you! 😇 Usage ===== @@ -161,10 +169,10 @@ Description: =========== E Right contains more items: E {'bar': 4} E Use -v to get the full diff - - - test_foo.py:6: AssertionError - ========================== 1 failed in 0.03 seconds =========================== + + + test_foo.py:6: AssertionError + ========================== 1 failed in 0.03 seconds =========================== This is useful when asserting mock calls with many/nested arguments and trying @@ -199,14 +207,14 @@ Description: =========== mock_use_standalone_module = true This will force the plugin to import ``mock`` instead of the ``unittest.mock`` module bundled with - Python 3.3+. Note that this option is only used in Python 3+, as Python 2 users only have the option + Python 3.4+. Note that this option is only used in Python 3+, as Python 2 users only have the option to use the ``mock`` package from PyPI anyway. Requirements ============ - * Python 2.6+, Python 3.3+ + * Python 2.7, Python 3.4+ * pytest * mock (for Python 2) @@ -337,11 +345,11 @@ Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Software Development :: Testing +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* diff --git a/pytest_mock.egg-info/requires.txt b/pytest_mock.egg-info/requires.txt index 79ee644..c7e509c 100644 --- a/pytest_mock.egg-info/requires.txt +++ b/pytest_mock.egg-info/requires.txt @@ -1,4 +1,4 @@ pytest>=2.7 -[:python_version=="2.6" or python_version=="2.7"] +[:python_version < "3.0"] mock diff --git a/setup.py b/setup.py index 15a347e..cc3e87b 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ from setuptools import setup +from io import open setup( name='pytest-mock', @@ -8,12 +9,11 @@ setup( }, py_modules=['pytest_mock', '_pytest_mock_version'], platforms='any', + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', install_requires=[ 'pytest>=2.7', + 'mock;python_version<"3.0"', ], - extras_require={ - ':python_version=="2.6" or python_version=="2.7"': ['mock'], - }, use_scm_version={'write_to': '_pytest_mock_version.py'}, setup_requires=['setuptools_scm'], url='https://github.com/pytest-dev/pytest-mock/', @@ -21,7 +21,7 @@ setup( author='Bruno Oliveira', author_email='nicoddemus@gmail.com', description='Thin-wrapper around the mock package for easier use with py.test', - long_description=open('README.rst').read(), + long_description=open('README.rst', encoding='utf-8').read(), keywords="pytest mock", classifiers=[ 'Development Status :: 5 - Production/Stable', @@ -29,10 +29,9 @@ setup( 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', diff --git a/test_pytest_mock.py b/test_pytest_mock.py index ec2cf73..f3d65d5 100644 --- a/test_pytest_mock.py +++ b/test_pytest_mock.py @@ -13,6 +13,19 @@ skip_pypy = pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='could not make work on pypy') +@pytest.fixture +def needs_assert_rewrite(pytestconfig): + """ + Fixture which skips requesting test if assertion rewrite is disabled (#102) + + Making this a fixture to avoid acessing pytest's config in the global context. + """ + option = pytestconfig.getoption('assertmode') + if option != 'rewrite': + pytest.skip('this test needs assertion rewrite to work but current option ' + 'is "{}"'.format(option)) + + class UnixFS(object): """ Wrapper to os functions to simulate a Unix file system, used for testing @@ -348,8 +361,8 @@ def assert_argument_introspection(left, right): raise AssertionError("DID NOT RAISE") -@pytest.mark.skipif(sys.version_info[:2] in [(3, 3), (3, 4)], - reason="assert_not_called not available in python 3.3 and 3.4") +@pytest.mark.skipif(sys.version_info[:2] == (3, 4), + reason="assert_not_called not available in Python 3.4") def test_assert_not_called_wrapper(mocker): stub = mocker.stub() stub.assert_not_called() @@ -375,6 +388,7 @@ def test_assert_called_once_with_wrapper(mocker): stub.assert_called_once_with("foo") +@pytest.mark.usefixtures('needs_assert_rewrite') def test_assert_called_args_with_introspection(mocker): stub = mocker.stub() @@ -390,6 +404,7 @@ def test_assert_called_args_with_introspection(mocker): stub.assert_called_once_with(*wrong_args) +@pytest.mark.usefixtures('needs_assert_rewrite') def test_assert_called_kwargs_with_introspection(mocker): stub = mocker.stub() @@ -510,6 +525,7 @@ def runpytest_subprocess(testdir, *args): return testdir.runpytest(*args) +@pytest.mark.usefixtures('needs_assert_rewrite') def test_detailed_introspection(testdir): """Check that the "mock_use_standalone" is being used. """ diff --git a/tox.ini b/tox.ini index b07603b..e424f6b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,22 @@ [tox] -envlist = py{26,27,33,34,35,36}-pytest{27,28,29,30},linting +envlist = py{27,34,35,36}-pytest{30,31,32,33,34},linting,norewrite [testenv] passenv = USER USERNAME deps = coverage - pytest27: pytest~=2.7 - pytest28: pytest~=2.8 - pytest29: pytest~=2.9 pytest30: pytest~=3.0 + pytest31: pytest~=3.1 + pytest32: pytest~=3.2 + pytest33: pytest~=3.3 + pytest34: pytest~=3.4 commands = coverage run --append --source=pytest_mock.py -m pytest test_pytest_mock.py +[testenv:norewrite] +commands = + pytest test_pytest_mock.py --assert=plain -ra + [testenv:linting] skip_install=True deps =