Add tests for normalize_path and normalize_paths

This commit is contained in:
Ian Cordasco 2016-01-09 21:04:11 -06:00
parent 13ca3dfe37
commit ec26d46dff

View file

@ -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