MCPcopy Create free account
hub / github.com/coooodeer/parse-rust / test_spans

Function test_spans

tests/test_parse.py:208–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

206
207
208def test_spans():
209 # test the string sections our fields come from
210 string = "hello world"
211 r = parse.parse("hello {}", string)
212 assert r.spans == {0: (6, 11)}
213 start, end = r.spans[0]
214 assert string[start:end] == r.fixed[0]
215
216 string = "hello world"
217 r = parse.parse("hello {:>}", string)
218 assert r.spans == {0: (10, 15)}
219 start, end = r.spans[0]
220 assert string[start:end] == r.fixed[0]
221
222 string = "hello 0x12 world"
223 r = parse.parse("hello {val:x} world", string)
224 assert r.spans == {"val": (6, 10)}
225 start, end = r.spans["val"]
226 assert string[start:end] == "0x%x" % r.named["val"]
227
228 string = "hello world and other beings"
229 r = parse.parse("hello {} {name} {} {spam}", string)
230 assert r.spans == {0: (6, 11), "name": (12, 15), 1: (16, 21), "spam": (22, 28)}
231
232
233def test_numbers():

Callers

nothing calls this directly

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected