tests/basics: Add test for calling a subclass of a native class.

Adding this test gets py/objtype.c to 100% coverage.
pull/3640/head
Damien George 2018-02-24 23:13:42 +11:00
rodzic c0bcf00ed1
commit 90da791a08
2 zmienionych plików z 31 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,30 @@
# test calling a subclass of a native class that supports calling
# For this test we need a native class that can be subclassed (has make_new)
# and is callable (has call). The only one available is machine.Signal, which
# in turns needs PinBase.
try:
import umachine as machine
except ImportError:
import machine
try:
machine.PinBase
machine.Signal
except AttributeError:
print("SKIP")
raise SystemExit
class Pin(machine.PinBase):
#def __init__(self):
# self.v = 0
def value(self, v=None):
return 42
class MySignal(machine.Signal):
pass
s = MySignal(Pin())
# apply call to the subclass, which should call the native base
print(s())

Wyświetl plik

@ -0,0 +1 @@
42