Only require Mock on Python 3.4 and older. Use the builtin one elsewhere.

Mock 2.0 is using pbr which is hostile to environments without network access.
It's not required on Python 3.5+ so I made it possible to use `unittest.mock`
on this version.

Updated tox.ini to reflect this. Tested with 2.7.11, 3.3.6, 3.4.5, and 3.5.2 on
macOS 10.12.1 with tox and pyenv.
This commit is contained in:
Lukasz Langa 2016-11-27 13:26:42 -08:00
parent b8ce1334d0
commit 01c0c648e1
21 changed files with 95 additions and 31 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
*.pyc
.python-version
.tox
.eggs
*.egg

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,8 @@
"""Tests for our debugging module."""
import mock
try:
import mock
except ImportError:
from unittest import mock
import pytest
import setuptools

View file

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

View file

@ -5,7 +5,10 @@ import tokenize
from flake8 import processor
import mock
try:
import mock
except ImportError:
from unittest import mock
import pytest

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

30
tox.ini
View file

@ -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}