[e988c2]: / tests / spec / str_series_ops / test_contains.py

Download this file

112 lines (100 with data), 2.2 kB

  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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
from ..tables import p
title = "Testing whether one string contains another string"
def test_contains_fixed_value(spec_test):
table_data = {
p: """
| s1
--+--------
1 | ab
2 | ab12
3 | 12ab
4 | 12ab45
5 | a b
6 | AB
7 |
""",
}
spec_test(
table_data,
p.s1.contains("ab"),
{
1: True,
2: True,
3: True,
4: True,
5: False,
6: False,
7: None,
},
)
def test_contains_fixed_value_with_special_characters(spec_test):
table_data = {
p: """
| s1
--+-------
1 | /a%b_
2 | /ab_
3 | /a%bc
4 | a%b_
""",
}
spec_test(
table_data,
p.s1.contains("/a%b_"),
{
1: True,
2: False,
3: False,
4: False,
},
)
def test_contains_value_from_column(spec_test):
table_data = {
p: """
| s1 | s2
--+--------+----
1 | ab | ab
2 | cd12 | cd
3 | 12ef | ef
4 | 12gh45 | gh
5 | i j | ij
6 | KL | kl
7 | | mn
8 | ab |
""",
}
spec_test(
table_data,
p.s1.contains(p.s2),
{
1: True,
2: True,
3: True,
4: True,
5: False,
6: False,
7: None,
8: None,
},
)
def test_contains_value_from_column_with_special_characters(spec_test):
table_data = {
p: """
| s1 | s2
--+-------+-------
1 | /a%b_ | /a%b_
2 | /ab_ | /a%b_
3 | /a%bc | /a%b_
4 | a%b_ | /a%b_
""",
}
spec_test(
table_data,
p.s1.contains(p.s2),
{
1: True,
2: False,
3: False,
4: False,
},
)