Skip to content

Commit addd1d3

Browse files
Alex Marchdpgeorge
authored andcommitted
tests/extmod/btree1: Checks for put, seq, string print and unsupported binary op.
1 parent 99d62c4 commit addd1d3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/extmod/btree1.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
try:
22
import btree
33
import uio
4+
import uerrno
45
except ImportError:
56
print("SKIP")
67
import sys
@@ -15,6 +16,9 @@
1516
db[b"foo2"] = b"bar2"
1617
db[b"bar1"] = b"foo1"
1718

19+
dbstr = str(db)
20+
print(dbstr[:7], dbstr[-1:])
21+
1822
print(db[b"foo2"])
1923
try:
2024
print(db[b"foo"])
@@ -56,14 +60,30 @@
5660
for k, v in db.items(None, None, btree.DESC):
5761
print((k, v))
5862

63+
print(db.seq(1, b"foo1"))
64+
print(db.seq(1, b"qux"))
65+
66+
try:
67+
db.seq(b"foo1")
68+
except OSError as e:
69+
print(e.args[0] == uerrno.EINVAL)
70+
5971
print(list(db.keys()))
6072
print(list(db.values()))
6173

6274
for k in db:
6375
print(k)
6476

77+
db.put(b"baz1", b"qux1")
78+
6579
print("foo1", "foo1" in db)
6680
print("foo2", "foo2" in db)
81+
print("baz1", "baz1" in db)
82+
83+
try:
84+
print(db + db[b"foo1"])
85+
except TypeError:
86+
print("TypeError")
6787

6888
db.close()
6989
f.close()

tests/extmod/btree1.py.exp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<btree >
12
b'bar2'
23
KeyError
34
None
@@ -25,10 +26,15 @@ KeyError
2526
(b'foo3', b'bar3')
2627
(b'foo1', b'bar1')
2728
(b'bar1', b'foo1')
29+
(b'foo1', b'bar1')
30+
None
31+
True
2832
[b'bar1', b'foo1', b'foo3']
2933
[b'foo1', b'bar1', b'bar3']
3034
b'bar1'
3135
b'foo1'
3236
b'foo3'
3337
foo1 True
3438
foo2 False
39+
baz1 True
40+
TypeError

0 commit comments

Comments
 (0)