diff options
| author | Anthony Sottile <asottile@umich.edu> | 2021-03-29 17:43:42 -0700 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2021-03-30 17:37:13 -0700 |
| commit | 358ae85120b5336f6abf574688b1f7290b3c8cc4 (patch) | |
| tree | b19e95f7eac533e223fd20950c99f67f92f9df10 /tests/unit | |
| parent | 8cc3fc01e8d06b2eb6fa59332b598b2c638a4d40 (diff) | |
| download | flake8-358ae85120b5336f6abf574688b1f7290b3c8cc4.tar.gz | |
automatic: pyupgrade --py36-plus
Diffstat (limited to 'tests/unit')
| -rw-r--r-- | tests/unit/test_application.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_base_formatter.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_checker_manager.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_config_file_finder.py | 3 | ||||
| -rw-r--r-- | tests/unit/test_debug.py | 3 | ||||
| -rw-r--r-- | tests/unit/test_file_checker.py | 5 | ||||
| -rw-r--r-- | tests/unit/test_file_processor.py | 10 | ||||
| -rw-r--r-- | tests/unit/test_get_local_plugins.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_legacy_api.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_merged_config_parser.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_option.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_option_manager.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_plugin.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_plugin_manager.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_plugin_type_manager.py | 3 | ||||
| -rw-r--r-- | tests/unit/test_statistics.py | 4 | ||||
| -rw-r--r-- | tests/unit/test_style_guide.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_utils.py | 6 | ||||
| -rw-r--r-- | tests/unit/test_violation.py | 3 |
19 files changed, 31 insertions, 28 deletions
diff --git a/tests/unit/test_application.py b/tests/unit/test_application.py index 51adefb..d675eaa 100644 --- a/tests/unit/test_application.py +++ b/tests/unit/test_application.py @@ -1,8 +1,8 @@ """Tests for the Application class.""" import argparse import sys +from unittest import mock -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 ff2df7c..c48adf2 100644 --- a/tests/unit/test_base_formatter.py +++ b/tests/unit/test_base_formatter.py @@ -1,7 +1,7 @@ """Tests for the BaseFormatter object.""" import argparse +from unittest import mock -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 d3e7e61..b94d0c5 100644 --- a/tests/unit/test_checker_manager.py +++ b/tests/unit/test_checker_manager.py @@ -1,7 +1,7 @@ """Tests for the Manager object for FileCheckers.""" import errno +from unittest import mock -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 d21b03d..d31a692 100644 --- a/tests/unit/test_config_file_finder.py +++ b/tests/unit/test_config_file_finder.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- """Tests for the ConfigFileFinder.""" import configparser import os +from unittest import mock -import mock import pytest from flake8.options import config diff --git a/tests/unit/test_debug.py b/tests/unit/test_debug.py index 6398cf9..bc31fec 100644 --- a/tests/unit/test_debug.py +++ b/tests/unit/test_debug.py @@ -1,5 +1,6 @@ """Tests for our debugging module.""" -import mock +from unittest import mock + import pytest from flake8.main import debug diff --git a/tests/unit/test_file_checker.py b/tests/unit/test_file_checker.py index c4ee2bf..2b80919 100644 --- a/tests/unit/test_file_checker.py +++ b/tests/unit/test_file_checker.py @@ -1,5 +1,6 @@ """Unit tests for the FileChecker class.""" -import mock +from unittest import mock + import pytest import flake8 @@ -50,7 +51,7 @@ def test_nonexistent_file(): def test_raises_exception_on_failed_plugin(tmp_path, default_options): """Checks that a failing plugin results in PluginExecutionFailed.""" foobar = tmp_path / 'foobar.py' - foobar.write_text(u"I exist!") # Create temp file + foobar.write_text("I exist!") # Create temp file plugin = { "name": "failure", "plugin_name": "failure", # Both are necessary diff --git a/tests/unit/test_file_processor.py b/tests/unit/test_file_processor.py index b72e064..ca7f4f6 100644 --- a/tests/unit/test_file_processor.py +++ b/tests/unit/test_file_processor.py @@ -1,8 +1,8 @@ """Tests for the FileProcessor class.""" import ast import tokenize +from unittest import mock -import mock import pytest from flake8 import processor @@ -46,7 +46,7 @@ def test_read_lines_unknown_encoding(tmpdir, default_options): @pytest.mark.parametrize('first_line', [ '\xEF\xBB\xBF"""Module docstring."""\n', - u'\uFEFF"""Module docstring."""\n', + '\uFEFF"""Module docstring."""\n', ]) def test_strip_utf_bom(first_line, default_options): r"""Verify that we strip '\xEF\xBB\xBF' from the first line.""" @@ -58,7 +58,7 @@ def test_strip_utf_bom(first_line, default_options): @pytest.mark.parametrize('lines, expected', [ (['\xEF\xBB\xBF"""Module docstring."""\n'], False), - ([u'\uFEFF"""Module docstring."""\n'], False), + (['\uFEFF"""Module docstring."""\n'], False), (['#!/usr/bin/python', '# flake8 is great', 'a = 1'], False), (['#!/usr/bin/python', '# flake8: noqa', 'a = 1'], True), (['#!/usr/bin/python', '# flake8:noqa', 'a = 1'], True), @@ -130,7 +130,7 @@ def test_noqa_line_for(default_options): ]) for i in range(1, 4): - assert file_processor.noqa_line_for(i) == 'Line {}\n'.format(i) + assert file_processor.noqa_line_for(i) == f'Line {i}\n' def test_noqa_line_for_continuation(default_options): @@ -182,7 +182,7 @@ def test_next_line(default_options): ]) for i in range(1, 4): - assert file_processor.next_line() == 'Line {}'.format(i) + assert file_processor.next_line() == f'Line {i}' assert file_processor.line_number == i diff --git a/tests/unit/test_get_local_plugins.py b/tests/unit/test_get_local_plugins.py index ec11998..0817550 100644 --- a/tests/unit/test_get_local_plugins.py +++ b/tests/unit/test_get_local_plugins.py @@ -1,5 +1,5 @@ """Tests for get_local_plugins.""" -import mock +from unittest import mock from flake8.options import config diff --git a/tests/unit/test_legacy_api.py b/tests/unit/test_legacy_api.py index 0ec839f..a1e7d50 100644 --- a/tests/unit/test_legacy_api.py +++ b/tests/unit/test_legacy_api.py @@ -1,8 +1,8 @@ """Tests for Flake8's legacy API.""" import argparse import os.path +from unittest import mock -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 d446ad8..8def01b 100644 --- a/tests/unit/test_merged_config_parser.py +++ b/tests/unit/test_merged_config_parser.py @@ -1,7 +1,7 @@ """Unit tests for flake8.options.config.MergedConfigParser.""" import os +from unittest import mock -import mock import pytest from flake8.options import config diff --git a/tests/unit/test_option.py b/tests/unit/test_option.py index ba6b672..fc0e288 100644 --- a/tests/unit/test_option.py +++ b/tests/unit/test_option.py @@ -1,7 +1,7 @@ """Unit tests for flake8.options.manager.Option.""" import functools +from unittest import mock -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 09714b9..4dcbaa8 100644 --- a/tests/unit/test_option_manager.py +++ b/tests/unit/test_option_manager.py @@ -1,8 +1,8 @@ """Unit tests for flake.options.manager.OptionManager.""" import argparse import os +from unittest import mock -import mock import pytest from flake8 import utils diff --git a/tests/unit/test_plugin.py b/tests/unit/test_plugin.py index 402eac8..204a4c2 100644 --- a/tests/unit/test_plugin.py +++ b/tests/unit/test_plugin.py @@ -1,7 +1,7 @@ """Tests for flake8.plugins.manager.Plugin.""" import argparse +from unittest import mock -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 9ad6aba..55c3e24 100644 --- a/tests/unit/test_plugin_manager.py +++ b/tests/unit/test_plugin_manager.py @@ -1,5 +1,5 @@ """Tests for flake8.plugins.manager.PluginManager.""" -import mock +from unittest import mock from flake8._compat import importlib_metadata from flake8.plugins import manager diff --git a/tests/unit/test_plugin_type_manager.py b/tests/unit/test_plugin_type_manager.py index 939aa8c..9d00b78 100644 --- a/tests/unit/test_plugin_type_manager.py +++ b/tests/unit/test_plugin_type_manager.py @@ -1,5 +1,6 @@ """Tests for flake8.plugins.manager.PluginTypeManager.""" -import mock +from unittest import mock + import pytest from flake8 import exceptions diff --git a/tests/unit/test_statistics.py b/tests/unit/test_statistics.py index 16896f0..6aa4e6f 100644 --- a/tests/unit/test_statistics.py +++ b/tests/unit/test_statistics.py @@ -111,8 +111,8 @@ def test_statistic_for_retrieves_more_than_one_value(): """Show this works for more than a couple statistic values.""" aggregator = stats.Statistics() for i in range(50): - aggregator.record(make_error(code='E1{:02d}'.format(i))) - aggregator.record(make_error(code='W2{:02d}'.format(i))) + aggregator.record(make_error(code=f'E1{i:02d}')) + aggregator.record(make_error(code=f'W2{i:02d}')) statistics = list(aggregator.statistics_for('E')) assert len(statistics) == 50 diff --git a/tests/unit/test_style_guide.py b/tests/unit/test_style_guide.py index 5503d7e..ac781f3 100644 --- a/tests/unit/test_style_guide.py +++ b/tests/unit/test_style_guide.py @@ -1,7 +1,7 @@ """Tests for the flake8.style_guide.StyleGuide class.""" import argparse +from unittest import mock -import mock import pytest from flake8 import statistics diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 4b89484..1befa8f 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -3,8 +3,8 @@ import io import logging import os import sys +from unittest import mock -import mock import pytest from flake8 import exceptions @@ -242,7 +242,7 @@ def test_filenames_from_exclude_doesnt_exclude_directory_names(tmpdir): def test_parameters_for_class_plugin(): """Verify that we can retrieve the parameters for a class plugin.""" - class FakeCheck(object): + class FakeCheck: def __init__(self, tree): raise NotImplementedError @@ -268,7 +268,7 @@ def test_parameters_for_function_plugin(): def read_diff_file(filename): """Read the diff file in its entirety.""" - with open(filename, 'r') as fd: + with open(filename) as fd: content = fd.read() return content diff --git a/tests/unit/test_violation.py b/tests/unit/test_violation.py index a3a56f0..284cd2a 100644 --- a/tests/unit/test_violation.py +++ b/tests/unit/test_violation.py @@ -1,5 +1,6 @@ """Tests for the flake8.style_guide.Violation class.""" -import mock +from unittest import mock + import pytest from flake8 import style_guide |
