Telethon/generator/tests/tl_iterator_test.py

29 lines
779 B
Python
Raw Normal View History

2023-06-13 00:05:53 +03:00
from pytest import raises
2023-07-03 20:19:20 +03:00
from telethon_generator.tl_parser import FunctionDef, TypeDef, parse_tl_file
2023-06-13 00:05:53 +03:00
def test_parse_bad_separator() -> None:
with raises(ValueError) as e:
2023-07-03 20:19:20 +03:00
for _ in parse_tl_file("---foo---"):
2023-06-13 00:05:53 +03:00
pass
e.match("bad separator")
def test_parse_file() -> None:
items = list(
2023-07-03 20:19:20 +03:00
parse_tl_file(
2023-06-13 00:05:53 +03:00
"""
// leading; comment
first#1 = t; // inline comment
---functions---
second and bad;
third#3 = t;
// trailing comment
"""
)
)
assert len(items) == 3
assert isinstance(items[0], TypeDef) and items[0].id == 1
assert isinstance(items[1], ValueError)
assert isinstance(items[2], FunctionDef) and items[2].id == 3