File: test_lcsstr.py

package info (click to toggle)
textdistance 4.6.3-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 448 kB
  • sloc: python: 2,728; sh: 4; makefile: 3
file content (38 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
# external
import pytest

# project
import textdistance


ALG = textdistance.LCSStr


@pytest.mark.parametrize('left, right, expected', [
    # prefix
    ('ab', 'abcd', 'ab'),
    ('abcd', 'ab', 'ab'),

    # middle
    ('abcd', 'bc', 'bc'),
    ('bc', 'abcd', 'bc'),

    # suffix
    ('abcd', 'cd', 'cd'),
    ('abcd', 'cd', 'cd'),

    # no
    ('abcd', 'ef', ''),
    ('ef', 'abcd', ''),

    # long
    # https://github.com/life4/textdistance/issues/40
    ('MYTEST' * 100, 'TEST', 'TEST'),
    ('TEST', 'MYTEST' * 100, 'TEST'),
])
def test_distance(left, right, expected):
    actual = ALG(external=False)(left, right)
    assert actual == expected

    actual = ALG(external=True)(left, right)
    assert actual == expected