18 from parsers import lazymanifest |
18 from parsers import lazymanifest |
19 try: |
19 try: |
20 lm = lazymanifest(mdata) |
20 lm = lazymanifest(mdata) |
21 # iterate the whole thing, which causes the code to fully parse |
21 # iterate the whole thing, which causes the code to fully parse |
22 # every line in the manifest |
22 # every line in the manifest |
23 list(lm.iterentries()) |
23 for e, _, _ in lm.iterentries(): |
|
24 # also exercise __getitem__ et al |
|
25 lm[e] |
|
26 e in lm |
|
27 (e + 'nope') in lm |
24 lm[b'xyzzy'] = (b'\0' * 20, 'x') |
28 lm[b'xyzzy'] = (b'\0' * 20, 'x') |
25 # do an insert, text should change |
29 # do an insert, text should change |
26 assert lm.text() != mdata, "insert should change text and didn't: %r %r" % (lm.text(), mdata) |
30 assert lm.text() != mdata, "insert should change text and didn't: %r %r" % (lm.text(), mdata) |
|
31 cloned = lm.filtercopy(lambda x: x != 'xyzzy') |
|
32 assert cloned.text() == mdata, 'cloned text should equal mdata' |
|
33 cloned.diff(lm) |
27 del lm[b'xyzzy'] |
34 del lm[b'xyzzy'] |
|
35 cloned.diff(lm) |
28 # should be back to the same |
36 # should be back to the same |
29 assert lm.text() == mdata, "delete should have restored text but didn't: %r %r" % (lm.text(), mdata) |
37 assert lm.text() == mdata, "delete should have restored text but didn't: %r %r" % (lm.text(), mdata) |
30 except Exception as e: |
38 except Exception as e: |
31 pass |
39 pass |
32 # uncomment this print if you're editing this Python code |
40 # uncomment this print if you're editing this Python code |