summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-08-15 18:47:16 -0400
committerAnthony Sottile <asottile@umich.edu>2021-08-15 19:00:43 -0400
commitd34581b83f75e12e2c021577aa2523eea8a9b590 (patch)
treef9312ee5f37d725677028e426a244bb5befe5ca3
parent281f3f8b43106023bf3fb160666384394031a9fd (diff)
downloadflake8-d34581b83f75e12e2c021577aa2523eea8a9b590.tar.gz
test using python3.10
-rw-r--r--.github/workflows/main.yml3
-rw-r--r--pytest.ini4
-rw-r--r--tests/integration/test_main.py8
-rw-r--r--tests/unit/test_plugin_type_manager.py21
4 files changed, 19 insertions, 17 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 3e84b3c..a378c9b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -27,6 +27,9 @@ jobs:
- os: ubuntu-latest
python: 3.9
toxenv: py
+ - os: ubuntu-latest
+ python: '3.10.0-alpha - 3.10.999'
+ toxenv: py
# windows
- os: windows-latest
python: 3.6
diff --git a/pytest.ini b/pytest.ini
index a72e0e1..1978251 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,4 +1,6 @@
[pytest]
norecursedirs = .git .* *.egg* old docs dist build
addopts = -rw
-filterwarnings = error
+filterwarnings =
+ error
+ ignore:SelectableGroups:DeprecationWarning
diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py
index 16ecba0..8ad7654 100644
--- a/tests/integration/test_main.py
+++ b/tests/integration/test_main.py
@@ -191,8 +191,10 @@ def test_tokenization_error_but_not_syntax_error(tmpdir, capsys):
expected = "t.py:2:1: E999 SyntaxError: end of file (EOF) in multi-line statement\n" # noqa: E501
elif sys.version_info < (3, 8): # pragma: no cover (<cp38)
expected = "t.py:2:1: E902 TokenError: EOF in multi-line statement\n"
- else: # pragma: no cover (cp38+)
+ elif sys.version_info < (3, 10): # pragma: no cover (cp38+)
expected = "t.py:1:8: E999 SyntaxError: unexpected EOF while parsing\n"
+ else: # pragma: no cover (cp310+)
+ expected = "t.py:1:10: E999 SyntaxError: unexpected EOF while parsing\n" # noqa: E501
out, err = capsys.readouterr()
assert out == expected
@@ -207,8 +209,10 @@ def test_tokenization_error_is_a_syntax_error(tmpdir, capsys):
if hasattr(sys, "pypy_version_info"): # pragma: no cover (pypy)
expected = "t.py:3:2: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
- else: # pragma: no cover (cpython)
+ elif sys.version_info < (3, 10): # pragma: no cover (<cp310)
expected = "t.py:3:5: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
+ else: # pragma: no cover (cp310+)
+ expected = "t.py:3:7: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
out, err = capsys.readouterr()
assert out == expected
diff --git a/tests/unit/test_plugin_type_manager.py b/tests/unit/test_plugin_type_manager.py
index 4db1ea9..1b823af 100644
--- a/tests/unit/test_plugin_type_manager.py
+++ b/tests/unit/test_plugin_type_manager.py
@@ -34,20 +34,13 @@ def create_mapping_manager_mock(plugins):
return manager_mock
-def create_manager_with_plugins(plugins):
- """Create a fake PluginManager with a plugins dictionary."""
- manager_mock = mock.create_autospec(manager.PluginManager)
- manager_mock.plugins = plugins
- return manager_mock
-
-
class FakeTestType(manager.PluginTypeManager):
"""Fake PluginTypeManager."""
namespace = TEST_NAMESPACE
-@mock.patch("flake8.plugins.manager.PluginManager")
+@mock.patch("flake8.plugins.manager.PluginManager", autospec=True)
def test_instantiates_a_manager(PluginManager): # noqa: N803
"""Verify we create a PluginManager on instantiation."""
FakeTestType()
@@ -55,7 +48,7 @@ def test_instantiates_a_manager(PluginManager): # noqa: N803
PluginManager.assert_called_once_with(TEST_NAMESPACE, local_plugins=None)
-@mock.patch("flake8.plugins.manager.PluginManager")
+@mock.patch("flake8.plugins.manager.PluginManager", autospec=True)
def test_proxies_names_to_manager(PluginManager): # noqa: N803
"""Verify we proxy the names attribute."""
PluginManager.return_value = mock.Mock(names=["T100", "T200", "T300"])
@@ -64,7 +57,7 @@ def test_proxies_names_to_manager(PluginManager): # noqa: N803
assert type_mgr.names == ["T100", "T200", "T300"]
-@mock.patch("flake8.plugins.manager.PluginManager")
+@mock.patch("flake8.plugins.manager.PluginManager", autospec=True)
def test_proxies_plugins_to_manager(PluginManager): # noqa: N803
"""Verify we proxy the plugins attribute."""
PluginManager.return_value = mock.Mock(plugins=["T100", "T200", "T300"])
@@ -86,7 +79,7 @@ def test_generate_call_function():
assert func(plugin) is optmanager
-@mock.patch("flake8.plugins.manager.PluginManager")
+@mock.patch("flake8.plugins.manager.PluginManager", autospec=True)
def test_load_plugins(PluginManager): # noqa: N803
"""Verify load plugins loads *every* plugin."""
# Create a bunch of fake plugins
@@ -191,12 +184,12 @@ def test_provide_options(PluginManager): # noqa: N803
plugin.provide_options.assert_called_with(optmanager, options, [])
-@mock.patch("flake8.plugins.manager.PluginManager")
+@mock.patch("flake8.plugins.manager.PluginManager", autospec=True)
def test_proxy_contains_to_managers_plugins_dict(PluginManager): # noqa: N803
"""Verify that we proxy __contains__ to the manager's dictionary."""
plugins = {"T10%i" % i: create_plugin_mock() for i in range(8)}
# Return our PluginManager mock
- PluginManager.return_value = create_manager_with_plugins(plugins)
+ PluginManager.return_value.plugins = plugins
type_mgr = FakeTestType()
for i in range(8):
@@ -209,7 +202,7 @@ def test_proxies_getitem_to_managers_plugins_dict(PluginManager): # noqa: N803
"""Verify that we can use the PluginTypeManager like a dictionary."""
plugins = {"T10%i" % i: create_plugin_mock() for i in range(8)}
# Return our PluginManager mock
- PluginManager.return_value = create_manager_with_plugins(plugins)
+ PluginManager.return_value.plugins = plugins
type_mgr = FakeTestType()
for i in range(8):