Start writing unit tests
This commit is contained in:
parent
ab24097866
commit
1c438931ff
44
test.py
Normal file
44
test.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
from string import punctuation, whitespace
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from normalisename import Normalisename
|
||||||
|
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
|
|
||||||
|
SEP = '_'
|
||||||
|
WHLI = {'.', '-'}
|
||||||
|
OP = None
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def normalise():
|
||||||
|
return Normalisename(SEP, WHLI, OP)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'before, after', [
|
||||||
|
(
|
||||||
|
f'this{ws}is{ws}{ws}a{ws}cat',
|
||||||
|
f'this{SEP}is{SEP}a{SEP}cat'
|
||||||
|
) for ws in whitespace
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_replace_whitespaces_with_separator(normalise, before, after):
|
||||||
|
assert normalise(before) == after
|
||||||
|
|
||||||
|
|
||||||
|
def test_remove_funky_characters(normalise):
|
||||||
|
assert normalise(''.join(set(punctuation).difference(WHLI.union({SEP, '/'})))) == ''
|
||||||
|
|
||||||
|
|
||||||
|
def test_remove_accent_from_letters(normalise):
|
||||||
|
assert normalise('éáűöüóőú') == 'eauouoou'
|
||||||
|
|
||||||
|
|
||||||
|
def test_dirname_is_not_changed(normalise):
|
||||||
|
assert False
|
||||||
|
|
||||||
|
|
||||||
|
def test_name_with_trailing_slash_is_normalised(normalise):
|
||||||
|
assert False
|
Loading…
Reference in New Issue
Block a user