diff --git a/.gitignore b/.gitignore index fe89362..c9310dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +.python-version .tox .eggs *.egg diff --git a/setup.py b/setup.py index 3e71c30..f968fc9 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) # noqa import flake8 -tests_require = ['mock >= 2.0.0', 'pytest'] +tests_require = ['pytest'] requires = [ "pyflakes >= 0.8.1, != 1.2.0, != 1.2.1, != 1.2.2, < 1.4.0", @@ -20,6 +20,9 @@ requires = [ "mccabe >= 0.5.0, < 0.6.0", ] +if sys.version_info < (3, 5): + tests_require.append('mock >= 2.0.0') + if sys.version_info < (3, 4): requires.append("enum34") diff --git a/tests/integration/test_checker.py b/tests/integration/test_checker.py index 1b8a3c5..73286a8 100644 --- a/tests/integration/test_checker.py +++ b/tests/integration/test_checker.py @@ -1,5 +1,8 @@ """Integration tests for the checker submodule.""" -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import checker diff --git a/tests/unit/test_application.py b/tests/unit/test_application.py index 6a3ef91..131592c 100644 --- a/tests/unit/test_application.py +++ b/tests/unit/test_application.py @@ -1,7 +1,10 @@ """Tests for the Application class.""" import optparse -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8.main import application as app diff --git a/tests/unit/test_base_formatter.py b/tests/unit/test_base_formatter.py index bb54358..0ae23f7 100644 --- a/tests/unit/test_base_formatter.py +++ b/tests/unit/test_base_formatter.py @@ -1,7 +1,10 @@ """Tests for the BaseFormatter object.""" import optparse -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import style_guide diff --git a/tests/unit/test_checker_manager.py b/tests/unit/test_checker_manager.py index e5562ef..0456c0e 100644 --- a/tests/unit/test_checker_manager.py +++ b/tests/unit/test_checker_manager.py @@ -1,7 +1,10 @@ """Tests for the Manager object for FileCheckers.""" import errno -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import checker diff --git a/tests/unit/test_config_file_finder.py b/tests/unit/test_config_file_finder.py index 3f321da..82c1fb9 100644 --- a/tests/unit/test_config_file_finder.py +++ b/tests/unit/test_config_file_finder.py @@ -3,7 +3,10 @@ import configparser import os import sys -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8.options import config diff --git a/tests/unit/test_debug.py b/tests/unit/test_debug.py index dbafe2e..9284ffe 100644 --- a/tests/unit/test_debug.py +++ b/tests/unit/test_debug.py @@ -1,5 +1,8 @@ """Tests for our debugging module.""" -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest import setuptools diff --git a/tests/unit/test_file_checker.py b/tests/unit/test_file_checker.py index a2d33fc..5208136 100644 --- a/tests/unit/test_file_checker.py +++ b/tests/unit/test_file_checker.py @@ -1,5 +1,8 @@ """Unit tests for the FileChecker class.""" -import mock +try: + import mock +except ImportError: + from unittest import mock from flake8 import checker diff --git a/tests/unit/test_file_processor.py b/tests/unit/test_file_processor.py index c534003..4e875c6 100644 --- a/tests/unit/test_file_processor.py +++ b/tests/unit/test_file_processor.py @@ -5,7 +5,10 @@ import tokenize from flake8 import processor -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest diff --git a/tests/unit/test_git.py b/tests/unit/test_git.py index 24d4b5b..6a29fbc 100644 --- a/tests/unit/test_git.py +++ b/tests/unit/test_git.py @@ -1,5 +1,8 @@ """Tests around functionality in the git integration.""" -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8.main import git diff --git a/tests/unit/test_legacy_api.py b/tests/unit/test_legacy_api.py index 0f1d1f3..5929211 100644 --- a/tests/unit/test_legacy_api.py +++ b/tests/unit/test_legacy_api.py @@ -1,5 +1,8 @@ """Tests for Flake8's legacy API.""" -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8.api import legacy as api diff --git a/tests/unit/test_merged_config_parser.py b/tests/unit/test_merged_config_parser.py index 1541df4..7fe3084 100644 --- a/tests/unit/test_merged_config_parser.py +++ b/tests/unit/test_merged_config_parser.py @@ -1,7 +1,10 @@ """Unit tests for flake8.options.config.MergedConfigParser.""" import os -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8.options import config diff --git a/tests/unit/test_option.py b/tests/unit/test_option.py index 67e2255..843dea0 100644 --- a/tests/unit/test_option.py +++ b/tests/unit/test_option.py @@ -1,5 +1,8 @@ """Unit tests for flake8.options.manager.Option.""" -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8.options import manager diff --git a/tests/unit/test_option_manager.py b/tests/unit/test_option_manager.py index 661b445..483c3f0 100644 --- a/tests/unit/test_option_manager.py +++ b/tests/unit/test_option_manager.py @@ -2,7 +2,10 @@ import optparse import os -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import utils diff --git a/tests/unit/test_plugin.py b/tests/unit/test_plugin.py index 84f676a..865af7e 100644 --- a/tests/unit/test_plugin.py +++ b/tests/unit/test_plugin.py @@ -1,7 +1,10 @@ """Tests for flake8.plugins.manager.Plugin.""" import optparse -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import exceptions diff --git a/tests/unit/test_plugin_manager.py b/tests/unit/test_plugin_manager.py index 8991b96..18bdced 100644 --- a/tests/unit/test_plugin_manager.py +++ b/tests/unit/test_plugin_manager.py @@ -1,5 +1,8 @@ """Tests for flake8.plugins.manager.PluginManager.""" -import mock +try: + import mock +except ImportError: + from unittest import mock from flake8.plugins import manager diff --git a/tests/unit/test_plugin_type_manager.py b/tests/unit/test_plugin_type_manager.py index 186c2e3..6aef045 100644 --- a/tests/unit/test_plugin_type_manager.py +++ b/tests/unit/test_plugin_type_manager.py @@ -1,7 +1,10 @@ """Tests for flake8.plugins.manager.PluginTypeManager.""" import collections -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import exceptions diff --git a/tests/unit/test_style_guide.py b/tests/unit/test_style_guide.py index 7357b25..6b0f2aa 100644 --- a/tests/unit/test_style_guide.py +++ b/tests/unit/test_style_guide.py @@ -1,7 +1,10 @@ """Tests for the flake8.style_guide.StyleGuide class.""" import optparse -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import defaults diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index d1816bc..ded55cb 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,7 +1,10 @@ """Tests for flake8's utils module.""" import os -import mock +try: + import mock +except ImportError: + from unittest import mock import pytest from flake8 import utils diff --git a/tox.ini b/tox.ini index b72f3ad..cc0fb34 100644 --- a/tox.ini +++ b/tox.ini @@ -4,14 +4,20 @@ envlist = py27,py33,py34,py35,flake8,linters,docs [testenv] deps = - mock>=2.0.0 pytest coverage + mock>=2.0.0 commands = coverage run --parallel-mode -m pytest {posargs} coverage combine coverage report -m +[testenv:py35] +# No mock needed on 3.5+ +deps = + pytest + coverage + [testenv:venv] deps = . @@ -31,7 +37,7 @@ commands = # Linters [testenv:flake8] -basepython = python3 +basepython = python3.5 skip_install = true deps = flake8 @@ -41,7 +47,7 @@ commands = flake8 src/flake8/ tests/ setup.py [testenv:pylint] -basepython = python3 +basepython = python3.5 skip_install = true deps = pyflakes @@ -50,7 +56,7 @@ commands = pylint src/flake8 [testenv:doc8] -basepython = python3 +basepython = python3.5 skip_install = true deps = sphinx @@ -59,7 +65,7 @@ commands = doc8 docs/source/ [testenv:mypy] -basepython = python3 +basepython = python3.5 skip_install = true deps = mypy-lang @@ -67,7 +73,7 @@ commands = mypy flake8 [testenv:bandit] -basepython = python3 +basepython = python3.5 skip_install = true deps = bandit @@ -75,7 +81,7 @@ commands = bandit -r src/flake8/ -c .bandit.yml [testenv:linters] -basepython = python3 +basepython = python3.5 skip_install = true deps = {[testenv:flake8]deps} @@ -92,7 +98,7 @@ commands = # Documentation [testenv:docs] -basepython = python3 +basepython = python3.5 deps = -rdocs/source/requirements.txt commands = @@ -100,7 +106,7 @@ commands = sphinx-build -E -W -c docs/source/ -b man docs/source/ docs/build/man [testenv:serve-docs] -basepython = python3 +basepython = python3.5 skip_install = true changedir = docs/build/html deps = @@ -108,7 +114,7 @@ commands = python -m http.server {posargs} [testenv:readme] -basepython = python3 +basepython = python3.5 deps = readme_renderer commands = @@ -116,7 +122,7 @@ commands = # Release tooling [testenv:build] -basepython = python3 +basepython = python3.5 skip_install = true deps = wheel @@ -125,7 +131,7 @@ commands = python setup.py -q sdist bdist_wheel [testenv:release] -basepython = python3 +basepython = python3.5 skip_install = true deps = {[testenv:build]deps}