| 1 |
"""A set of test cases for the wemake isort profile. |
| 2 |
|
| 3 |
Snippets are taken directly from the wemake-python-styleguide project here: |
| 4 |
https://github.com/wemake-services/wemake-python-styleguide |
| 5 |
""" |
| 6 |
|
| 7 |
from functools import partial |
| 8 |
|
| 9 |
from ..utils import isort_test |
| 10 |
|
| 11 |
wemake_isort_test = partial( |
| 12 |
isort_test, profile="wemake", known_first_party=["wemake_python_styleguide"] |
| 13 |
) |
| 14 |
|
| 15 |
|
| 16 |
def test_wemake_snippet_one() -> None: |
| 17 |
wemake_isort_test( |
| 18 |
""" |
| 19 |
import ast |
| 20 |
import tokenize |
| 21 |
import traceback |
| 22 |
from typing import ClassVar, Iterator, Sequence, Type |
| 23 |
|
| 24 |
from flake8.options.manager import OptionManager |
| 25 |
from typing_extensions import final |
| 26 |
|
| 27 |
from wemake_python_styleguide import constants, types |
| 28 |
from wemake_python_styleguide import version as pkg_version |
| 29 |
from wemake_python_styleguide.options.config import Configuration |
| 30 |
from wemake_python_styleguide.options.validation import validate_options |
| 31 |
from wemake_python_styleguide.presets.types import file_tokens as tokens_preset |
| 32 |
from wemake_python_styleguide.presets.types import filename as filename_preset |
| 33 |
from wemake_python_styleguide.presets.types import tree as tree_preset |
| 34 |
from wemake_python_styleguide.transformations.ast_tree import transform |
| 35 |
from wemake_python_styleguide.violations import system |
| 36 |
from wemake_python_styleguide.visitors import base |
| 37 |
|
| 38 |
VisitorClass = Type[base.BaseVisitor] |
| 39 |
""" |
| 40 |
) |
| 41 |
|
| 42 |
|
| 43 |
def test_wemake_snippet_two() -> None: |
| 44 |
wemake_isort_test( |
| 45 |
""" |
| 46 |
from collections import defaultdict |
| 47 |
from typing import ClassVar, DefaultDict, List |
| 48 |
|
| 49 |
from flake8.formatting.base import BaseFormatter |
| 50 |
from flake8.statistics import Statistics |
| 51 |
from flake8.style_guide import Violation |
| 52 |
from pygments import highlight |
| 53 |
from pygments.formatters import TerminalFormatter |
| 54 |
from pygments.lexers import PythonLexer |
| 55 |
from typing_extensions import Final |
| 56 |
|
| 57 |
from wemake_python_styleguide.version import pkg_version |
| 58 |
|
| 59 |
#: That url is generated and hosted by Sphinx. |
| 60 |
DOCS_URL_TEMPLATE: Final = ( |
| 61 |
'https://wemake-python-stylegui.de/en/{0}/pages/usage/violations/' |
| 62 |
) |
| 63 |
""" |
| 64 |
) |
| 65 |
|
| 66 |
|
| 67 |
def test_wemake_snippet_three() -> None: |
| 68 |
wemake_isort_test( |
| 69 |
""" |
| 70 |
import ast |
| 71 |
|
| 72 |
from pep8ext_naming import NamingChecker |
| 73 |
from typing_extensions import final |
| 74 |
|
| 75 |
from wemake_python_styleguide.transformations.ast.bugfixes import ( |
| 76 |
fix_async_offset, |
| 77 |
fix_line_number, |
| 78 |
) |
| 79 |
from wemake_python_styleguide.transformations.ast.enhancements import ( |
| 80 |
set_if_chain, |
| 81 |
set_node_context, |
| 82 |
) |
| 83 |
|
| 84 |
|
| 85 |
@final |
| 86 |
class _ClassVisitor(ast.NodeVisitor): ... |
| 87 |
""" |
| 88 |
) |
| 89 |
|
| 90 |
|
| 91 |
def test_wemake_snippet_four() -> None: |
| 92 |
"""80 line length should not be fixed""" |
| 93 |
wemake_isort_test( |
| 94 |
""" |
| 95 |
from typing import Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union |
| 96 |
""", |
| 97 |
""" |
| 98 |
from typing import Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union |
| 99 |
""", |
| 100 |
) |
| 101 |
|
| 102 |
|
| 103 |
def test_wemake_snippet_five() -> None: |
| 104 |
"""81 line length should be fixed""" |
| 105 |
wemake_isort_test( |
| 106 |
""" |
| 107 |
from typing import Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union1 |
| 108 |
""", |
| 109 |
""" |
| 110 |
from typing import ( |
| 111 |
Iterable, |
| 112 |
Iterator, |
| 113 |
Optional, |
| 114 |
Sequence, |
| 115 |
Tuple, |
| 116 |
TypeVar, |
| 117 |
Union1, |
| 118 |
) |
| 119 |
""", |
| 120 |
) |