Skip to content

Commit 6a3efa9

Browse files
committed
fix all existing tests to support Stream
Wrap the string, bytes, list into a Stream before calling parse.
1 parent ad1f90f commit 6a3efa9

File tree

4 files changed

+217
-210
lines changed

4 files changed

+217
-210
lines changed

examples/json.py

Lines changed: 4 additions & 2 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*")
@@ -45,7 +45,8 @@
4545
def test():
4646
assert (
4747
json_doc.parse(
48-
r"""
48+
Stream(
49+
r"""
4950
{
5051
"int": 1,
5152
"string": "hello",
@@ -55,6 +56,7 @@ def test():
5556
"other": [true, false, null]
5657
}
5758
"""
59+
)
5860
)
5961
== {
6062
"int": 1,

examples/sql_select.py

Lines changed: 5 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,9 @@ 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("SELECT thing, stuff, 123, 'hello' FROM my_table WHERE id = 1;"),
114+
) == Select(
113115
columns=[
114116
Field("thing"),
115117
Field("stuff"),
@@ -126,7 +128,7 @@ def test_select():
126128

127129

128130
def test_optional_where():
129-
assert select.parse("SELECT 1 FROM x;") == Select(
131+
assert select.parse(Stream("SELECT 1 FROM x;")) == Select(
130132
columns=[Number(1)],
131133
table=Table("x"),
132134
where=None,

0 commit comments

Comments
 (0)