Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for python 3.6a #64

Merged
merged 1 commit into from
Sep 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't make this MockFixture an old-style class on Python 2? Is that intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right. I tried that first as a fix and forgot to revert it.

On the other hand being an old-style class doesn't really matter for MockFixture because it doesn't have any comparison operators or meta-classes, which is where old-style and new-style classes differ. Do you rather me revert that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that, as I have no idea how an old-style class works, and I'm sure I'm not the only one 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But apparently @nicoddemus knows how they work and that it does not matter in this case.
Makes the code cleaner, too - so I am +1 for keeping it like this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is good btw to forget about old-style things.. ;)
We have tests for catching that hopefully.. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except that maybe @nicoddemus isn't the only one working on that code 😉

And I agree about forgetting about old-style things, that's why it should be a new-style class 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@The-Compiler
Well:

% git shortlog -sn
122 Bruno Oliveira
4 Rafael Bertoldi (fogo)
3 Jurko Gospodnetić
2 Florian Bruhin
2 Pavel Savchenko
2 Tiago Nobrega
2 jhermann

;)

But it's under the pytest-dev umbrella of course, so you are right in that regard.

new-style classes however are only relevant for py2, and I was disregarding this by ignoring old-style things.. ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since @The-Compiler prefers to bring it back, no worries! Pushed 931785c. 😁

"""
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