Skip to content

Commit 6f721b3

Browse files
committed
fix more tests; get some tests from v1.23 or later
1 parent 4b0aee4 commit 6f721b3

24 files changed

+142
-57
lines changed

py/nativeglue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ typedef struct _mp_fun_table_t {
157157
double (*obj_get_float_to_d)(mp_obj_t o);
158158
bool (*get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
159159
const mp_stream_p_t *(*get_stream_raise)(mp_obj_t self_in, int flags);
160+
// CIRCUITPY-CHANGE
160161
void (*assert_native_inited)(mp_obj_t native_object);
161162
const mp_print_t *plat_print;
162163
const mp_obj_type_t *type_type;

tests/basics/async_await2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# test await expression
22

3-
# CIRCUITPY-CHNAGE
3+
# CIRCUITPY-CHANGE
44
# uPy allows normal generators to be awaitables.
55
# CircuitPython does not.
66
# In CircuitPython you need to have an __await__ method on an awaitable like in CPython;

tests/basics/builtin_pow3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
except TypeError:
3030
print("TypeError expected")
3131

32+
# CIRCUITPY-CHANGE
3233
try:
3334
print(pow(4, 5, 0))
3435
except ValueError:

tests/basics/bytes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
print(b'123')
33
print(br'123')
44
print(rb'123')
5-
print(b'\u1234')
65

76
# construction
87
print(bytes())

tests/basics/bytes_escape_unicode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Coverage test for unicode escape in a bytes literal.
2+
# CPython issues a SyntaxWarning for this.
3+
print(b"\u1234")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b'\\u1234'

tests/basics/gen_yield_from_throw.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,6 @@ def gen2():
1717
except TypeError:
1818
print("got TypeError from downstream!")
1919

20-
# passing None as second argument to throw
21-
g = gen2()
22-
print(next(g))
23-
print(g.throw(ValueError, None))
24-
try:
25-
print(next(g))
26-
except TypeError:
27-
print("got TypeError from downstream!")
28-
29-
# passing an exception instance as second argument to throw
30-
g = gen2()
31-
print(next(g))
32-
print(g.throw(ValueError, ValueError(123)))
33-
try:
34-
print(next(g))
35-
except TypeError:
36-
print("got TypeError from downstream!")
37-
3820
# thrown value is caught and then generator returns normally
3921
def gen():
4022
try:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Test generator .throw() with multiple arguments.
2+
# Using multiple arguments is deprecated since CPython 3.12.
3+
4+
5+
def gen():
6+
try:
7+
yield 1
8+
except ValueError as e:
9+
print("got ValueError from upstream!", repr(e.args))
10+
yield "str1"
11+
raise TypeError
12+
13+
14+
def gen2():
15+
print((yield from gen()))
16+
17+
18+
# Passing None as second argument to throw.
19+
g = gen2()
20+
print(next(g))
21+
print(g.throw(ValueError, None))
22+
try:
23+
print(next(g))
24+
except TypeError:
25+
print("got TypeError from downstream!")
26+
27+
# Passing an exception instance as second argument to throw.
28+
g = gen2()
29+
print(next(g))
30+
print(g.throw(ValueError, ValueError(123)))
31+
try:
32+
print(next(g))
33+
except TypeError:
34+
print("got TypeError from downstream!")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
1
2+
got ValueError from upstream! ()
3+
str1
4+
got TypeError from downstream!
5+
1
6+
got ValueError from upstream! (123,)
7+
str1
8+
got TypeError from downstream!
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Test throwing repeatedly into the same generator, where that generator
2+
# is yielding from another generator.
3+
4+
5+
def yielder():
6+
yield 4
7+
yield 5
8+
9+
10+
def gen():
11+
while True:
12+
try:
13+
print("gen received:", (yield from yielder()))
14+
except ValueError as exc:
15+
print(repr(exc))
16+
17+
18+
g = gen()
19+
for i in range(2):
20+
print("send, got:", g.send(None))
21+
print("throw, got:", g.throw(ValueError("a", i)))
22+
print("throw, got:", g.throw(ValueError("b", i)))

0 commit comments

Comments
 (0)