Skip to content

Commit 63fc779

Browse files
committed
fix all existing tests to support Stream
Wrap the string, bytes, list into a Stream before calling parse.
1 parent 30b3ee4 commit 63fc779

File tree

4 files changed

+217
-212
lines changed

4 files changed

+217
-212
lines changed

examples/json.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from parsy import forward_declaration, regex, seq, string
1+
from parsy import Stream, forward_declaration, regex, seq, string
22

33
# Utilities
44
whitespace = regex(r"\s*")
@@ -44,7 +44,7 @@
4444

4545
def test():
4646
assert (
47-
json_doc.parse(
47+
json_doc.parse(Stream(
4848
r"""
4949
{
5050
"int": 1,
@@ -55,7 +55,7 @@ def test():
5555
"other": [true, false, null]
5656
}
5757
"""
58-
)
58+
))
5959
== {
6060
"int": 1,
6161
"string": "hello",

examples/sql_select.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from dataclasses import dataclass
1414
from typing import List, Optional, Union
1515

16-
from parsy import from_enum, regex, seq, string
16+
from parsy import Stream, from_enum, regex, seq, string
1717

1818
# -- AST nodes:
1919

@@ -109,7 +109,11 @@ class Select:
109109

110110

111111
def test_select():
112-
assert select.parse("SELECT thing, stuff, 123, 'hello' FROM my_table WHERE id = 1;") == Select(
112+
assert select.parse(
113+
Stream(
114+
"SELECT thing, stuff, 123, 'hello' FROM my_table WHERE id = 1;"
115+
),
116+
) == Select(
113117
columns=[
114118
Field("thing"),
115119
Field("stuff"),
@@ -126,7 +130,7 @@ def test_select():
126130

127131

128132
def test_optional_where():
129-
assert select.parse("SELECT 1 FROM x;") == Select(
133+
assert select.parse(Stream("SELECT 1 FROM x;")) == Select(
130134
columns=[Number(1)],
131135
table=Table("x"),
132136
where=None,

0 commit comments

Comments
 (0)