diff --git a/.travis.yml b/.travis.yml index dff7eca..4f5e420 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,12 @@ language: python python: - - 2.6 - - 2.7 - - 3.4 - 3.5 - - pypy install: - - pip install coveralls --use-wheel + - pip install tox coveralls script: - - python setup.py develop - - coverage run --source=pytest_mock.py runtests.py + - tox after_success: - coveralls diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e017fdc..cc003ce 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,16 @@ +0.10.1 +------ + +* Fix regression in frozen tests due to ``distutils`` import dependency. + Thanks `@The-Compiler`_ for the report (`#29`_). + +* Fix regression when using ``pytest-mock`` with ``pytest-2.7.X``. + Thanks `@akscram`_ for the report (`#28`_). + +.. _@akscram: https://github.com/Chronial +.. _#28: https://github.com/pytest-dev/pytest-mock/issues/28 +.. _#29: https://github.com/pytest-dev/pytest-mock/issues/29 + 0.10 ---- @@ -6,8 +19,8 @@ Thanks to `@Chronial`_ for idea and PR (`#26`_, `#27`_)! .. _@Chronial: https://github.com/Chronial -.. _#26: https://github.com/pytest-dev/pytest-qt/issues/26 -.. _#27: https://github.com/pytest-dev/pytest-qt/issues/27 +.. _#26: https://github.com/pytest-dev/pytest-mock/issues/26 +.. _#27: https://github.com/pytest-dev/pytest-mock/issues/27 0.9.0 ----- diff --git a/appveyor.yml b/appveyor.yml index d8b9885..31aaa37 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ install: - - C:\Python34\python -m pip install tox + - C:\Python35\python -m pip install tox build: false # Not a C# project test_script: - - C:\Python34\scripts\tox -e py27,py34,py35 + - C:\Python35\scripts\tox diff --git a/pytest_mock.py b/pytest_mock.py index cc99e0f..99c2ad4 100644 --- a/pytest_mock.py +++ b/pytest_mock.py @@ -2,14 +2,14 @@ import sys import pytest -from distutils.util import strtobool if sys.version_info >= (3, 3): # pragma: no cover import unittest.mock as mock_module else: import mock as mock_module -version = '0.10.0' +version = '0.10.1' + class MockFixture(object): """ @@ -207,7 +207,13 @@ def wrap_assert_methods(config): mock_module.NonCallableMock, method, wrapper) patcher.start() _mock_module_patches.append(patcher) - config.add_cleanup(unwrap_assert_methods) + + if hasattr(config, 'add_cleanup'): + add_cleanup = config.add_cleanup + else: + # pytest 2.7 compatibility + add_cleanup = config._cleanup.append + add_cleanup(unwrap_assert_methods) def unwrap_assert_methods(): @@ -227,7 +233,10 @@ def pytest_addoption(parser): def parse_ini_boolean(value): if value in (True, False): return value - return bool(strtobool(value)) + try: + return {'true': True, 'false': False}[value.lower()] + except KeyError: + raise ValueError('unknown string for bool: %r' % value) def pytest_configure(config): diff --git a/runtests.py b/runtests.py deleted file mode 100644 index 02362ad..0000000 --- a/runtests.py +++ /dev/null @@ -1,3 +0,0 @@ -# simple pytest wrapper so we can execute it using "coverage run" -import pytest, sys -sys.exit(pytest.main()) diff --git a/setup.py b/setup.py index 4521335..aa726d0 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ py_modules=['pytest_mock'], platforms='any', install_requires=[ - 'pytest>=2.4', + 'pytest>=2.7', ], extras_require={ ':python_version=="2.6" or python_version=="2.7"': ['mock'], diff --git a/test_pytest_mock.py b/test_pytest_mock.py index d0516b2..60d2bbf 100644 --- a/test_pytest_mock.py +++ b/test_pytest_mock.py @@ -326,8 +326,11 @@ def test_foo(mocker): [pytest] mock_traceback_monkeypatch = false """) - - result = testdir.runpytest_subprocess() + if hasattr(testdir, 'runpytest_subprocess'): + result = testdir.runpytest_subprocess() + else: + # pytest 2.7.X + result = testdir.runpytest() assert result.ret == 0 diff --git a/tox.ini b/tox.ini index 37292da..dd1605a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,12 @@ [tox] # note that tox expects interpreters to be found at C:\PythonXY, # with XY being python version ("27" or "34") for instance -envlist = py26, py27, py34, py35 +envlist = py{26,27,34,35}-pytest{27,28} [testenv] -commands = py.test test_pytest_mock.py \ No newline at end of file +passenv = USER USERNAME +deps = + coverage + pytest27: pytest==2.7.3 + pytest28: pytest==2.8.7 +commands = coverage run --append --source=pytest_mock.py -m pytest test_pytest_mock.py