Skip to content

Commit 114e5ef

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 114e5ef

File tree

4 files changed

+215
-210
lines changed

4 files changed

+215
-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: 3 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,7 @@ 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(Stream("SELECT thing, stuff, 123, 'hello' FROM my_table WHERE id = 1;")) == Select(
113113
columns=[
114114
Field("thing"),
115115
Field("stuff"),
@@ -126,7 +126,7 @@ def test_select():
126126

127127

128128
def test_optional_where():
129-
assert select.parse("SELECT 1 FROM x;") == Select(
129+
assert select.parse(Stream("SELECT 1 FROM x;")) == Select(
130130
columns=[Number(1)],
131131
table=Table("x"),
132132
where=None,

0 commit comments

Comments
 (0)