Skip to content

Commit

Permalink
Merge pull request #64 from nicoddemus/travis-py36
Browse files Browse the repository at this point in the history
Fix for python 3.6a
  • Loading branch information
nicoddemus authored Sep 17, 2016
2 parents 5416c11 + 1eb1f9f commit 0d36254
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
---

Expand Down
9 changes: 6 additions & 3 deletions pytest_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
)
17 changes: 8 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0d36254

Please sign in to comment.