mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Fix some typing issues in tests
This commit is contained in:
parent
53ea35e0d5
commit
4078243dad
|
@ -287,7 +287,7 @@ class Sender:
|
||||||
return self._mtp.auth_key
|
return self._mtp.auth_key
|
||||||
|
|
||||||
|
|
||||||
async def connect(transport, addr):
|
async def connect(transport: Transport, addr: str) -> Tuple[Sender, Enqueuer]:
|
||||||
sender, enqueuer = await Sender.connect(transport, Plain(), addr)
|
sender, enqueuer = await Sender.connect(transport, Plain(), addr)
|
||||||
return await generate_auth_key(sender, enqueuer)
|
return await generate_auth_key(sender, enqueuer)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from pytest import raises
|
from pytest import raises
|
||||||
|
from telethon._impl.crypto.auth_key import AuthKey
|
||||||
from telethon._impl.mtproto.mtp import Encrypted, Plain, RpcError
|
from telethon._impl.mtproto.mtp import Encrypted, Plain, RpcError
|
||||||
from telethon._impl.tl.mtproto.types import RpcError as GeneratedRpcError
|
from telethon._impl.tl.mtproto.types import RpcError as GeneratedRpcError
|
||||||
|
|
||||||
|
@ -70,8 +71,8 @@ REQUEST = b"Hey!"
|
||||||
REQUEST_B = b"Bye!"
|
REQUEST_B = b"Bye!"
|
||||||
|
|
||||||
|
|
||||||
def auth_key() -> bytes:
|
def auth_key() -> AuthKey:
|
||||||
return bytes(256)
|
return AuthKey.from_bytes(bytes(256))
|
||||||
|
|
||||||
|
|
||||||
def ensure_buffer_is_message(buffer: bytes, body: bytes, seq_no: int) -> None:
|
def ensure_buffer_is_message(buffer: bytes, body: bytes, seq_no: int) -> None:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from pytest import LogCaptureFixture
|
||||||
from telethon._impl.mtproto.transport.full import Full
|
from telethon._impl.mtproto.transport.full import Full
|
||||||
from telethon._impl.mtsender.sender import connect
|
from telethon._impl.mtsender.sender import connect
|
||||||
|
|
||||||
|
@ -11,13 +12,13 @@ TELEGRAM_DEFAULT_TEST_DC = TELEGRAM_TEST_DC_2
|
||||||
TEST_TIMEOUT = 10000
|
TEST_TIMEOUT = 10000
|
||||||
|
|
||||||
|
|
||||||
def test_invoke_encrypted_method(caplog) -> None:
|
def test_invoke_encrypted_method(caplog: LogCaptureFixture) -> None:
|
||||||
caplog.set_level(logging.DEBUG)
|
caplog.set_level(logging.DEBUG)
|
||||||
|
|
||||||
async def func():
|
async def func() -> None:
|
||||||
deadline = asyncio.get_running_loop().time() + TEST_TIMEOUT
|
deadline = asyncio.get_running_loop().time() + TEST_TIMEOUT
|
||||||
|
|
||||||
def timeout():
|
def timeout() -> float:
|
||||||
return deadline - asyncio.get_running_loop().time()
|
return deadline - asyncio.get_running_loop().time()
|
||||||
|
|
||||||
sender, enqueuer = await asyncio.wait_for(
|
sender, enqueuer = await asyncio.wait_for(
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Output(bytearray):
|
||||||
self += data
|
self += data
|
||||||
|
|
||||||
|
|
||||||
def setup_pack(n: int) -> Tuple[Abridged, bytes, bytearray]:
|
def setup_pack(n: int) -> Tuple[Abridged, bytes, Output]:
|
||||||
input = bytes(x & 0xFF for x in range(n))
|
input = bytes(x & 0xFF for x in range(n))
|
||||||
return Abridged(), input, Output()
|
return Abridged(), input, Output()
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Output(bytearray):
|
||||||
self += data
|
self += data
|
||||||
|
|
||||||
|
|
||||||
def setup_pack(n: int) -> Tuple[Full, bytes, bytearray]:
|
def setup_pack(n: int) -> Tuple[Full, bytes, Output]:
|
||||||
input = bytes(x & 0xFF for x in range(n))
|
input = bytes(x & 0xFF for x in range(n))
|
||||||
return Full(), input, Output()
|
return Full(), input, Output()
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Output(bytearray):
|
||||||
self += data
|
self += data
|
||||||
|
|
||||||
|
|
||||||
def setup_pack(n: int) -> Tuple[Intermediate, bytes, bytearray]:
|
def setup_pack(n: int) -> Tuple[Intermediate, bytes, Output]:
|
||||||
input = bytes(x & 0xFF for x in range(n))
|
input = bytes(x & 0xFF for x in range(n))
|
||||||
return Intermediate(), input, Output()
|
return Intermediate(), input, Output()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user