python-liquid 2.0.0__py3-none-any.whl → 2.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- liquid/__init__.py +1 -1
- liquid/builtin/expressions/loop.py +2 -5
- liquid/builtin/loaders/mixins.py +1 -2
- liquid/extra/tags/macro_tag.py +2 -0
- liquid/messages.py +1 -1
- liquid/static_analysis.py +16 -10
- {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/METADATA +6 -9
- python_liquid-2.0.2.dist-info/RECORD +95 -0
- liquid/golden/__init__.py +0 -173
- liquid/golden/abs_filter.py +0 -73
- liquid/golden/append_filter.py +0 -43
- liquid/golden/assign_tag.py +0 -45
- liquid/golden/at_least_filter.py +0 -78
- liquid/golden/at_most_filter.py +0 -68
- liquid/golden/base64_decode_filter.py +0 -43
- liquid/golden/base64_encode_filter.py +0 -42
- liquid/golden/base64_url_safe_decode_filter.py +0 -43
- liquid/golden/base64_url_safe_encode_filter.py +0 -42
- liquid/golden/capitalize_filter.py +0 -27
- liquid/golden/capture_tag.py +0 -39
- liquid/golden/case.py +0 -28
- liquid/golden/case_tag.py +0 -226
- liquid/golden/ceil_filter.py +0 -63
- liquid/golden/comment_tag.py +0 -119
- liquid/golden/compact_filter.py +0 -54
- liquid/golden/concat_filter.py +0 -63
- liquid/golden/cycle_tag.py +0 -114
- liquid/golden/date_filter.py +0 -63
- liquid/golden/decrement_tag.py +0 -16
- liquid/golden/default_filter.py +0 -112
- liquid/golden/divided_by_filter.py +0 -101
- liquid/golden/doc_tag.py +0 -61
- liquid/golden/downcase_filter.py +0 -27
- liquid/golden/echo_tag.py +0 -116
- liquid/golden/escape_filter.py +0 -27
- liquid/golden/escape_once_filter.py +0 -32
- liquid/golden/find_filter.py +0 -90
- liquid/golden/find_index_filter.py +0 -96
- liquid/golden/first_filter.py +0 -51
- liquid/golden/floor_filter.py +0 -63
- liquid/golden/for_tag.py +0 -642
- liquid/golden/has_filter.py +0 -139
- liquid/golden/identifiers.py +0 -249
- liquid/golden/if_tag.py +0 -531
- liquid/golden/ifchanged_tag.py +0 -46
- liquid/golden/illegal.py +0 -34
- liquid/golden/include_tag.py +0 -196
- liquid/golden/increment_tag.py +0 -48
- liquid/golden/inline_comment_tag.py +0 -127
- liquid/golden/join_filter.py +0 -69
- liquid/golden/last_filter.py +0 -51
- liquid/golden/liquid_tag.py +0 -215
- liquid/golden/lstrip_filter.py +0 -37
- liquid/golden/map_filter.py +0 -50
- liquid/golden/minus_filter.py +0 -58
- liquid/golden/modulo_filter.py +0 -60
- liquid/golden/newline_to_br_filter.py +0 -37
- liquid/golden/not_liquid.py +0 -16
- liquid/golden/output_statement.py +0 -295
- liquid/golden/plus_filter.py +0 -63
- liquid/golden/prepend_filter.py +0 -43
- liquid/golden/range_objects.py +0 -79
- liquid/golden/raw_tag.py +0 -31
- liquid/golden/reject_filter.py +0 -268
- liquid/golden/remove_filter.py +0 -45
- liquid/golden/remove_first_filter.py +0 -46
- liquid/golden/remove_last_filter.py +0 -46
- liquid/golden/render_tag.py +0 -210
- liquid/golden/replace_filter.py +0 -65
- liquid/golden/replace_first_filter.py +0 -59
- liquid/golden/replace_last_filter.py +0 -60
- liquid/golden/reverse_filter.py +0 -42
- liquid/golden/round_filter.py +0 -87
- liquid/golden/rstrip_filter.py +0 -37
- liquid/golden/size_filter.py +0 -42
- liquid/golden/slice_filter.py +0 -119
- liquid/golden/sort_filter.py +0 -86
- liquid/golden/sort_natural_filter.py +0 -105
- liquid/golden/special.py +0 -91
- liquid/golden/split_filter.py +0 -128
- liquid/golden/strip_filter.py +0 -37
- liquid/golden/strip_html_filter.py +0 -74
- liquid/golden/strip_newlines_filter.py +0 -37
- liquid/golden/sum_filter.py +0 -97
- liquid/golden/tablerow_tag.py +0 -399
- liquid/golden/times_filter.py +0 -53
- liquid/golden/truncate_filter.py +0 -61
- liquid/golden/truncatewords_filter.py +0 -94
- liquid/golden/uniq_filter.py +0 -87
- liquid/golden/unless_tag.py +0 -101
- liquid/golden/upcase_filter.py +0 -27
- liquid/golden/url_decode_filter.py +0 -27
- liquid/golden/url_encode_filter.py +0 -27
- liquid/golden/where_filter.py +0 -122
- liquid/golden/whitespace_control.py +0 -281
- python_liquid-2.0.0.dist-info/RECORD +0 -182
- {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/WHEEL +0 -0
- {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/licenses/LICENSE +0 -0
liquid/golden/special.py
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"""Golden test cases for testing Liquid's special, built-in properties."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="first of an array",
|
|
8
|
-
template=r"{{ a.first }}",
|
|
9
|
-
expect="3",
|
|
10
|
-
globals={"a": [3, 2, 1]},
|
|
11
|
-
),
|
|
12
|
-
Case(
|
|
13
|
-
description="last of an array",
|
|
14
|
-
template=r"{{ a.last }}",
|
|
15
|
-
expect="1",
|
|
16
|
-
globals={"a": [3, 2, 1]},
|
|
17
|
-
),
|
|
18
|
-
Case(
|
|
19
|
-
description="size of an array",
|
|
20
|
-
template=r"{{ a.size }}",
|
|
21
|
-
expect="3",
|
|
22
|
-
globals={"a": [3, 2, 1]},
|
|
23
|
-
),
|
|
24
|
-
Case(
|
|
25
|
-
description="size of a string",
|
|
26
|
-
template=r"{{ s.size }}",
|
|
27
|
-
expect="5",
|
|
28
|
-
globals={"s": "hello"},
|
|
29
|
-
),
|
|
30
|
-
Case(
|
|
31
|
-
description="first of a string",
|
|
32
|
-
template=r"{{ s.first }}",
|
|
33
|
-
expect="",
|
|
34
|
-
globals={"s": "hello"},
|
|
35
|
-
),
|
|
36
|
-
Case(
|
|
37
|
-
description="first of an object",
|
|
38
|
-
template=r"{{ obj.first | join: '#' }}",
|
|
39
|
-
expect="a#1",
|
|
40
|
-
globals={"obj": {"a": 1, "b": 2}},
|
|
41
|
-
),
|
|
42
|
-
Case(
|
|
43
|
-
description="first of an empty object",
|
|
44
|
-
template=r"{{ obj.first | join: '#' }}",
|
|
45
|
-
expect="",
|
|
46
|
-
globals={"obj": {}},
|
|
47
|
-
),
|
|
48
|
-
Case(
|
|
49
|
-
description="last of a string",
|
|
50
|
-
template=r"{{ s.last }}",
|
|
51
|
-
expect="",
|
|
52
|
-
globals={"s": "hello"},
|
|
53
|
-
),
|
|
54
|
-
Case(
|
|
55
|
-
description="last of a object",
|
|
56
|
-
template=r"{{ obj.last }}",
|
|
57
|
-
expect="",
|
|
58
|
-
globals={"obj": {"a": 1, "b": 2}},
|
|
59
|
-
),
|
|
60
|
-
Case(
|
|
61
|
-
description="size of an object with a size property",
|
|
62
|
-
template=r"{{ obj.size }}",
|
|
63
|
-
expect="99",
|
|
64
|
-
globals={"obj": {"size": 99}},
|
|
65
|
-
),
|
|
66
|
-
Case(
|
|
67
|
-
description="first of an object with a first property",
|
|
68
|
-
template=r"{{ obj.first }}",
|
|
69
|
-
expect="99",
|
|
70
|
-
globals={"obj": {"a": 1, "first": 99}},
|
|
71
|
-
),
|
|
72
|
-
Case(
|
|
73
|
-
description="last of an object with a last property",
|
|
74
|
-
template=r"{{ obj.last }}",
|
|
75
|
-
expect="99",
|
|
76
|
-
globals={"obj": {"a": 1, "last": 99, "b": 42}},
|
|
77
|
-
),
|
|
78
|
-
Case(
|
|
79
|
-
description="size of undefined",
|
|
80
|
-
template=r"{{ nosuchthing.last }}",
|
|
81
|
-
expect="",
|
|
82
|
-
globals={},
|
|
83
|
-
),
|
|
84
|
-
Case(
|
|
85
|
-
description="size of an int",
|
|
86
|
-
template=r"{{ x.size }}",
|
|
87
|
-
expect="",
|
|
88
|
-
globals={"x": 1},
|
|
89
|
-
standard=False,
|
|
90
|
-
),
|
|
91
|
-
]
|
liquid/golden/split_filter.py
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `split` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="split string",
|
|
8
|
-
template=r'{{ "Hi, how are you today?" | split: " " | join: "#" }}',
|
|
9
|
-
expect="Hi,#how#are#you#today?",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="not a string",
|
|
13
|
-
template=r"{{ 56 | split: ' ' | first }}",
|
|
14
|
-
expect="56",
|
|
15
|
-
),
|
|
16
|
-
Case(
|
|
17
|
-
description="argument not a string",
|
|
18
|
-
template=r'{{ "hello th1ere" | split: 1 | join: "#" }}',
|
|
19
|
-
expect="hello th#ere",
|
|
20
|
-
),
|
|
21
|
-
Case(
|
|
22
|
-
description="missing argument",
|
|
23
|
-
template=r'{{ "hello there" | split }}',
|
|
24
|
-
expect="",
|
|
25
|
-
error=True,
|
|
26
|
-
),
|
|
27
|
-
Case(
|
|
28
|
-
description="too many arguments",
|
|
29
|
-
template=r'{{ "hello there" | split: " ", "," }}',
|
|
30
|
-
expect="",
|
|
31
|
-
error=True,
|
|
32
|
-
),
|
|
33
|
-
Case(
|
|
34
|
-
description="undefined left value",
|
|
35
|
-
template=r'{{ nosuchthing | split: " " }}',
|
|
36
|
-
expect="",
|
|
37
|
-
),
|
|
38
|
-
Case(
|
|
39
|
-
description="undefined argument",
|
|
40
|
-
template=r'{{ "Hello there" | split: nosuchthing | join: "#" }}',
|
|
41
|
-
expect="H#e#l#l#o# #t#h#e#r#e",
|
|
42
|
-
),
|
|
43
|
-
Case(
|
|
44
|
-
description="empty string argument",
|
|
45
|
-
template=(
|
|
46
|
-
r'{% assign a = "abc" | split: "" %}'
|
|
47
|
-
r"{% for i in a %}#{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
48
|
-
),
|
|
49
|
-
expect="#0a#1b#2c",
|
|
50
|
-
future=True,
|
|
51
|
-
),
|
|
52
|
-
Case(
|
|
53
|
-
description="argument is a single space",
|
|
54
|
-
template=(
|
|
55
|
-
'{% assign a = "a b\nc" | split: " " %}'
|
|
56
|
-
r"{% for i in a %}#{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
57
|
-
),
|
|
58
|
-
expect="#0a#1b#2c",
|
|
59
|
-
future=True,
|
|
60
|
-
),
|
|
61
|
-
Case(
|
|
62
|
-
description="argument is nil",
|
|
63
|
-
template='{{ "Hello there" | split: nil | join: "#" }}',
|
|
64
|
-
expect="H#e#l#l#o# #t#h#e#r#e",
|
|
65
|
-
future=True,
|
|
66
|
-
),
|
|
67
|
-
Case(
|
|
68
|
-
description="argument is false",
|
|
69
|
-
template='{{ "Hello there" | split: false | join: "#" }}',
|
|
70
|
-
expect="Hello there",
|
|
71
|
-
future=True,
|
|
72
|
-
),
|
|
73
|
-
Case(
|
|
74
|
-
description="argument is a newline",
|
|
75
|
-
template=(
|
|
76
|
-
'{% assign a = "a b\nc" | split: x %}'
|
|
77
|
-
r"{% for i in a %}#{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
78
|
-
),
|
|
79
|
-
globals={"x": "\n"},
|
|
80
|
-
expect="#0a b#1c",
|
|
81
|
-
future=True,
|
|
82
|
-
),
|
|
83
|
-
Case(
|
|
84
|
-
description="argument does not appear in string",
|
|
85
|
-
template=(
|
|
86
|
-
r'{% assign a = "abc" | split: "," %}'
|
|
87
|
-
r"{% for i in a %}#{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
88
|
-
),
|
|
89
|
-
expect="#0abc",
|
|
90
|
-
future=True,
|
|
91
|
-
),
|
|
92
|
-
Case(
|
|
93
|
-
description="empty string and empty argument",
|
|
94
|
-
template=(
|
|
95
|
-
r'{% assign a = "" | split: "" %}'
|
|
96
|
-
r"{% for i in a %}{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
97
|
-
),
|
|
98
|
-
expect="",
|
|
99
|
-
future=True,
|
|
100
|
-
),
|
|
101
|
-
Case(
|
|
102
|
-
description="empty string and single char argument",
|
|
103
|
-
template=(
|
|
104
|
-
r'{% assign a = "" | split: "," %}'
|
|
105
|
-
r"{% for i in a %}{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
106
|
-
),
|
|
107
|
-
expect="",
|
|
108
|
-
future=True,
|
|
109
|
-
),
|
|
110
|
-
Case(
|
|
111
|
-
description="left matches argument",
|
|
112
|
-
template=(
|
|
113
|
-
r'{% assign a = "," | split: "," %}'
|
|
114
|
-
r"{% for i in a %}{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
115
|
-
),
|
|
116
|
-
expect="",
|
|
117
|
-
future=True,
|
|
118
|
-
),
|
|
119
|
-
Case(
|
|
120
|
-
description="left matches string repr of argument",
|
|
121
|
-
template=(
|
|
122
|
-
r'{% assign a = "1" | split: 1 %}'
|
|
123
|
-
r"{% for i in a %}{{ forloop.index0 }}{{ i }}{% endfor %}"
|
|
124
|
-
),
|
|
125
|
-
expect="",
|
|
126
|
-
future=True,
|
|
127
|
-
),
|
|
128
|
-
]
|
liquid/golden/strip_filter.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `strip` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="left padded",
|
|
8
|
-
template='{{ " \t\r\n hello" | strip }}',
|
|
9
|
-
expect="hello",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="right padded",
|
|
13
|
-
template='{{ "hello \t\r\n " | strip }}',
|
|
14
|
-
expect="hello",
|
|
15
|
-
),
|
|
16
|
-
Case(
|
|
17
|
-
description="left and right padded",
|
|
18
|
-
template='{{ " \t\r\n hello \t\r\n " | strip }}',
|
|
19
|
-
expect="hello",
|
|
20
|
-
),
|
|
21
|
-
Case(
|
|
22
|
-
description="not a string",
|
|
23
|
-
template=r"{{ 5 | strip }}",
|
|
24
|
-
expect="5",
|
|
25
|
-
),
|
|
26
|
-
Case(
|
|
27
|
-
description="unexpected argument",
|
|
28
|
-
template=r'{{ "hello" | strip: 5 }}',
|
|
29
|
-
expect="",
|
|
30
|
-
error=True,
|
|
31
|
-
),
|
|
32
|
-
Case(
|
|
33
|
-
description="undefined left value",
|
|
34
|
-
template=r"{{ nosuchthing | strip }}",
|
|
35
|
-
expect="",
|
|
36
|
-
),
|
|
37
|
-
]
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `strip_html` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="some HTML markup",
|
|
8
|
-
template=r"{{ s | strip_html }}",
|
|
9
|
-
expect="Have you read Ulysses & ?",
|
|
10
|
-
globals={"s": "Have <em>you</em> read <strong>Ulysses</strong> & ?"},
|
|
11
|
-
),
|
|
12
|
-
Case(
|
|
13
|
-
description="some HTML markup with HTML comment",
|
|
14
|
-
template=r"{{ s | strip_html }}",
|
|
15
|
-
expect="you read Ulysses & ?",
|
|
16
|
-
globals={
|
|
17
|
-
"s": "<!-- Have --><em>you</em> read <strong>Ulysses</strong> & ?"
|
|
18
|
-
},
|
|
19
|
-
),
|
|
20
|
-
Case(
|
|
21
|
-
description="not a string",
|
|
22
|
-
template=r"{{ 5 | strip_html }}",
|
|
23
|
-
expect="5",
|
|
24
|
-
),
|
|
25
|
-
Case(
|
|
26
|
-
description="unexpected argument",
|
|
27
|
-
template=r'{{ "hello" | strip_html: 5 }}',
|
|
28
|
-
expect="",
|
|
29
|
-
error=True,
|
|
30
|
-
),
|
|
31
|
-
Case(
|
|
32
|
-
description="undefined left value",
|
|
33
|
-
template=r"{{ nosuchthing | strip_html }}",
|
|
34
|
-
expect="",
|
|
35
|
-
),
|
|
36
|
-
Case(
|
|
37
|
-
description="html block",
|
|
38
|
-
template=r"{{ s | strip_html }}",
|
|
39
|
-
expect="test",
|
|
40
|
-
globals={"s": "<div>test</div>"},
|
|
41
|
-
),
|
|
42
|
-
Case(
|
|
43
|
-
description="html block with id",
|
|
44
|
-
template=r"{{ s | strip_html }}",
|
|
45
|
-
expect="test",
|
|
46
|
-
globals={"s": "<div id='test'>test</div>"},
|
|
47
|
-
),
|
|
48
|
-
Case(
|
|
49
|
-
description="script block",
|
|
50
|
-
template=r"{{ s | strip_html }}",
|
|
51
|
-
expect="",
|
|
52
|
-
globals={
|
|
53
|
-
"s": "<script type='text/javascript'>document.write('some stuff');</script>"
|
|
54
|
-
},
|
|
55
|
-
),
|
|
56
|
-
Case(
|
|
57
|
-
description="style block",
|
|
58
|
-
template=r"{{ s | strip_html }}",
|
|
59
|
-
expect="",
|
|
60
|
-
globals={"s": "<style type='text/css'>foo bar</style>"},
|
|
61
|
-
),
|
|
62
|
-
Case(
|
|
63
|
-
description="html block with newline",
|
|
64
|
-
template=r"{{ s | strip_html }}",
|
|
65
|
-
expect="test",
|
|
66
|
-
globals={"s": "<div\nclass='multiline'>test</div>"},
|
|
67
|
-
),
|
|
68
|
-
Case(
|
|
69
|
-
description="html comment with newline",
|
|
70
|
-
template=r"{{ s | strip_html }}",
|
|
71
|
-
expect="test",
|
|
72
|
-
globals={"s": "<!-- foo bar \n test -->test"},
|
|
73
|
-
),
|
|
74
|
-
]
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `strip_newlines` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="newline and other whitespace",
|
|
8
|
-
template='{{ "hello there\nyou" | strip_newlines }}',
|
|
9
|
-
expect="hello thereyou",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="not a string",
|
|
13
|
-
template="{{ 5 | strip_newlines }}",
|
|
14
|
-
expect="5",
|
|
15
|
-
),
|
|
16
|
-
Case(
|
|
17
|
-
description="unexpected argument",
|
|
18
|
-
template='{{ "hello" | strip_newlines: 5 }}',
|
|
19
|
-
expect="",
|
|
20
|
-
error=True,
|
|
21
|
-
),
|
|
22
|
-
Case(
|
|
23
|
-
description="reference implementation test 1",
|
|
24
|
-
template='{{ "a\nb\nc" | strip_newlines }}',
|
|
25
|
-
expect="abc",
|
|
26
|
-
),
|
|
27
|
-
Case(
|
|
28
|
-
description="reference implementation test 2",
|
|
29
|
-
template='{{ "a\r\nb\nc" | strip_newlines }}',
|
|
30
|
-
expect="abc",
|
|
31
|
-
),
|
|
32
|
-
Case(
|
|
33
|
-
description="undefined left value",
|
|
34
|
-
template="{{ nosuchthing | strip_newlines }}",
|
|
35
|
-
expect="",
|
|
36
|
-
),
|
|
37
|
-
]
|
liquid/golden/sum_filter.py
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `sum` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="empty sequence",
|
|
8
|
-
template=r"{{ a | sum }}",
|
|
9
|
-
expect="0",
|
|
10
|
-
globals={"a": []},
|
|
11
|
-
),
|
|
12
|
-
Case(
|
|
13
|
-
description="only zeros",
|
|
14
|
-
template=r"{{ a | sum }}",
|
|
15
|
-
expect="0",
|
|
16
|
-
globals={"a": [0, 0, 0]},
|
|
17
|
-
),
|
|
18
|
-
Case(
|
|
19
|
-
description="ints",
|
|
20
|
-
template=r"{{ a | sum }}",
|
|
21
|
-
expect="6",
|
|
22
|
-
globals={"a": [1, 2, 3]},
|
|
23
|
-
),
|
|
24
|
-
Case(
|
|
25
|
-
description="negative ints",
|
|
26
|
-
template=r"{{ a | sum }}",
|
|
27
|
-
expect="-6",
|
|
28
|
-
globals={"a": [-1, -2, -3]},
|
|
29
|
-
),
|
|
30
|
-
# Case(
|
|
31
|
-
# description="floats",
|
|
32
|
-
# template=r"{{ a | sum }}",
|
|
33
|
-
# expect="0.6",
|
|
34
|
-
# globals={"a": [0.1, 0.2, 0.3]},
|
|
35
|
-
# ),
|
|
36
|
-
# Case(
|
|
37
|
-
# description="float strings",
|
|
38
|
-
# template=r"{{ a | sum }}",
|
|
39
|
-
# expect="0.6",
|
|
40
|
-
# globals={"a": ["0.1", "0.2", "0.3"]},
|
|
41
|
-
# ),
|
|
42
|
-
# Case(
|
|
43
|
-
# description="floats and ints",
|
|
44
|
-
# template=r"{{ a | sum }}",
|
|
45
|
-
# expect="6.6",
|
|
46
|
-
# globals={"a": [0.1, 0.2, 0.3, 1, 2, 3]},
|
|
47
|
-
# ),
|
|
48
|
-
Case(
|
|
49
|
-
description="negative strings",
|
|
50
|
-
template=r"{{ a | sum }}",
|
|
51
|
-
expect="-6",
|
|
52
|
-
globals={"a": ["-1", "-2", "-3"]},
|
|
53
|
-
),
|
|
54
|
-
Case(
|
|
55
|
-
description="positive and negative ints",
|
|
56
|
-
template=r"{{ a | sum }}",
|
|
57
|
-
expect="5",
|
|
58
|
-
globals={"a": [-2, -3, 10]},
|
|
59
|
-
),
|
|
60
|
-
Case(
|
|
61
|
-
description="nested ints",
|
|
62
|
-
template=r"{{ a | sum }}",
|
|
63
|
-
expect="6",
|
|
64
|
-
globals={"a": [1, [2, [3]]]},
|
|
65
|
-
),
|
|
66
|
-
Case(
|
|
67
|
-
description="hashes with property argument",
|
|
68
|
-
template=r"{{ a | sum: 'k' }}",
|
|
69
|
-
expect="6",
|
|
70
|
-
globals={"a": [{"k": 1}, {"k": 2}, {"k": 3}]},
|
|
71
|
-
),
|
|
72
|
-
Case(
|
|
73
|
-
description="hashes with numeric strings and property argument",
|
|
74
|
-
template=r"{{ a | sum: 'k' }}",
|
|
75
|
-
expect="6",
|
|
76
|
-
globals={"a": [{"k": "1"}, {"k": "2"}, {"k": "3"}]},
|
|
77
|
-
),
|
|
78
|
-
Case(
|
|
79
|
-
description="hashes without property argument",
|
|
80
|
-
template=r"{{ a | sum }}",
|
|
81
|
-
expect="0",
|
|
82
|
-
globals={"a": [{"k": 1}, {"k": 2}, {"k": 3}]},
|
|
83
|
-
),
|
|
84
|
-
Case(
|
|
85
|
-
description="hashes with some missing properties",
|
|
86
|
-
template=r"{{ a | sum: 'k' }}",
|
|
87
|
-
expect="3",
|
|
88
|
-
globals={"a": [{"k": 1}, {"k": 2}, {"x": 3}]},
|
|
89
|
-
),
|
|
90
|
-
Case(
|
|
91
|
-
description="properties arguments with non-hash items",
|
|
92
|
-
template=r"{{ a | sum: 'k' }}",
|
|
93
|
-
expect="3",
|
|
94
|
-
globals={"a": [1, 2, 3]},
|
|
95
|
-
error=True,
|
|
96
|
-
),
|
|
97
|
-
]
|