forked from PyCQA/pydocstyle
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_utils.py
33 lines (20 loc) · 917 Bytes
/
test_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Unit test for pydocstyle utils.
Use tox or pytest to run the test suite.
"""
from pydocstyle import utils
__all__ = ()
def test_common_prefix():
"""Test common prefix length of two strings."""
assert utils.common_prefix_length('abcd', 'abce') == 3
def test_no_common_prefix():
"""Test common prefix length of two strings that have no common prefix."""
assert utils.common_prefix_length('abcd', 'cdef') == 0
def test_differ_length():
"""Test common prefix length of two strings differing in length."""
assert utils.common_prefix_length('abcd', 'ab') == 2
def test_empty_string():
"""Test common prefix length of two strings, one of them empty."""
assert utils.common_prefix_length('abcd', '') == 0
def test_strip_non_alphanumeric():
"""Test strip of a string leaves only alphanumeric characters."""
assert utils.strip_non_alphanumeric(" 1abcd1...") == "1abcd1"