python-liquid 2.0.1__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 (96) hide show
  1. liquid/__init__.py +1 -1
  2. liquid/builtin/expressions/loop.py +2 -5
  3. liquid/extra/tags/macro_tag.py +2 -0
  4. liquid/static_analysis.py +16 -10
  5. {python_liquid-2.0.1.dist-info → python_liquid-2.0.2.dist-info}/METADATA +2 -1
  6. python_liquid-2.0.2.dist-info/RECORD +95 -0
  7. liquid/golden/__init__.py +0 -173
  8. liquid/golden/abs_filter.py +0 -73
  9. liquid/golden/append_filter.py +0 -43
  10. liquid/golden/assign_tag.py +0 -45
  11. liquid/golden/at_least_filter.py +0 -78
  12. liquid/golden/at_most_filter.py +0 -68
  13. liquid/golden/base64_decode_filter.py +0 -43
  14. liquid/golden/base64_encode_filter.py +0 -42
  15. liquid/golden/base64_url_safe_decode_filter.py +0 -43
  16. liquid/golden/base64_url_safe_encode_filter.py +0 -42
  17. liquid/golden/capitalize_filter.py +0 -27
  18. liquid/golden/capture_tag.py +0 -39
  19. liquid/golden/case.py +0 -28
  20. liquid/golden/case_tag.py +0 -226
  21. liquid/golden/ceil_filter.py +0 -63
  22. liquid/golden/comment_tag.py +0 -119
  23. liquid/golden/compact_filter.py +0 -54
  24. liquid/golden/concat_filter.py +0 -63
  25. liquid/golden/cycle_tag.py +0 -114
  26. liquid/golden/date_filter.py +0 -63
  27. liquid/golden/decrement_tag.py +0 -16
  28. liquid/golden/default_filter.py +0 -112
  29. liquid/golden/divided_by_filter.py +0 -101
  30. liquid/golden/doc_tag.py +0 -61
  31. liquid/golden/downcase_filter.py +0 -27
  32. liquid/golden/echo_tag.py +0 -116
  33. liquid/golden/escape_filter.py +0 -27
  34. liquid/golden/escape_once_filter.py +0 -32
  35. liquid/golden/find_filter.py +0 -90
  36. liquid/golden/find_index_filter.py +0 -96
  37. liquid/golden/first_filter.py +0 -51
  38. liquid/golden/floor_filter.py +0 -63
  39. liquid/golden/for_tag.py +0 -642
  40. liquid/golden/has_filter.py +0 -139
  41. liquid/golden/identifiers.py +0 -249
  42. liquid/golden/if_tag.py +0 -531
  43. liquid/golden/ifchanged_tag.py +0 -46
  44. liquid/golden/illegal.py +0 -34
  45. liquid/golden/include_tag.py +0 -196
  46. liquid/golden/increment_tag.py +0 -48
  47. liquid/golden/inline_comment_tag.py +0 -127
  48. liquid/golden/join_filter.py +0 -69
  49. liquid/golden/last_filter.py +0 -51
  50. liquid/golden/liquid_tag.py +0 -215
  51. liquid/golden/lstrip_filter.py +0 -37
  52. liquid/golden/map_filter.py +0 -50
  53. liquid/golden/minus_filter.py +0 -58
  54. liquid/golden/modulo_filter.py +0 -60
  55. liquid/golden/newline_to_br_filter.py +0 -37
  56. liquid/golden/not_liquid.py +0 -16
  57. liquid/golden/output_statement.py +0 -295
  58. liquid/golden/plus_filter.py +0 -63
  59. liquid/golden/prepend_filter.py +0 -43
  60. liquid/golden/range_objects.py +0 -79
  61. liquid/golden/raw_tag.py +0 -31
  62. liquid/golden/reject_filter.py +0 -268
  63. liquid/golden/remove_filter.py +0 -45
  64. liquid/golden/remove_first_filter.py +0 -46
  65. liquid/golden/remove_last_filter.py +0 -46
  66. liquid/golden/render_tag.py +0 -210
  67. liquid/golden/replace_filter.py +0 -65
  68. liquid/golden/replace_first_filter.py +0 -59
  69. liquid/golden/replace_last_filter.py +0 -60
  70. liquid/golden/reverse_filter.py +0 -42
  71. liquid/golden/round_filter.py +0 -87
  72. liquid/golden/rstrip_filter.py +0 -37
  73. liquid/golden/size_filter.py +0 -42
  74. liquid/golden/slice_filter.py +0 -119
  75. liquid/golden/sort_filter.py +0 -86
  76. liquid/golden/sort_natural_filter.py +0 -105
  77. liquid/golden/special.py +0 -91
  78. liquid/golden/split_filter.py +0 -128
  79. liquid/golden/strip_filter.py +0 -37
  80. liquid/golden/strip_html_filter.py +0 -74
  81. liquid/golden/strip_newlines_filter.py +0 -37
  82. liquid/golden/sum_filter.py +0 -97
  83. liquid/golden/tablerow_tag.py +0 -399
  84. liquid/golden/times_filter.py +0 -53
  85. liquid/golden/truncate_filter.py +0 -61
  86. liquid/golden/truncatewords_filter.py +0 -94
  87. liquid/golden/uniq_filter.py +0 -87
  88. liquid/golden/unless_tag.py +0 -101
  89. liquid/golden/upcase_filter.py +0 -27
  90. liquid/golden/url_decode_filter.py +0 -27
  91. liquid/golden/url_encode_filter.py +0 -27
  92. liquid/golden/where_filter.py +0 -122
  93. liquid/golden/whitespace_control.py +0 -281
  94. python_liquid-2.0.1.dist-info/RECORD +0 -182
  95. {python_liquid-2.0.1.dist-info → python_liquid-2.0.2.dist-info}/WHEEL +0 -0
  96. {python_liquid-2.0.1.dist-info → python_liquid-2.0.2.dist-info}/licenses/LICENSE +0 -0
