File: test_lcsseq.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 (41 lines) | stat: -rw-r--r-- 960 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
39
40
41
# external
import pytest

# project
import textdistance


ALG = textdistance.LCSSeq


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

    ('test', 'text', 'tet'),
    ('thisisatest', 'testing123testing', 'tsitest'),
    ('DIXON', 'DICKSONX', 'DION'),
    ('random exponential', 'layer activation', 'ratia'),

    ('a' * 80, 'a' * 80, 'a' * 80),
    ('a' * 80, 'b' * 80, ''),
])
def test_distance(left, right, expected):
    actual = ALG(external=False)(left, right)
    assert actual == expected

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


@pytest.mark.parametrize('seqs, expected', [
    (('a', 'b', 'c'), ''),
    (('a', 'a', 'a'), 'a'),
    (('test', 'text', 'tempest'), 'tet'),
])
def test_distance_multiseq(seqs, expected):
    actual = ALG(external=False)(*seqs)
    assert actual == expected

    actual = ALG(external=True)(*seqs)
    assert actual == expected