diff options
Diffstat (limited to 'tests/extmod/framebuf_subclass.py')
-rw-r--r-- | tests/extmod/framebuf_subclass.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/extmod/framebuf_subclass.py b/tests/extmod/framebuf_subclass.py index 6363c224fb..f44a306a35 100644 --- a/tests/extmod/framebuf_subclass.py +++ b/tests/extmod/framebuf_subclass.py @@ -18,3 +18,25 @@ fb = FB(n=3) fb.pixel(0, 0, 0x0102) fb.foo() print(bytes(fb)) + +# Test that blitting a subclass works. +fb2 = framebuf.FrameBuffer(bytearray(2 * 3 * 3), 3, 3, framebuf.RGB565) +fb.fill(0) +fb.pixel(0, 0, 0x0506) +fb.pixel(2, 2, 0x0708) +fb2.blit(fb, 0, 0) +print(bytes(fb2)) + +# Test that blitting something that isn't a subclass fails with TypeError. +class NotAFrameBuf: + pass + +try: + fb.blit(NotAFrameBuf(), 0, 0) +except TypeError: + print('TypeError') + +try: + fb.blit(None, 0, 0) +except TypeError: + print('TypeError') |