From 1eb1f9fa0c3ccd4ceea73e67b42c0c78578ee78c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 17 Sep 2016 17:46:21 -0300 Subject: [PATCH] Fix support for python 3.6 Fix #59 --- .travis.yml | 6 ++++-- CHANGELOG.rst | 8 ++++++++ pytest_mock.py | 9 ++++++--- setup.py | 1 + tox.ini | 17 ++++++++--------- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f5e420..8ab05e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,14 @@ language: python python: - - 3.5 + - "3.5" + - "nightly" install: - pip install tox coveralls script: - - tox + - if [[ $TRAVIS_PYTHON_VERSION != nightly ]]; then tox; fi + - if [[ $TRAVIS_PYTHON_VERSION == nightly ]]; then tox -e py36-pytest28,py36-pytest29,py36-pytest30; fi after_success: - coveralls diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 60198c8..0883e42 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,11 @@ +1.3 +--- + +* Add support for Python 3.6. Thanks `@hackebrot`_ for the report (`#59`_). + +.. _@hackebrot: https://github.com/hackebrot +.. _#59: https://github.com/pytest-dev/pytest-mock/issues/59 + 1.2 --- diff --git a/pytest_mock.py b/pytest_mock.py index 457349e..a36bace 100644 --- a/pytest_mock.py +++ b/pytest_mock.py @@ -10,7 +10,7 @@ version = '1.2' -class MockFixture(object): +class MockFixture: """ Fixture that provides the same interface to functions in the mock module, ensuring that they are uninstalled at the end of each test. @@ -21,12 +21,15 @@ class MockFixture(object): PropertyMock = mock_module.PropertyMock call = mock_module.call ANY = mock_module.ANY - sentinel = mock_module.sentinel + def __init__(self): self._patches = [] # list of mock._patch objects self._mocks = [] # list of MagicMock objects self.patch = self._Patcher(self._patches, self._mocks) + # temporary fix: this should be at class level, but is blowing + # up in Python 3.6 + self.sentinel = mock_module.sentinel def resetall(self): """ @@ -213,7 +216,7 @@ def wrap_assert_methods(config): for method, wrapper in wrappers.items(): try: original = getattr(mock_module.NonCallableMock, method) - except AttributeError: + except AttributeError: # pragma: no cover continue _mock_module_originals[method] = original patcher = mock_module.patch.object( diff --git a/setup.py b/setup.py index 60d093b..d2e0036 100644 --- a/setup.py +++ b/setup.py @@ -40,6 +40,7 @@ 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Topic :: Software Development :: Testing', ] ) diff --git a/tox.ini b/tox.ini index 5e90937..1a56cfa 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,17 @@ [tox] -# note that tox expects interpreters to be found at C:\PythonXY, -# with XY being python version ("27" or "34") for instance -envlist = py{26,27,33,34,35}-pytest{27,28,30},linting +envlist = py{26,27,33,34,35}-pytest{27,28,29,30},linting [testenv] passenv = USER USERNAME deps = coverage - pytest27: pytest==2.7.3 - pytest28: pytest==2.8.7 - # temporary until pytest-dev/pytest#1935 is merged - pytest30: git+https://github.com/nicoddemus/pytest@assert-rewrite-dev-plugins -commands = coverage run --append --source=pytest_mock.py -m pytest test_pytest_mock.py - + pytest27: pytest~=2.7 + pytest28: pytest~=2.8 + pytest29: pytest~=2.9 + # temporary until 3.0.3 is released + pytest30: git+https://github.com/pytest-dev/pytest@master +commands = + coverage run --append --source=pytest_mock.py -m pytest test_pytest_mock.py [testenv:linting] basepython = python3.5