2021-12-05 15:24:51 +01:00
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
from unittest.mock import Mock
|
|
|
|
|
|
|
|
|
2022-04-09 02:07:38 +02:00
|
|
|
class KeyEvent:
|
|
|
|
def __init__(self, key_number, pressed):
|
|
|
|
self.key_number = key_number
|
|
|
|
self.pressed = pressed
|
|
|
|
|
|
|
|
|
2023-03-29 22:02:29 +02:00
|
|
|
def ticks_ms():
|
|
|
|
return (time.time_ns() // 1_000_000) % (1 << 29)
|
|
|
|
|
|
|
|
|
2021-12-05 15:24:51 +01:00
|
|
|
def init_circuit_python_modules_mocks():
|
|
|
|
sys.modules['usb_hid'] = Mock()
|
|
|
|
sys.modules['digitalio'] = Mock()
|
|
|
|
sys.modules['neopixel'] = Mock()
|
|
|
|
sys.modules['pulseio'] = Mock()
|
|
|
|
sys.modules['busio'] = Mock()
|
|
|
|
sys.modules['microcontroller'] = Mock()
|
|
|
|
sys.modules['board'] = Mock()
|
|
|
|
sys.modules['storage'] = Mock()
|
|
|
|
|
2022-04-09 02:07:38 +02:00
|
|
|
sys.modules['keypad'] = Mock()
|
|
|
|
sys.modules['keypad'].Event = KeyEvent
|
|
|
|
|
2021-12-05 15:24:51 +01:00
|
|
|
sys.modules['micropython'] = Mock()
|
|
|
|
sys.modules['micropython'].const = lambda x: x
|
|
|
|
|
|
|
|
sys.modules['supervisor'] = Mock()
|
2023-03-29 22:02:29 +02:00
|
|
|
sys.modules['supervisor'].ticks_ms = ticks_ms
|
|
|
|
|
|
|
|
from . import task
|
|
|
|
|
|
|
|
sys.modules['_asyncio'] = task
|