Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit b1532bd

Browse files
committed
Fix the rest of the SnapshotValueReader tests.
1 parent 022704a commit b1532bd

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

python/selfie-lib/tests/SnapshotValueReader_test.py

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ def test_no_escaping_needed(self):
2727
"""
2828
)
2929
assert reader.peek_key() == "00_empty"
30+
assert reader.peek_key() == "00_empty"
3031
assert reader.next_value().value_string() == ""
3132
assert reader.peek_key() == "01_singleLineString"
33+
assert reader.peek_key() == "01_singleLineString"
3234
assert reader.next_value().value_string() == "this is one line"
3335
assert reader.peek_key() == "01a_singleLineLeadingSpace"
3436
assert reader.next_value().value_string() == " the leading space is significant"
@@ -73,27 +75,25 @@ def test_invalid_names(self):
7375

7476
def test_escape_characters_in_name(self):
7577
reader = SnapshotValueReader.of(
76-
"""
77-
╔═ test with \\(square brackets\\) in name ═╗
78-
╔═ test with \\\\backslash\\\\ in name ═╗
79-
╔═ test with\\nnewline\\nin name ═╗
80-
╔═ test with \\ttab\\t in name ═╗
81-
╔═ test with \\\\─ ascii art \\\\┐ in name ═╗
82-
""".strip()
78+
"""╔═ test with \\(square brackets\\) in name ═╗
79+
╔═ test with \\\\backslash\\\\ in name ═╗
80+
╔═ test with\\nnewline\\nin name ═╗
81+
╔═ test with \\ttab\\t in name ═╗
82+
╔═ test with \\\\─ ascii art \\\\┐ in name ═╗"""
8383
)
84-
assert reader.peek_key() == "test with (square brackets) in name"
84+
assert reader.peek_key() == "test with [square brackets] in name"
8585
assert reader.next_value().value_string() == ""
8686
assert reader.peek_key() == "test with \\backslash\\ in name"
8787
assert reader.next_value().value_string() == ""
88-
assert reader.peek_key().strip() == "test with\nnewline\nin name"
88+
assert reader.peek_key() == "test with\nnewline\nin name"
8989
assert reader.next_value().value_string() == ""
9090
assert reader.peek_key() == "test with \ttab\t in name"
9191
assert reader.next_value().value_string() == ""
9292
assert reader.peek_key() == "test with ╔═ ascii art ═╗ in name"
9393
assert reader.next_value().value_string() == ""
9494

95-
def assert_key_value_with_skip(self, key, expected_value):
96-
reader = SnapshotValueReader.of(self)
95+
def assert_key_value_with_skip(self, test_content, key, expected_value):
96+
reader = SnapshotValueReader.of(test_content)
9797
while reader.peek_key() != key:
9898
reader.skip_value()
9999
assert reader.peek_key() == key
@@ -102,15 +102,13 @@ def assert_key_value_with_skip(self, key, expected_value):
102102
reader.skip_value()
103103

104104
def test_skip_values(self):
105-
test_content = """
106-
╔═ 00_empty ═╗
107-
╔═ 01_singleLineString ═╗
108-
this is one line
109-
╔═ 02_multiLineStringTrimmed ═╗
110-
Line 1
111-
Line 2
112-
╔═ 05_notSureHowKotlinMultilineWorks ═╗
113-
""".strip()
105+
test_content = """╔═ 00_empty ═╗
106+
╔═ 01_singleLineString ═╗
107+
this is one line
108+
╔═ 02_multiLineStringTrimmed ═╗
109+
Line 1
110+
Line 2
111+
╔═ 05_notSureHowKotlinMultilineWorks ═╗"""
114112
self.assert_key_value_with_skip(test_content, "00_empty", "")
115113
self.assert_key_value_with_skip(
116114
test_content, "01_singleLineString", "this is one line"
@@ -119,11 +117,10 @@ def test_skip_values(self):
119117
test_content, "02_multiLineStringTrimmed", "Line 1\nLine 2"
120118
)
121119

122-
def test_binary():
123-
reader = SnapshotValueReader(
120+
def test_binary(self):
121+
reader = SnapshotValueReader.of(
124122
"""╔═ Apple ═╗ base64 length 3 bytes
125-
c2Fk
126-
"""
123+
c2Fk"""
127124
)
128125
assert reader.peek_key() == "Apple"
129-
assert reader.next_value() == b"sad"
126+
assert reader.next_value().value_binary() == b"sad"

0 commit comments

Comments
 (0)