1
0
forked from pool/python-flake8

Accepting request 672301 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/672301
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-flake8?expand=0&rev=22
This commit is contained in:
Dominique Leuenberger 2019-02-14 13:12:14 +00:00 committed by Git OBS Bridge
commit dc41abf49c
7 changed files with 282 additions and 134 deletions

View File

@ -0,0 +1,58 @@
From: Antonio Larrosa <alarrosa@suse.com>
Subject: Fix mock.patch with python3.4
In python 3.5, mock.patch uses create=True automatically if you are patching
builtins in a module, but in python 3.4 the argument is still needed.
Index: flake8-3.7.5/tests/unit/test_debug.py
===================================================================
--- flake8-3.7.5.orig/tests/unit/test_debug.py
+++ flake8-3.7.5/tests/unit/test_debug.py
@@ -70,7 +70,7 @@ def test_information(system, pyversion,
system.assert_called_once_with()
-@mock.patch('flake8.main.debug.print')
+@mock.patch('flake8.main.debug.print', create=True)
@mock.patch('flake8.main.debug.information', return_value={})
@mock.patch('json.dumps', return_value='{}')
def test_print_information_no_plugins(dumps, information, print_mock):
@@ -85,7 +85,7 @@ def test_print_information_no_plugins(du
assert print_mock.called is False
-@mock.patch('flake8.main.debug.print')
+@mock.patch('flake8.main.debug.print', create=True)
@mock.patch('flake8.main.debug.information', return_value={})
@mock.patch('json.dumps', return_value='{}')
def test_print_information(dumps, information, print_mock):
Index: flake8-3.7.5/tests/unit/test_base_formatter.py
===================================================================
--- flake8-3.7.5.orig/tests/unit/test_base_formatter.py
+++ flake8-3.7.5/tests/unit/test_base_formatter.py
@@ -23,7 +23,7 @@ def test_start(filename):
"""Verify we open a new file in the start method."""
mock_open = mock.mock_open()
formatter = base.BaseFormatter(options(output_file=filename))
- with mock.patch('flake8.formatting.base.open', mock_open):
+ with mock.patch('flake8.formatting.base.open', mock_open, create=True):
formatter.start()
if filename is None:
@@ -90,7 +90,7 @@ def test_write_uses_an_output_file(tee):
formatter = base.BaseFormatter(options(tee=tee))
formatter.output_fd = filemock
- with mock.patch('flake8.formatting.base.print') as print_func:
+ with mock.patch('flake8.formatting.base.print', create=True) as print_func:
formatter.write(line, source)
if tee:
assert print_func.called
@@ -109,7 +109,7 @@ def test_write_uses_an_output_file(tee):
]
-@mock.patch('flake8.formatting.base.print')
+@mock.patch('flake8.formatting.base.print', create=True)
def test_write_uses_print(print_function):
"""Verify that we use the print function without an output file."""
line = 'Something to write'

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6a35f5b8761f45c5513e3405f110a86bea57982c3b75b766ce7b65217abe1670
size 144684

3
flake8-3.7.5.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fd9ddf503110bf3d8b1d270e8c673aab29ccb3dd6abf29bae1f54e5116ab4a91
size 148039

View File

@ -1,65 +0,0 @@
From 03ea38df168036a38aff7af916c07c05fe1f2eb2 Mon Sep 17 00:00:00 2001
From: Anthony Sottile <asottile@umich.edu>
Date: Sat, 19 Jan 2019 11:59:38 -0800
Subject: [PATCH] WIP: use latest pyflakes
---
setup.py | 2 +-
src/flake8/plugins/pyflakes.py | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
Index: flake8-3.6.0/setup.py
===================================================================
--- flake8-3.6.0.orig/setup.py
+++ flake8-3.6.0/setup.py
@@ -25,7 +25,7 @@ requires = [
# http://flake8.pycqa.org/en/latest/faq.html#why-does-flake8-use-ranges-for-its-dependencies
# And in which releases we will update those ranges here:
# http://flake8.pycqa.org/en/latest/internal/releases.html#releasing-flake8
- "pyflakes >= 2.0.0, < 2.1.0",
+ "pyflakes >= 2.1.0, < 2.2.0",
"pycodestyle >= 2.4.0, < 2.5.0",
"mccabe >= 0.6.0, < 0.7.0",
"setuptools >= 30",
Index: flake8-3.6.0/src/flake8/plugins/pyflakes.py
===================================================================
--- flake8-3.6.0.orig/src/flake8/plugins/pyflakes.py
+++ flake8-3.6.0/src/flake8/plugins/pyflakes.py
@@ -30,6 +30,8 @@ FLAKE8_PYFLAKES_CODES = {
"TooManyExpressionsInStarredAssignment": "F621",
"TwoStarredExpressions": "F622",
"AssertTuple": "F631",
+ "IsLiteral": "F632",
+ "InvalidPrintSyntax": "F633",
"BreakOutsideLoop": "F701",
"ContinueOutsideLoop": "F702",
"ContinueInFinally": "F703",
@@ -39,6 +41,7 @@ FLAKE8_PYFLAKES_CODES = {
"DefaultExceptNotLast": "F707",
"DoctestSyntaxError": "F721",
"ForwardAnnotationSyntaxError": "F722",
+ "CommentAnnotationSyntaxError": "F723",
"RedefinedWhileUnused": "F811",
"RedefinedInListComp": "F812",
"UndefinedName": "F821",
@@ -72,7 +75,7 @@ class FlakesChecker(pyflakes.checker.Che
include_in_doctest = []
exclude_from_doctest = []
- def __init__(self, tree, filename):
+ def __init__(self, tree, file_tokens, filename):
"""Initialize the PyFlakes plugin with an AST tree and filename."""
filename = utils.normalize_paths(filename)[0]
with_doctest = self.with_doctest
@@ -97,7 +100,10 @@ class FlakesChecker(pyflakes.checker.Che
with_doctest = True
super(FlakesChecker, self).__init__(
- tree, filename, withDoctest=with_doctest
+ tree,
+ filename=filename,
+ withDoctest=with_doctest,
+ file_tokens=file_tokens,
)
@classmethod

View File

@ -1,3 +1,82 @@
-------------------------------------------------------------------
Wed Feb 6 09:42:40 UTC 2019 - Antonio Larrosa <alarrosa@suse.com>
- Add missing dependency on python3-typing when python3 < 3.5
- Add fix-mock-patch-with-python3.4.patch to fix building the package in
Leap 42.3. In python 3.5, mock.patch uses create=True automatically if
you are patching builtins in a module, but in python 3.4 the argument
is still needed.
-------------------------------------------------------------------
Tue Feb 5 11:48:33 UTC 2019 - Antonio Larrosa <alarrosa@suse.com>
- Enable tests
- Add allow-bytes-filenames.patch to fix some tests that fail because
they pass bytes objects as filenames.
- Update remove_mock_dependency.patch to fix another test that used mock
-------------------------------------------------------------------
Tue Feb 5 09:21:47 UTC 2019 - Antonio Larrosa <alarrosa@suse.com>
- Update to version 3.7.5:
* Bugs Fixed
+ Fix reporting of pyflakes "referenced before assignment" error
(See also GitLab!301, GitLab#503)
- Update to version 3.7.4:
* Bugs Fixed
+ Fix performance regression with lots of per-file-ignores and errors
(See also GitLab!299, GitLab#501)
- Update to version 3.7.3:
* Bugs Fixed
+ Fix imports of typing in python 3.5.0 / 3.5.1 (See also GitLab!294,
GitLab#498)
+ Fix flake8 --statistics (See also GitLab!295, GitLab#499)
+ Gracefully ignore flake8-per-file-ignores plugin if installed
(See also GitLab!297, GitLab#495)
+ Improve error message for malformed per-file-ignores
(See also GitLab!298, GitLab#489)
- Update to version 3.7.2:
* Bugs Fixed
+ Fix broken flake8 --diff (regressed in 3.7.0) (See also GitLab!292,
GitLab#490)
+ Fix typo in plugin exception reporting (See also GitLab!275, GitLab#491)
+ Fix AttributeError while attempting to use the legacy api
(regressed in 3.7.0) (See also GitLab!293, GitLab#497)
- Update to version 3.7.1:
* Bugs Fixed
+ Fix capitalized filenames in per-file-ignores setting (See also GitLab!290, GitLab#488)
- Update to version 3.7.0:
* New Dependency Information
+ Add dependency on entrypoints >= 0.3, < 0.4
(See also GitLab!264, GitLab!288)
+ Pyflakes has been updated to >= 2.1.0, < 2.2.0
(See also GitLab!283, GitLab!285)
+ pycodestyle has been updated to >= 2.5.0, < 2.6.0
(See also GitLab!287)
* Features
+ Add support for per-file-ignores (See also GitLab!259, GitLab#156,
GitLab!281, GitLab#471)
+ Enable use of float and complex option types (See also GitLab!261,
GitLab#452)
+ Improve startup performance by switching from pkg_resources to
entrypoints (See also GitLab!264)
+ Add metadata for use through the pre-commit git hooks framework
(See also GitLab!268, GitLab!284)
+ Allow physical line checks to return more than one result
(See also GitLab!269)
+ Allow # noqa:X123 comments without space between the colon and codes list
(See also GitLab!273, GitLab#470)
+ Remove broken and unused flake8.listen plugin type
(See also GitLab!274, GitLab#480)
- Remove pyflakes21.patch which is already included upstream
- Rebase remove_mock_dependency.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Jan 29 09:19:47 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com> Tue Jan 29 09:19:47 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>

View File

@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}} %{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without python2 %bcond_without python2
Name: python-flake8 Name: python-flake8
Version: 3.6.0 Version: 3.7.5
Release: 0 Release: 0
Summary: Modular source code checker: pep8, pyflakes and co Summary: Modular source code checker: pep8, pyflakes and co
License: MIT License: MIT
@ -27,31 +27,45 @@ Group: Development/Languages/Python
URL: https://gitlab.com/pycqa/flake8 URL: https://gitlab.com/pycqa/flake8
Source: https://files.pythonhosted.org/packages/source/f/flake8/flake8-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/f/flake8/flake8-%{version}.tar.gz
Patch0: remove_mock_dependency.patch Patch0: remove_mock_dependency.patch
Patch1: pyflakes21.patch Patch1: fix-mock-patch-with-python3.4.patch
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires: python-entrypoints >= 0.3
Requires: python-mccabe >= 0.6.0 Requires: python-mccabe >= 0.6.0
Requires: python-pycodestyle >= 2.4.0 Requires: python-pycodestyle >= 2.5.0
Requires: python-pyflakes >= 2.0.0 Requires: python-pyflakes >= 2.1.0
Requires(post): update-alternatives Requires(post): update-alternatives
Requires(postun): update-alternatives Requires(postun): update-alternatives
BuildArch: noarch BuildArch: noarch
# SECTION test requirements # SECTION test requirements
BuildRequires: %{python_module mccabe >= 0.2.1} BuildRequires: %{python_module entrypoints >= 0.3}
BuildRequires: %{python_module pycodestyle >= 2.4.0} BuildRequires: %{python_module mccabe >= 0.6.0}
BuildRequires: %{python_module pyflakes >= 2.0.0} BuildRequires: %{python_module pycodestyle >= 2.5.0}
BuildRequires: %{python_module pyflakes >= 2.1.0}
BuildRequires: %{python_module pytest-runner} BuildRequires: %{python_module pytest-runner}
BuildRequires: %{python_module pytest} BuildRequires: %{python_module pytest}
%if %{with python2} %if %{with python2}
BuildRequires: python2-configparser BuildRequires: python2-configparser >= 3.7.0
BuildRequires: python2-enum34 BuildRequires: python2-enum34
BuildRequires: python2-functools32
BuildRequires: python2-mock BuildRequires: python2-mock
BuildRequires: python2-typing
%endif
%if 0%{?python3_version_nodots} < 35
BuildRequires: python3-typing
%endif %endif
# /SECTION # /SECTION
%ifpython2 %ifpython2
Requires: python-configparser Requires: python-configparser >= 3.7.0
Requires: python-enum34 Requires: python-enum34
Requires: python-functools32
Requires: python-typing
%endif
%ifpython3
%if 0%{?python3_version_nodots} < 35
Requires: python3-typing
%endif
%endif %endif
%python_subpackages %python_subpackages
@ -83,7 +97,7 @@ Flake8 runs all the tools by launching the single ``flake8`` script.
%python_uninstall_alternative flake8 %python_uninstall_alternative flake8
%check %check
%python_exec setup.py test %python_expand PYTHONPATH=%{buildroot}%{$python_sitelib} $python -m pytest tests
%files %{python_files} %files %{python_files}
%doc README.rst %doc README.rst

View File

@ -1,5 +1,7 @@
--- a/tests/integration/test_checker.py Index: flake8-3.7.5/tests/integration/test_checker.py
+++ b/tests/integration/test_checker.py ===================================================================
--- flake8-3.7.5.orig/tests/integration/test_checker.py
+++ flake8-3.7.5/tests/integration/test_checker.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Integration tests for the checker submodule.""" """Integration tests for the checker submodule."""
-import mock -import mock
@ -10,8 +12,10 @@
import pytest import pytest
from flake8 import checker from flake8 import checker
--- a/tests/unit/test_application.py Index: flake8-3.7.5/tests/unit/test_application.py
+++ b/tests/unit/test_application.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_application.py
+++ flake8-3.7.5/tests/unit/test_application.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Tests for the Application class.""" """Tests for the Application class."""
import optparse import optparse
@ -23,9 +27,11 @@
+ import mock + import mock
import pytest import pytest
from flake8 import exceptions from flake8.main import application as app
--- a/tests/unit/test_base_formatter.py Index: flake8-3.7.5/tests/unit/test_base_formatter.py
+++ b/tests/unit/test_base_formatter.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_base_formatter.py
+++ flake8-3.7.5/tests/unit/test_base_formatter.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Tests for the BaseFormatter object.""" """Tests for the BaseFormatter object."""
import optparse import optparse
@ -38,8 +44,10 @@
import pytest import pytest
from flake8 import style_guide from flake8 import style_guide
--- a/tests/unit/test_checker_manager.py Index: flake8-3.7.5/tests/unit/test_checker_manager.py
+++ b/tests/unit/test_checker_manager.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_checker_manager.py
+++ flake8-3.7.5/tests/unit/test_checker_manager.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Tests for the Manager object for FileCheckers.""" """Tests for the Manager object for FileCheckers."""
import errno import errno
@ -52,8 +60,10 @@
import pytest import pytest
from flake8 import checker from flake8 import checker
--- a/tests/unit/test_config_file_finder.py Index: flake8-3.7.5/tests/unit/test_config_file_finder.py
+++ b/tests/unit/test_config_file_finder.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_config_file_finder.py
+++ flake8-3.7.5/tests/unit/test_config_file_finder.py
@@ -4,7 +4,10 @@ import configparser @@ -4,7 +4,10 @@ import configparser
import os import os
import sys import sys
@ -66,20 +76,25 @@
import pytest import pytest
from flake8.options import config from flake8.options import config
--- a/tests/unit/test_debug.py Index: flake8-3.7.5/tests/unit/test_debug.py
+++ b/tests/unit/test_debug.py ===================================================================
@@ -1,5 +1,8 @@ --- flake8-3.7.5.orig/tests/unit/test_debug.py
+++ flake8-3.7.5/tests/unit/test_debug.py
@@ -1,6 +1,9 @@
"""Tests for our debugging module.""" """Tests for our debugging module."""
import entrypoints
-import mock -import mock
+try: +try:
+ import unittest.mock as mock + import unittest.mock as mock
+except ImportError: +except ImportError:
+ import mock + import mock
import pytest import pytest
import setuptools
--- a/tests/unit/test_file_checker.py from flake8.main import debug
+++ b/tests/unit/test_file_checker.py Index: flake8-3.7.5/tests/unit/test_file_checker.py
===================================================================
--- flake8-3.7.5.orig/tests/unit/test_file_checker.py
+++ flake8-3.7.5/tests/unit/test_file_checker.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Unit tests for the FileChecker class.""" """Unit tests for the FileChecker class."""
-import mock -import mock
@ -87,14 +102,16 @@
+ import unittest.mock as mock + import unittest.mock as mock
+except ImportError: +except ImportError:
+ import mock + import mock
import pytest
from flake8 import checker import flake8
Index: flake8-3.7.5/tests/unit/test_file_processor.py
--- a/tests/unit/test_file_processor.py ===================================================================
+++ b/tests/unit/test_file_processor.py --- flake8-3.7.5.orig/tests/unit/test_file_processor.py
@@ -5,7 +5,10 @@ import tokenize +++ flake8-3.7.5/tests/unit/test_file_processor.py
@@ -2,7 +2,10 @@
from flake8 import processor import ast
import tokenize
-import mock -import mock
+try: +try:
@ -103,9 +120,11 @@
+ import mock + import mock
import pytest import pytest
from flake8 import processor
--- a/tests/unit/test_get_local_plugins.py Index: flake8-3.7.5/tests/unit/test_get_local_plugins.py
+++ b/tests/unit/test_get_local_plugins.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_get_local_plugins.py
+++ flake8-3.7.5/tests/unit/test_get_local_plugins.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Tests for get_local_plugins.""" """Tests for get_local_plugins."""
-import mock -import mock
@ -116,8 +135,10 @@
from flake8.options import config from flake8.options import config
--- a/tests/unit/test_git.py Index: flake8-3.7.5/tests/unit/test_git.py
+++ b/tests/unit/test_git.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_git.py
+++ flake8-3.7.5/tests/unit/test_git.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Tests around functionality in the git integration.""" """Tests around functionality in the git integration."""
-import mock -import mock
@ -128,8 +149,10 @@
import pytest import pytest
from flake8.main import git from flake8.main import git
--- a/tests/unit/test_legacy_api.py Index: flake8-3.7.5/tests/unit/test_legacy_api.py
+++ b/tests/unit/test_legacy_api.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_legacy_api.py
+++ flake8-3.7.5/tests/unit/test_legacy_api.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Tests for Flake8's legacy API.""" """Tests for Flake8's legacy API."""
-import mock -import mock
@ -140,8 +163,10 @@
import pytest import pytest
from flake8.api import legacy as api from flake8.api import legacy as api
--- a/tests/unit/test_merged_config_parser.py Index: flake8-3.7.5/tests/unit/test_merged_config_parser.py
+++ b/tests/unit/test_merged_config_parser.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_merged_config_parser.py
+++ flake8-3.7.5/tests/unit/test_merged_config_parser.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Unit tests for flake8.options.config.MergedConfigParser.""" """Unit tests for flake8.options.config.MergedConfigParser."""
import os import os
@ -154,8 +179,10 @@
import pytest import pytest
from flake8.options import config from flake8.options import config
--- a/tests/unit/test_option.py Index: flake8-3.7.5/tests/unit/test_option.py
+++ b/tests/unit/test_option.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_option.py
+++ flake8-3.7.5/tests/unit/test_option.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Unit tests for flake8.options.manager.Option.""" """Unit tests for flake8.options.manager.Option."""
-import mock -import mock
@ -166,8 +193,10 @@
import pytest import pytest
from flake8.options import manager from flake8.options import manager
--- a/tests/unit/test_option_manager.py Index: flake8-3.7.5/tests/unit/test_option_manager.py
+++ b/tests/unit/test_option_manager.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_option_manager.py
+++ flake8-3.7.5/tests/unit/test_option_manager.py
@@ -2,7 +2,10 @@ @@ -2,7 +2,10 @@
import optparse import optparse
import os import os
@ -180,8 +209,10 @@
import pytest import pytest
from flake8 import utils from flake8 import utils
--- a/tests/unit/test_plugin.py Index: flake8-3.7.5/tests/unit/test_plugin.py
+++ b/tests/unit/test_plugin.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_plugin.py
+++ flake8-3.7.5/tests/unit/test_plugin.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Tests for flake8.plugins.manager.Plugin.""" """Tests for flake8.plugins.manager.Plugin."""
import optparse import optparse
@ -194,8 +225,10 @@
import pytest import pytest
from flake8 import exceptions from flake8 import exceptions
--- a/tests/unit/test_plugin_manager.py Index: flake8-3.7.5/tests/unit/test_plugin_manager.py
+++ b/tests/unit/test_plugin_manager.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_plugin_manager.py
+++ flake8-3.7.5/tests/unit/test_plugin_manager.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Tests for flake8.plugins.manager.PluginManager.""" """Tests for flake8.plugins.manager.PluginManager."""
-import mock -import mock
@ -206,8 +239,10 @@
from flake8.plugins import manager from flake8.plugins import manager
--- a/tests/unit/test_plugin_type_manager.py Index: flake8-3.7.5/tests/unit/test_plugin_type_manager.py
+++ b/tests/unit/test_plugin_type_manager.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_plugin_type_manager.py
+++ flake8-3.7.5/tests/unit/test_plugin_type_manager.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Tests for flake8.plugins.manager.PluginTypeManager.""" """Tests for flake8.plugins.manager.PluginTypeManager."""
import sys import sys
@ -220,8 +255,10 @@
import pytest import pytest
from flake8 import exceptions from flake8 import exceptions
--- a/tests/unit/test_style_guide.py Index: flake8-3.7.5/tests/unit/test_style_guide.py
+++ b/tests/unit/test_style_guide.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_style_guide.py
+++ flake8-3.7.5/tests/unit/test_style_guide.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Tests for the flake8.style_guide.StyleGuide class.""" """Tests for the flake8.style_guide.StyleGuide class."""
import optparse import optparse
@ -233,9 +270,11 @@
+ import mock + import mock
import pytest import pytest
from flake8 import style_guide from flake8 import statistics
--- a/tests/unit/test_utils.py Index: flake8-3.7.5/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_utils.py
+++ flake8-3.7.5/tests/unit/test_utils.py
@@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@
"""Tests for flake8's utils module.""" """Tests for flake8's utils module."""
import os import os
@ -247,9 +286,11 @@
+ import mock + import mock
import pytest import pytest
from flake8 import utils from flake8 import exceptions
--- a/tests/unit/test_violation.py Index: flake8-3.7.5/tests/unit/test_violation.py
+++ b/tests/unit/test_violation.py ===================================================================
--- flake8-3.7.5.orig/tests/unit/test_violation.py
+++ flake8-3.7.5/tests/unit/test_violation.py
@@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
"""Tests for the flake8.style_guide.Violation class.""" """Tests for the flake8.style_guide.Violation class."""
-import mock -import mock
@ -260,19 +301,40 @@
import pytest import pytest
from flake8 import style_guide from flake8 import style_guide
--- a/setup.py Index: flake8-3.7.5/setup.py
+++ b/setup.py ===================================================================
@@ -11,8 +11,12 @@ sys.path.insert(0, os.path.join(os.path. --- flake8-3.7.5.orig/setup.py
+++ flake8-3.7.5/setup.py
@@ -11,6 +11,12 @@ sys.path.insert(0, os.path.join(os.path.
import flake8 import flake8
+PY2 = sys.version_info[0] == 2 +PY2 = sys.version_info[0] == 2
-tests_require = ['mock >= 2.0.0', 'pytest']
+tests_require = ['pytest'] +tests_require = ['pytest']
+ +
+if PY2: +if PY2:
+ tests_require.append('mock >= 2.0.0') + tests_require.append('mock >= 2.0.0')
+
# NOTE(sigmavirus24): When updating these requirements, update them in # NOTE(sigmavirus24): When updating these requirements, update them in
# setup.cfg as well. # setup.cfg as well.
@@ -147,4 +153,5 @@ setuptools.setup(
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
],
+ tests_require=tests_require,
)
Index: flake8-3.7.5/tests/integration/test_main.py
===================================================================
--- flake8-3.7.5.orig/tests/integration/test_main.py
+++ flake8-3.7.5/tests/integration/test_main.py
@@ -1,5 +1,8 @@
"""Integration tests for the main entrypoint of flake8."""
-import mock
+try:
+ import unittest.mock as mock
+except ImportError:
+ import mock
from flake8 import utils
from flake8.main import application