mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 10:36:53 +00:00
Add tests for normalize_path and normalize_paths
This commit is contained in:
parent
13ca3dfe37
commit
ec26d46dff
1 changed files with 27 additions and 0 deletions
|
|
@ -1,9 +1,14 @@
|
|||
"""Tests for flake8's utils module."""
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from flake8 import utils
|
||||
|
||||
|
||||
RELATIVE_PATHS = ["flake8", "pep8", "pyflakes", "mccabe"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value,expected", [
|
||||
("E123,\n\tW234,\n E206", ["E123", "W234", "E206"]),
|
||||
("E123,W234,E206", ["E123", "W234", "E206"]),
|
||||
|
|
@ -11,4 +16,26 @@ from flake8 import utils
|
|||
(["E123", "\n\tW234", "\n E206"], ["E123", "W234", "E206"]),
|
||||
])
|
||||
def test_parse_comma_separated_list(value, expected):
|
||||
"""Verify that similar inputs produce identical outputs."""
|
||||
assert utils.parse_comma_separated_list(value) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value,expected", [
|
||||
("flake8", "flake8"),
|
||||
("../flake8", os.path.abspath("../flake8")),
|
||||
("flake8/", os.path.abspath("flake8")),
|
||||
])
|
||||
def test_normalize_path(value, expected):
|
||||
"""Verify that we normalize paths provided to the tool."""
|
||||
assert utils.normalize_path(value) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value,expected", [
|
||||
("flake8,pep8,pyflakes,mccabe", ["flake8", "pep8", "pyflakes", "mccabe"]),
|
||||
("flake8,\n\tpep8,\n pyflakes,\n\n mccabe",
|
||||
["flake8", "pep8", "pyflakes", "mccabe"]),
|
||||
("../flake8,../pep8,../pyflakes,../mccabe",
|
||||
[os.path.abspath("../" + p) for p in RELATIVE_PATHS]),
|
||||
])
|
||||
def test_normalize_paths(value, expected):
|
||||
assert utils.normalize_paths(value) == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue