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.
Files changed (98) hide show
  1. liquid/__init__.py +1 -1
  2. liquid/builtin/expressions/loop.py +2 -5
  3. liquid/builtin/loaders/mixins.py +1 -2
  4. liquid/extra/tags/macro_tag.py +2 -0
  5. liquid/messages.py +1 -1
  6. liquid/static_analysis.py +16 -10
  7. {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/METADATA +6 -9
  8. python_liquid-2.0.2.dist-info/RECORD +95 -0
  9. liquid/golden/__init__.py +0 -173
  10. liquid/golden/abs_filter.py +0 -73
  11. liquid/golden/append_filter.py +0 -43
  12. liquid/golden/assign_tag.py +0 -45
  13. liquid/golden/at_least_filter.py +0 -78
  14. liquid/golden/at_most_filter.py +0 -68
  15. liquid/golden/base64_decode_filter.py +0 -43
  16. liquid/golden/base64_encode_filter.py +0 -42
  17. liquid/golden/base64_url_safe_decode_filter.py +0 -43
  18. liquid/golden/base64_url_safe_encode_filter.py +0 -42
  19. liquid/golden/capitalize_filter.py +0 -27
  20. liquid/golden/capture_tag.py +0 -39
  21. liquid/golden/case.py +0 -28
  22. liquid/golden/case_tag.py +0 -226
  23. liquid/golden/ceil_filter.py +0 -63
  24. liquid/golden/comment_tag.py +0 -119
  25. liquid/golden/compact_filter.py +0 -54
  26. liquid/golden/concat_filter.py +0 -63
  27. liquid/golden/cycle_tag.py +0 -114
  28. liquid/golden/date_filter.py +0 -63
  29. liquid/golden/decrement_tag.py +0 -16
  30. liquid/golden/default_filter.py +0 -112
  31. liquid/golden/divided_by_filter.py +0 -101
  32. liquid/golden/doc_tag.py +0 -61
  33. liquid/golden/downcase_filter.py +0 -27
  34. liquid/golden/echo_tag.py +0 -116
  35. liquid/golden/escape_filter.py +0 -27
  36. liquid/golden/escape_once_filter.py +0 -32
  37. liquid/golden/find_filter.py +0 -90
  38. liquid/golden/find_index_filter.py +0 -96
  39. liquid/golden/first_filter.py +0 -51
  40. liquid/golden/floor_filter.py +0 -63
  41. liquid/golden/for_tag.py +0 -642
  42. liquid/golden/has_filter.py +0 -139
  43. liquid/golden/identifiers.py +0 -249
  44. liquid/golden/if_tag.py +0 -531
  45. liquid/golden/ifchanged_tag.py +0 -46
  46. liquid/golden/illegal.py +0 -34
  47. liquid/golden/include_tag.py +0 -196
  48. liquid/golden/increment_tag.py +0 -48
  49. liquid/golden/inline_comment_tag.py +0 -127
  50. liquid/golden/join_filter.py +0 -69
  51. liquid/golden/last_filter.py +0 -51
  52. liquid/golden/liquid_tag.py +0 -215
  53. liquid/golden/lstrip_filter.py +0 -37
  54. liquid/golden/map_filter.py +0 -50
  55. liquid/golden/minus_filter.py +0 -58
  56. liquid/golden/modulo_filter.py +0 -60
  57. liquid/golden/newline_to_br_filter.py +0 -37
  58. liquid/golden/not_liquid.py +0 -16
  59. liquid/golden/output_statement.py +0 -295
  60. liquid/golden/plus_filter.py +0 -63
  61. liquid/golden/prepend_filter.py +0 -43
  62. liquid/golden/range_objects.py +0 -79
  63. liquid/golden/raw_tag.py +0 -31
  64. liquid/golden/reject_filter.py +0 -268
  65. liquid/golden/remove_filter.py +0 -45
  66. liquid/golden/remove_first_filter.py +0 -46
  67. liquid/golden/remove_last_filter.py +0 -46
  68. liquid/golden/render_tag.py +0 -210
  69. liquid/golden/replace_filter.py +0 -65
  70. liquid/golden/replace_first_filter.py +0 -59
  71. liquid/golden/replace_last_filter.py +0 -60
  72. liquid/golden/reverse_filter.py +0 -42
  73. liquid/golden/round_filter.py +0 -87
  74. liquid/golden/rstrip_filter.py +0 -37
  75. liquid/golden/size_filter.py +0 -42
  76. liquid/golden/slice_filter.py +0 -119
  77. liquid/golden/sort_filter.py +0 -86
  78. liquid/golden/sort_natural_filter.py +0 -105
  79. liquid/golden/special.py +0 -91
  80. liquid/golden/split_filter.py +0 -128
  81. liquid/golden/strip_filter.py +0 -37
  82. liquid/golden/strip_html_filter.py +0 -74
  83. liquid/golden/strip_newlines_filter.py +0 -37
  84. liquid/golden/sum_filter.py +0 -97
  85. liquid/golden/tablerow_tag.py +0 -399
  86. liquid/golden/times_filter.py +0 -53
  87. liquid/golden/truncate_filter.py +0 -61
  88. liquid/golden/truncatewords_filter.py +0 -94
  89. liquid/golden/uniq_filter.py +0 -87
  90. liquid/golden/unless_tag.py +0 -101
  91. liquid/golden/upcase_filter.py +0 -27
  92. liquid/golden/url_decode_filter.py +0 -27
  93. liquid/golden/url_encode_filter.py +0 -27
  94. liquid/golden/where_filter.py +0 -122
  95. liquid/golden/whitespace_control.py +0 -281
  96. python_liquid-2.0.0.dist-info/RECORD +0 -182
  97. {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/WHEEL +0 -0
  98. {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,119 +0,0 @@
1
- """Golden tests cases for testing liquid's `comment` tag."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="don't render comments",
8
- template=r"{% comment %}foo{% endcomment %}",
9
- expect="",
10
- ),
11
- Case(
12
- description="respect whitespace control in comments",
13
- template="\n{%- comment %}foo{% endcomment -%}\t \r",
14
- expect="",
15
- ),
16
- Case(
17
- description="don't render comments with tags",
18
- template=(
19
- r"{% comment %}"
20
- r"{% if true %}"
21
- r"{{ title }}"
22
- r"{% endif %}"
23
- r"{% endcomment %}"
24
- ),
25
- expect="",
26
- ),
27
- Case(
28
- description="comment inside liquid tag",
29
- template="\n".join(
30
- [
31
- r"{% liquid",
32
- r" if 1 != 1",
33
- r" comment",
34
- r" else",
35
- r" echo 123",
36
- r" endcomment",
37
- r" endif",
38
- r"%}",
39
- ]
40
- ),
41
- expect="",
42
- ),
43
- Case(
44
- description="commented tags are not parsed",
45
- template=(
46
- r"{% comment %}"
47
- r" {% if true %}"
48
- r" {% if ... %}"
49
- r" {%- for ? -%}"
50
- r" {% while true %}"
51
- r" {%"
52
- r" unless if"
53
- r" %}"
54
- r" {% endcase %}"
55
- r"{% endcomment %}"
56
- ),
57
- expect="",
58
- ),
59
- Case(
60
- description="malformed tags are not parsed",
61
- template=r"{% comment %}{% assign foo = '1'{% endcomment %}",
62
- expect="",
63
- error=True,
64
- ),
65
- Case(
66
- description="incomplete tags are not parsed",
67
- template=r"{% comment %}{% {{ {%- endcomment %}",
68
- expect="",
69
- error=True,
70
- ),
71
- Case(
72
- description="nested comment blocks",
73
- template=(
74
- r"{% comment %}"
75
- r" {% comment %}"
76
- r" {% comment %}{% endcomment %}"
77
- r" {% endcomment %}"
78
- r"{% endcomment %}"
79
- ),
80
- expect="",
81
- future=True,
82
- ),
83
- Case(
84
- description="nested comment blocks, with nested tags",
85
- template=(
86
- r"{% comment %}"
87
- r" {% comment %}"
88
- r" {% comment %}{% if true %}hello{%endif%}{% endcomment %}"
89
- r" {% endcomment %}"
90
- r"{% endcomment %}"
91
- ),
92
- expect="",
93
- future=True,
94
- ),
95
- Case(
96
- description="unclosed nested comment blocks",
97
- template=(
98
- r"{% comment %}"
99
- r" {% comment %}"
100
- r" {% comment %}"
101
- r" {% endcomment %}"
102
- r"{% endcomment %}"
103
- ),
104
- expect="",
105
- error=True,
106
- future=True,
107
- ),
108
- Case(
109
- description="raw inside comment block",
110
- template=(
111
- r"{% comment %}"
112
- r" {% raw %}"
113
- r" {% endcomment %}"
114
- r" {% endraw %}"
115
- r"{% endcomment %}"
116
- ),
117
- expect="",
118
- ),
119
- ]
@@ -1,54 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `compact` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array with a nil",
8
- template=r"{{ a | compact | join: '#' }}",
9
- expect="b#a#A",
10
- globals={"a": ["b", "a", None, "A"]},
11
- ),
12
- Case(
13
- description="empty array",
14
- template=r"{{ a | compact | join: '#' }}",
15
- expect="",
16
- globals={"a": []},
17
- ),
18
- Case(
19
- description="too many arguments",
20
- template=r"{{ a | compact: 'foo', 'bar' }}",
21
- expect="",
22
- error=True,
23
- ),
24
- Case(
25
- description="left value is not an array",
26
- template=r"{{ a | compact | first }}",
27
- expect="123",
28
- globals={"a": 123},
29
- ),
30
- Case(
31
- description="left value is undefined",
32
- template=r"{{ nosuchthing | compact }}",
33
- expect="",
34
- ),
35
- Case(
36
- description="array of objects with key property",
37
- template=(
38
- r"{% assign x = a | compact: 'title' %}"
39
- r"{% for obj in x %}"
40
- r"{% for i in obj %}"
41
- r"({{ i[0] }},{{ i[1] }})"
42
- r"{% endfor %}"
43
- r"{% endfor %}"
44
- ),
45
- expect="(title,foo)(name,a)(title,bar)(name,c)",
46
- globals={
47
- "a": [
48
- {"title": "foo", "name": "a"},
49
- {"title": None, "name": "b"},
50
- {"title": "bar", "name": "c"},
51
- ]
52
- },
53
- ),
54
- ]
@@ -1,63 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `concat` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="range literal concat filter left value",
8
- template=r"{{ (1..3) | concat: foo | join: '#' }}",
9
- expect="1#2#3#5#6#7",
10
- globals={"foo": [5, 6, 7]},
11
- ),
12
- Case(
13
- description="two arrays of strings",
14
- template=r"{{ a | concat: b | join: '#' }}",
15
- expect="a#b#c#d",
16
- globals={"a": ["a", "b"], "b": ["c", "d"]},
17
- ),
18
- Case(
19
- description="missing argument is an error",
20
- template=r"{{ a | concat | join: '#' }}",
21
- expect="a#b",
22
- globals={"a": ["a", "b"]},
23
- error=True,
24
- ),
25
- Case(
26
- description="non array-like argument is an error",
27
- template=r"{{ a | concat: b | join: '#' }}",
28
- expect="",
29
- globals={"a": ["a", "b"], "b": 5},
30
- error=True,
31
- ),
32
- Case(
33
- description="left value is not array-like",
34
- template=r"{{ a | concat: b | join: '#' }}",
35
- expect="ab#c#d",
36
- globals={"a": "ab", "b": ["c", "d"]},
37
- ),
38
- Case(
39
- description="left value contains non string",
40
- template=r"{{ a | concat: b | join: '#' }}",
41
- expect="a#b#5#c#d",
42
- globals={"a": ["a", "b", 5], "b": ["c", "d"]},
43
- ),
44
- Case(
45
- description="undefined left value",
46
- template=r"{{ nosuchthing | concat: b | join: '#' }}",
47
- expect="c#d",
48
- globals={"b": ["c", "d"]},
49
- ),
50
- Case(
51
- description="undefined argument is an error",
52
- template=r"{{ a | concat: nosuchthing | join: '#' }}",
53
- expect="",
54
- globals={"a": ["a", "b"]},
55
- error=True,
56
- ),
57
- Case(
58
- description="nested left value gets flattened",
59
- template=r"{{ a | concat: b | join: '#' }}",
60
- expect="a#x#b#y#z#c#d",
61
- globals={"a": [["a", "x"], ["b", ["y", ["z"]]]], "b": ["c", "d"]},
62
- ),
63
- ]
@@ -1,114 +0,0 @@
1
- """Golden tests cases for testing liquid's `cycle` tag."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="no identifier",
8
- template=(
9
- r"{% cycle 'some', 'other' %}"
10
- r"{% cycle 'some', 'other' %}"
11
- r"{% cycle 'some', 'other' %}"
12
- ),
13
- expect="someothersome",
14
- ),
15
- Case(
16
- description="with identifier",
17
- template=(
18
- r"{% cycle 'foo': 'some', 'other' %}"
19
- r"{% cycle 'some', 'other' %}"
20
- r"{% cycle 'foo': 'some', 'other' %}"
21
- ),
22
- expect="somesomeother",
23
- ),
24
- Case(
25
- description="different items",
26
- template=(
27
- r"{% cycle '1', '2', '3' %}"
28
- r"{% cycle '1', '2' %}"
29
- r"{% cycle '1', '2', '3' %}"
30
- ),
31
- expect="112",
32
- ),
33
- Case(
34
- description="integers",
35
- template=r"{% cycle 1, 2, 3 %}{% cycle 1, 2, 3 %}{% cycle 1, 2, 3 %}",
36
- expect="123",
37
- ),
38
- Case(
39
- description="some global variables",
40
- template=r"{% cycle a, b, c %}{% cycle a, b, c %}{% cycle a, b, c %}",
41
- expect="123",
42
- globals={"a": 1, "b": 2, "c": 3},
43
- standard=False,
44
- ),
45
- Case(
46
- description="variable name",
47
- template=r"{% cycle a: 1, 2, 3 %}{% cycle a: 1, 2, 3 %}{% cycle a: 1, 2, 3 %}",
48
- expect="123",
49
- globals={"a": "foo"},
50
- ),
51
- Case(
52
- description="multiple undefined variable names",
53
- template=r"{% cycle a: 1, 2, 3 %}{% cycle b: 1, 2, 3 %}{% cycle a: 1, 2, 3 %}",
54
- expect="123",
55
- globals={},
56
- ),
57
- Case(
58
- description="undefined variable names mixed with no name",
59
- template=r"{% cycle a: 1, 2, 3 %}{% cycle b: 1, 2, 3 %}{% cycle 1, 2, 3 %}",
60
- expect="121",
61
- globals={},
62
- ),
63
- Case(
64
- description="changing variable name",
65
- template=(
66
- r"{% cycle a: 1, 2, 3 %}"
67
- r"{% assign a = 'bar' %}"
68
- r"{% cycle a: 1, 2, 3 %}"
69
- r"{% cycle a: 1, 2, 3 %}"
70
- ),
71
- expect="112",
72
- globals={"a": "foo"},
73
- ),
74
- Case(
75
- description="named with different items",
76
- template=(
77
- r"{% cycle 'a': 1, 2, 3 %}"
78
- r"{% cycle 'a': 7, 8, 9 %}"
79
- r"{% cycle 'a': 1, 2, 3 %}"
80
- ),
81
- expect="183",
82
- future=True,
83
- ),
84
- Case(
85
- description="named with different number of arguments",
86
- template=(
87
- r"{% cycle a: '1', '2' %}"
88
- r"{% cycle a: '1', '2', '3' %}"
89
- r"{% cycle a: '1' %}"
90
- ),
91
- expect="12",
92
- future=True,
93
- ),
94
- Case(
95
- description="named with shrinking number of arguments",
96
- template=(
97
- r"{% cycle a: '1', '2', '3' %}"
98
- r"{% cycle a: '1', '2' %}"
99
- r"{% cycle a: '1' %}"
100
- ),
101
- expect="121",
102
- future=True,
103
- ),
104
- Case(
105
- description="named with growing number of arguments",
106
- template=(
107
- r"{% cycle a: '1' %}"
108
- r"{% cycle a: '1', '2' %}"
109
- r"{% cycle a: '1', '2', '3' %}"
110
- ),
111
- expect="112",
112
- future=True,
113
- ),
114
- ]
@@ -1,63 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `date` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="well formed string",
8
- template=r"{{ 'March 14, 2016' | date: '%b %d, %y' }}",
9
- expect="Mar 14, 16",
10
- ),
11
- Case(
12
- description="too many arguments",
13
- template=r"{{ 'March 14, 2016' | date: '%b %d, %y', 'foo' }}",
14
- expect="",
15
- error=True,
16
- ),
17
- Case(
18
- description="undefined left value",
19
- template=r"{{ nosuchthing | date: '%b %d, %y' }}",
20
- expect="",
21
- ),
22
- Case(
23
- description="missing argument",
24
- template=r"{{ 'March 14, 2016' | date }}",
25
- expect="",
26
- error=True,
27
- ),
28
- Case(
29
- description="undefined argument",
30
- template=r"{{ 'March 14, 2016' | date: nosuchthing }}",
31
- expect="March 14, 2016",
32
- ),
33
- Case(
34
- description="literal percent",
35
- template=r"{{ 'March 14, 2016' | date: '%%%b %d, %y' }}",
36
- expect="%Mar 14, 16",
37
- ),
38
- Case(
39
- description="timestamp integer",
40
- template=r"{{ 1152098955 | date: '%m/%d/%Y' }}",
41
- expect="07/05/2006",
42
- ),
43
- Case(
44
- description="timestamp string",
45
- template=r"{{ '1152098955' | date: '%m/%d/%Y' }}",
46
- expect="07/05/2006",
47
- ),
48
- # Case(
49
- # description="negative timestamp integer",
50
- # template=r"{{ -1152098955 | date: '%m/%d/%Y' }}",
51
- # expect="06/29/1933",
52
- # ),
53
- Case(
54
- description="negative timestamp string",
55
- template=r"{{ '-1152098955' | date: '%m/%d/%Y' }}",
56
- expect="-1152098955",
57
- ),
58
- Case(
59
- description="seconds since epoch format directive",
60
- template=r"{{ 'March 14, 2016' | date: '%s' }}",
61
- expect="1457913600",
62
- ),
63
- ]
@@ -1,16 +0,0 @@
1
- """Golden tests cases for testing liquid's `decrement` tag."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="named counter",
8
- template=r"{% decrement foo %}{{ foo }} {% decrement foo %}{{ foo }}",
9
- expect="-1-1 -2-2",
10
- ),
11
- Case(
12
- description="increment and decrement named counter",
13
- template=r"{% decrement foo %} {% decrement foo %} {% increment foo %}",
14
- expect="-1 -2 -2",
15
- ),
16
- ]
@@ -1,112 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `default` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="nil",
8
- template=r"{{ nil | default: 'foo' }}",
9
- expect="foo",
10
- ),
11
- Case(
12
- description="false",
13
- template=r"{{ False | default: 'foo' }}",
14
- expect="foo",
15
- ),
16
- Case(
17
- description="empty string",
18
- template=r'{{ "" | default: "foo" }}',
19
- expect="foo",
20
- ),
21
- Case(
22
- description="empty array",
23
- template=r"{{ a | default: 'foo' }}",
24
- expect="foo",
25
- globals={"a": []},
26
- ),
27
- Case(
28
- description="empty object",
29
- template=r"{{ a | default: 'foo' }}",
30
- expect="foo",
31
- globals={"a": {}},
32
- ),
33
- Case(
34
- description="not empty string",
35
- template=r'{{ "hello" | default: "foo" }}',
36
- expect="hello",
37
- ),
38
- Case(
39
- description="not empty list",
40
- template=r'{{ a | default: "foo" | join: "#" }}',
41
- expect="hello#world",
42
- globals={"a": ["hello", "world"]},
43
- ),
44
- Case(
45
- description="not empty object",
46
- template=(
47
- r"{% assign b = a | default: foo %}"
48
- r"{% for item in b %}"
49
- r"({{ item[0] }},{{ item[1] }})"
50
- r"{% endfor %}"
51
- ),
52
- expect="(greeting,hello)",
53
- globals={"a": {"greeting": "hello"}, "foo": {"greeting": "goodbye"}},
54
- ),
55
- Case(
56
- description="too many arguments",
57
- template=r"{{ None | default: 'foo', 'bar', 'baz' }}",
58
- expect="",
59
- error=True,
60
- ),
61
- Case(
62
- description="missing argument",
63
- template=r"{{ false | default }}",
64
- expect="",
65
- ),
66
- Case(
67
- description="empty",
68
- template=r"{{ empty | default: bar }}",
69
- expect="",
70
- ),
71
- Case(
72
- description="allow false",
73
- template=r"{{ false | default: 'bar', allow_false:true }}",
74
- expect="false",
75
- ),
76
- Case(
77
- description="allow false from context",
78
- template=r"{{ false | default: 'bar', allow_false:foo }}",
79
- expect="false",
80
- globals={"foo": True},
81
- ),
82
- Case(
83
- description="undefined left value",
84
- template=r'{{ nosuchthing | default: "bar" }}',
85
- expect="bar",
86
- ),
87
- Case(
88
- description="true keyword argument before positional",
89
- template=r'{{ false | default: allow_false: true, "bar" }}',
90
- expect="false",
91
- ),
92
- Case(
93
- description="false keyword argument before positional",
94
- template=r'{{ false | default: allow_false: false, "bar" }}',
95
- expect="bar",
96
- ),
97
- Case(
98
- description="zero is not falsy",
99
- template=r'{{ 0 | default: "bar" }}',
100
- expect="0",
101
- ),
102
- Case(
103
- description="zero is not falsy with allow_false",
104
- template=r'{{ 0 | default: "bar", allow_false: true }}',
105
- expect="0",
106
- ),
107
- Case(
108
- description="0.0 is not falsy",
109
- template=r'{{ 0.0 | default: "bar" }}',
110
- expect="0.0",
111
- ),
112
- ]
@@ -1,101 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `divided_by` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="integer value and integer arg",
8
- template=r"{{ 10 | divided_by: 2 }}",
9
- expect="5",
10
- ),
11
- Case(
12
- description="integer value and float arg",
13
- template=r"{{ 10 | divided_by: 2.0 }}",
14
- expect="5.0",
15
- ),
16
- Case(
17
- description="integer division",
18
- template=r"{{ 9 | divided_by: 2 }}",
19
- expect="4",
20
- ),
21
- Case(
22
- description="float value and integer arg",
23
- template=r"{{ 9.0 | divided_by: 2 }}",
24
- expect="4.5",
25
- ),
26
- Case(
27
- description="float division",
28
- template=r"{{ 20 | divided_by: 7.0 }}",
29
- expect="2.857142857142857",
30
- ),
31
- Case(
32
- description="string value and argument",
33
- template=r'{{ "10" | divided_by: "2" }}',
34
- expect="5",
35
- ),
36
- Case(
37
- description="string not a number",
38
- template=r'{{ "foo" | divided_by: "2" }}',
39
- expect="0",
40
- ),
41
- Case(
42
- description="arg string not a number",
43
- template=r'{{ "10" | divided_by: "foo" }}',
44
- expect="",
45
- error=True,
46
- ),
47
- Case(
48
- description="too many args",
49
- template=r"{{ 5 | divided_by: 1, '5' }}",
50
- expect="",
51
- error=True,
52
- ),
53
- Case(
54
- description="not a string, int or float",
55
- template=r"{{ a | divided_by: 1 }}",
56
- expect="0",
57
- globals={"a": {}},
58
- ),
59
- Case(
60
- description="undefined left value",
61
- template=r"{{ nosuchthing | divided_by: 2 }}",
62
- expect="0",
63
- ),
64
- Case(
65
- description="undefined argument",
66
- template=r"{{ 10 | divided_by: nosuchthing }}",
67
- expect="",
68
- error=True,
69
- ),
70
- Case(
71
- description="divied by zero",
72
- template=r"{{ 10 | divided_by: 0 }}",
73
- expect="",
74
- error=True,
75
- ),
76
- Case(
77
- description="zero divided by float",
78
- template=r"{{ 0 | divided_by: 1.1 }}",
79
- expect="0.0",
80
- ),
81
- Case(
82
- description="zero divided by integer",
83
- template=r"{{ 0 | divided_by: 1 }}",
84
- expect="0",
85
- ),
86
- Case(
87
- description="issue",
88
- template=r"{{ 5 | divided_by: 3 }}",
89
- expect="1",
90
- ),
91
- Case(
92
- description="render",
93
- template=r"{{ 5.0 }} {{ 5 }}",
94
- expect="5.0 5",
95
- ),
96
- Case(
97
- description="left value is an empty string",
98
- template=r"{{ '' | divided_by: 2 }}",
99
- expect="0",
100
- ),
101
- ]