-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_list_diff.py
More file actions
35 lines (30 loc) · 889 Bytes
/
test_list_diff.py
File metadata and controls
35 lines (30 loc) · 889 Bytes
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
import pytest
from utils.list_diff import get_list_diff
@pytest.mark.parametrize('l1, l2, res', [
(
['a', 'bc', 'def', 'g'],
['a', 'b', 'c', 'd', 'e', 'f', 'g'],
[(1, 2, 1, 3), (2, 3, 3, 6)]
),
(
['a', 'b', 'c', 'd', 'e', 'f', 'g'],
['a', 'bc', 'def', 'g'],
[(1, 3, 1, 2), (3, 6, 2, 3)],
),
(
['a', 'b', 'c', 'def', 'g'],
['a', 'bc', 'd', 'e', 'f', 'g'],
[(1, 3, 1, 2), (3, 4, 2, 5)]
),
(
['a', 'bc', 'de', 'f'],
['a', 'b', 'cd', 'e', 'f'],
[(1, 3, 1, 4)]
)
])
def test_list_diff(l1, l2, res):
assert get_list_diff(l1, l2) == res
def test_list_diff_invalid():
# 如果两个列表包含的所有字符不同,应该抛出断言错误
with pytest.raises(AssertionError):
get_list_diff(['a', 'bc', 'd', 'e'], ['a', 'b', 'cd', 'e', 'f'])