mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-10 10:19:30 +01:00
Fix benchmarks not working after latest refactoring (#647)
This commit is contained in:
parent
16c116795d
commit
9d785d70a9
@ -1,6 +1,6 @@
|
|||||||
import io
|
|
||||||
import timeit
|
import timeit
|
||||||
|
|
||||||
|
from aioesphomeapi import APIConnection
|
||||||
from aioesphomeapi._frame_helper import APIPlaintextFrameHelper
|
from aioesphomeapi._frame_helper import APIPlaintextFrameHelper
|
||||||
from aioesphomeapi._frame_helper.plain_text import _cached_varuint_to_bytes
|
from aioesphomeapi._frame_helper.plain_text import _cached_varuint_to_bytes
|
||||||
from aioesphomeapi.api_pb2 import (
|
from aioesphomeapi.api_pb2 import (
|
||||||
@ -10,6 +10,7 @@ from aioesphomeapi.api_pb2 import (
|
|||||||
|
|
||||||
# cythonize -X language_level=3 -a -i aioesphomeapi/_frame_helper/plain_text.py
|
# cythonize -X language_level=3 -a -i aioesphomeapi/_frame_helper/plain_text.py
|
||||||
# cythonize -X language_level=3 -a -i aioesphomeapi/_frame_helper/base.py
|
# cythonize -X language_level=3 -a -i aioesphomeapi/_frame_helper/base.py
|
||||||
|
# cythonize -X language_level=3 -a -i aioesphomeapi/connection.py
|
||||||
|
|
||||||
adv = BluetoothLERawAdvertisementsResponse()
|
adv = BluetoothLERawAdvertisementsResponse()
|
||||||
fake_adv = BluetoothLERawAdvertisement(
|
fake_adv = BluetoothLERawAdvertisement(
|
||||||
@ -32,16 +33,21 @@ data = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _packet(type_: int, data: bytes):
|
class MockConnection(APIConnection):
|
||||||
pass
|
def __init__(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def process_packet(self, type_: int, data: bytes):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def report_fatal_error(self, exc: Exception):
|
||||||
|
raise exc
|
||||||
|
|
||||||
|
|
||||||
def _on_error(exc: Exception):
|
connection = MockConnection()
|
||||||
raise exc
|
|
||||||
|
|
||||||
|
|
||||||
helper = APIPlaintextFrameHelper(
|
helper = APIPlaintextFrameHelper(
|
||||||
on_pkt=_packet, on_error=_on_error, client_info="my client", log_name="test"
|
connection=connection, client_info="my client", log_name="test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user