liquid/golden/echo_tag.py DELETED
@@ -1,116 +0,0 @@
1
- """Golden tests cases for testing liquid's `echo` tag."""
2
-
3
- import datetime
4
-
5
- from liquid.golden.case import Case
6
-
7
- cases = [
8
- Case(
9
- description="render a string literal",
10
- template=r"{% echo 'hello' %}",
11
- expect="hello",
12
- ),
13
- Case(
14
- description="render an integer literal",
15
- template=r"{% echo 123 %}",
16
- expect="123",
17
- ),
18
- Case(
19
- description="render a float literal",
20
- template=r"{% echo 1.23 %}",
21
- expect="1.23",
22
- ),
23
- Case(
24
- description="render a variable from the global namespace",
25
- template=r"{% echo product.title %}",
26
- expect="foo",
27
- globals={"product": {"title": "foo"}},
28
- ),
29
- Case(
30
- description="render a variable from the local namespace",
31
- template=r"{% assign name = 'Brian' %}{% echo name %}",
32
- expect="Brian",
33
- ),
34
- Case(
35
- description="render an undefined variable",
36
- template=r"{% echo age %}",
37
- expect="",
38
- ),
39
- Case(
40
- description="render an undefined property",
41
- template=r"{% echo product.age %}",
42
- expect="",
43
- globals={"product": {"title": "foo"}},
44
- ),
45
- Case(
46
- description="access an array item by index",
47
- template=r"{% echo product.tags[1] %}",
48
- expect="garden",
49
- globals={"product": {"tags": ["sports", "garden"]}},
50
- ),
51
- Case(
52
- description="access an array item by negative index",
53
- template=r"{% echo product.tags[-2] %}",
54
- expect="sports",
55
- globals={"product": {"tags": ["sports", "garden"]}},
56
- ),
57
- Case(
58
- description="access array item by index stored in a local variable",
59
- template=r"{% assign i = 1 %}{% echo product.tags[i] %}",
60
- expect="garden",
61
- globals={"product": {"tags": ["sports", "garden"]}},
62
- ),
63
- Case(
64
- description="render a global identifier with a filter",
65
- template=r"{% echo product.title | upcase %}",
66
- expect="FOO",
67
- globals={"product": {"title": "foo"}},
68
- ),
69
- Case(
70
- description="dump an array from the global context",
71
- template=r"{% echo product.tags %}",
72
- expect="sportsgarden",
73
- globals={"product": {"tags": ["sports", "garden"]}},
74
- ),
75
- Case(
76
- description="assign a variable the value of an existing variable",
77
- template=(
78
- r"{% capture some %}hello{% endcapture %}"
79
- r"{% assign other = some %}"
80
- r"{% assign some = 'foo' %}"
81
- r"{% echo some %}-{% echo other %}"
82
- ),
83
- expect="foo-hello",
84
- ),
85
- Case(
86
- description="traverse variables with bracketed identifiers",
87
- template=r"{% echo site.data.menu[include.menu][include.locale] %}",
88
- expect="it works!",
89
- globals={
90
- "site": {"data": {"menu": {"foo": {"bar": "it works!"}}}},
91
- "include": {"menu": "foo", "locale": "bar"},
92
- },
93
- ),
94
- Case(
95
- description="render the special built in variable 'now'",
96
- template=r"{% echo now | date: '%d/%m/%Y' %}",
97
- expect=datetime.datetime.now().strftime(r"%d/%m/%Y"),
98
- standard=False,
99
- ),
100
- Case(
101
- description="render the special built in variable 'today'",
102
- template=r"{% echo today | date: '%d/%m/%Y' %}",
103
- expect=datetime.date.today().strftime(r"%d/%m/%Y"),
104
- standard=False,
105
- ),
106
- Case(
107
- description="access an undefined variable by index",
108
- template=r"{% echo nosuchthing[0] %}",
109
- expect="",
110
- ),
111
- Case(
112
- description="nothing to echo",
113
- template=r"{% echo %}",
114
- expect="",
115
- ),
116
- ]
@@ -1,27 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `escape` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="make HTML-safe",
8
- template=r'{{ "<p>test</p>" | escape }}',
9
- expect="&lt;p&gt;test&lt;/p&gt;",
10
- ),
11
- Case(
12
- description="not a string",
13
- template=r"{{ 5 | escape }}",
14
- expect="5",
15
- ),
16
- Case(
17
- description="unexpected argument",
18
- template=r'{{ "HELLO" | escape: 5 }}',
19
- expect="",
20
- error=True,
21
- ),
22
- Case(
23
- description="undefined left value",
24
- template=r"{{ nosuchthing | escape }}",
25
- expect="",
26
- ),
27
- ]
@@ -1,32 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `escape_once` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="make HTML-safe",
8
- template=r'{{ "&lt;p&gt;test&lt;/p&gt;" | escape_once }}',
9
- expect="&lt;p&gt;test&lt;/p&gt;",
10
- ),
11
- Case(
12
- description="make HTML-safe from mixed safe and markup.",
13
- template=r'{{ "&lt;p&gt;test&lt;/p&gt;<p>test</p>" | escape_once }}',
14
- expect="&lt;p&gt;test&lt;/p&gt;&lt;p&gt;test&lt;/p&gt;",
15
- ),
16
- Case(
17
- description="not a string",
18
- template=r"{{ 5 | escape_once }}",
19
- expect="5",
20
- ),
21
- Case(
22
- description="unexpected argument",
23
- template=r'{{ "HELLO" | escape_once: 5 }}',
24
- expect="",
25
- error=True,
26
- ),
27
- Case(
28
- description="undefined left value",
29
- template=r"{{ nosuchthing | escape_once }}",
30
- expect="",
31
- ),
32
- ]
@@ -1,90 +0,0 @@
1
- """Test cases for the standard `find` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array of strings, default value",
8
- template=r"{{ a | find: 'z' }}",
9
- expect="z",
10
- globals={"a": ["x", "y", "z"]},
11
- ),
12
- Case(
13
- description="array of strings, substring match, default value",
14
- template=r"{{ a | find: 'oo' }}",
15
- expect="zoo",
16
- globals={"a": ["x", "y", "zoo"]},
17
- ),
18
- Case(
19
- description="array of strings, default value, no match",
20
- template=r"{{ a | find: 'foo' }}",
21
- expect="",
22
- globals={"a": ["x", "y", "zoo"]},
23
- ),
24
- # Case(
25
- # description="array of ints, default value",
26
- # template=r"{{ a | find: 2 }}",
27
- # expect="1",
28
- # globals={"a": [1, 2, 3]},
29
- # ),
30
- Case(
31
- description="mixed array, default value",
32
- template=r"{{ a | find: 'z' }}",
33
- expect="",
34
- globals={"a": ["x", None, "z", False, True]},
35
- ),
36
- Case(
37
- description="string input, default value, match",
38
- template=r"{{ a | find: 'z' }}",
39
- expect="zoo",
40
- globals={"a": "zoo"},
41
- ),
42
- Case(
43
- description="string input, string value, match",
44
- template=r"{{ a | find: 'z', 'z' }}",
45
- expect="zoo",
46
- globals={"a": "zoo"},
47
- ),
48
- Case(
49
- description="string input, string value, no match",
50
- template=r"{{ a | find: 'z', 'y' }}",
51
- expect="",
52
- globals={"a": "zoo"},
53
- ),
54
- Case(
55
- description="hash input, default value, match",
56
- template=r"{% assign b = a | find: 'z' %}{{ b.z }}",
57
- expect="42",
58
- globals={"a": {"z": 42}},
59
- ),
60
- Case(
61
- description="hash input, default value, no match",
62
- template=r"{% assign b = a | find: 'foo' %}{{ b }}",
63
- expect="",
64
- globals={"a": {"z": 42}},
65
- ),
66
- Case(
67
- description="hash input, int value, match",
68
- template=r"{% assign b = a | find: 'z', 42 %}{{ b.z }}",
69
- expect="42",
70
- globals={"a": {"z": 42}},
71
- ),
72
- Case(
73
- description="hash input, explicit nil, match",
74
- template=r"{% assign b = a | find: 'z', nil %}{{ b.z }}",
75
- expect="",
76
- globals={"a": {"z": None}},
77
- ),
78
- Case(
79
- description="array of hashes, int value, match",
80
- template=r"{% assign b = a | find: 'z', 42 %}{{ b.foo }}",
81
- expect="bar",
82
- globals={"a": [{"x": 99}, {"z": 42, "foo": "bar"}]},
83
- ),
84
- Case(
85
- description="array of hashes, with a nil",
86
- template=r"{% assign b = a | find: 'z', 42 %}{{ b.foo }}",
87
- expect="",
88
- globals={"a": [{"x": 99}, None, {"z": 42, "foo": "bar"}]},
89
- ),
90
- ]
@@ -1,96 +0,0 @@
1
- """Test cases for the standard `find_index` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array of strings, default value",
8
- template=r"{{ a | find_index: 'z' }}",
9
- expect="2",
10
- globals={"a": ["x", "y", "z"]},
11
- ),
12
- Case(
13
- description="array of strings, substring match, default value",
14
- template=r"{{ a | find_index: 'oo' }}",
15
- expect="2",
16
- globals={"a": ["x", "y", "zoo"]},
17
- ),
18
- Case(
19
- description="array of strings, default value, no match",
20
- template=r"{{ a | find_index: 'foo' }}",
21
- expect="",
22
- globals={"a": ["x", "y", "zoo"]},
23
- ),
24
- # Case(
25
- # description="array of ints, default value",
26
- # template=r"{{ a | find_index: 3 }}",
27
- # expect="0",
28
- # globals={"a": [1, 2, 3]},
29
- # ),
30
- Case(
31
- description="mixed array, default value",
32
- template=r"{{ a | find_index: 'z' }}",
33
- expect="",
34
- globals={"a": ["x", None, "z", False, True]},
35
- ),
36
- Case(
37
- description="string input, default value, match",
38
- template=r"{{ a | find_index: 'z' }}",
39
- expect="0",
40
- globals={"a": "zoo"},
41
- ),
42
- Case(
43
- description="string input, string value, match",
44
- template=r"{{ a | find_index: 'z', 'z' }}",
45
- expect="0",
46
- globals={"a": "zoo"},
47
- ),
48
- Case(
49
- description="string input, string value, no match",
50
- template=r"{{ a | find_index: 'z', 'y' }}",
51
- expect="",
52
- globals={"a": "zoo"},
53
- ),
54
- Case(
55
- description="hash input, default value, match",
56
- template=r"{{ a | find_index: 'z' }}",
57
- expect="0",
58
- globals={"a": {"z": 42}},
59
- ),
60
- Case(
61
- description="hash input, default value, no match",
62
- template=r"{{ a | find_index: 'foo' }}",
63
- expect="",
64
- globals={"a": {"z": 42}},
65
- ),
66
- Case(
67
- description="hash input, int value, match",
68
- template=r"{{ a | find_index: 'z', 42 }}",
69
- expect="0",
70
- globals={"a": {"z": 42}},
71
- ),
72
- Case(
73
- description="hash input, explicit nil, match",
74
- template=r"{{ a | find_index: 'z', nil }}",
75
- expect="",
76
- globals={"a": {"z": None}},
77
- ),
78
- Case(
79
- description="array of hashes, explicit nil, match",
80
- template=r"{{ a | find_index: 'z', nil }}",
81
- expect="",
82
- globals={"a": ["foo", "bar", {"z": None}]},
83
- ),
84
- Case(
85
- description="array of hashes, int value, match",
86
- template=r"{{ a | find_index: 'z', 42 }}",
87
- expect="1",
88
- globals={"a": [{"x": 99}, {"z": 42, "foo": "bar"}]},
89
- ),
90
- Case(
91
- description="array of hashes, with a nil",
92
- template=r"{% assign b = a | find_index: 'z', 42 %}{{ b.foo }}",
93
- expect="",
94
- globals={"a": [{"x": 99}, None, {"z": 42, "foo": "bar"}]},
95
- ),
96
- ]
@@ -1,51 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `first` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="range literal first filter left value",
8
- template=r"{{ (1..3) | first }}",
9
- expect="1",
10
- ),
11
- Case(
12
- description="array of strings",
13
- template=r"{{ arr | first }}",
14
- expect="a",
15
- globals={"arr": ["a", "b"]},
16
- ),
17
- Case(
18
- description="array of things",
19
- template=r"{{ arr | first }}",
20
- expect="a",
21
- globals={"arr": ["a", "b", 1, [], {}]},
22
- ),
23
- Case(
24
- description="empty left value",
25
- template=r"{{ arr | first }}",
26
- expect="",
27
- globals={"arr": []},
28
- ),
29
- Case(
30
- description="left value is not an array",
31
- template=r"{{ arr | first }}",
32
- expect="",
33
- globals={"arr": 12},
34
- ),
35
- Case(
36
- description="left value is undefined",
37
- template=r"{{ nosuchthing | first }}",
38
- expect="",
39
- ),
40
- Case(
41
- description="first of a string",
42
- template=r"{{ 'hello' | first }}",
43
- expect="",
44
- ),
45
- Case(
46
- description="first of a hash",
47
- template=r"{% assign x = a | first %}({{ x[0] }},{{ x[1] }})",
48
- expect="(b,1)",
49
- globals={"a": {"b": 1, "c": 2}},
50
- ),
51
- ]
@@ -1,63 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `ceil` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="positive integer",
8
- template=r"{{ 5 | floor }}",
9
- expect="5",
10
- ),
11
- Case(
12
- description="negative integer",
13
- template=r"{{ -5 | floor }}",
14
- expect="-5",
15
- ),
16
- Case(
17
- description="positive float",
18
- template=r"{{ 5.4 | floor }}",
19
- expect="5",
20
- ),
21
- Case(
22
- description="negative float",
23
- template=r"{{ -5.4 | floor }}",
24
- expect="-6",
25
- ),
26
- Case(
27
- description="zero",
28
- template=r"{{ 0 | floor }}",
29
- expect="0",
30
- ),
31
- Case(
32
- description="positive string float",
33
- template=r'{{ "5.1" | floor }}',
34
- expect="5",
35
- ),
36
- Case(
37
- description="negative string float",
38
- template=r'{{ "-5.1" | floor }}',
39
- expect="-6",
40
- ),
41
- Case(
42
- description="unexpected argument",
43
- template=r"{{ -3.1 | floor: 1 }}",
44
- expect="",
45
- error=True,
46
- ),
47
- Case(
48
- description="string not a number",
49
- template=r'{{ "hello" | floor }}',
50
- expect="0",
51
- ),
52
- Case(
53
- description="not a string, int or float",
54
- template=r"{{ a | floor }}",
55
- expect="0",
56
- globals={"a": {}},
57
- ),
58
- Case(
59
- description="undefined left value",
60
- template=r"{{ nosuchthing | floor }}",
61
- expect="0",
62
- ),
63
- ]