def test_markdown(): pattern = ('^Markdown+ ' '(InlineKeyboard|ReplyKeyboard|ReplyKeyboardRemove)? ' 'Reply?$' '|^Markdown InlineKeyboard? Reply? Update$') ce = ClassExp(pattern) assert repr(ce._compiled_expression) == \ "re.compile('^(?:Markdown,)+((?:InlineKeyboard,)|(?:ReplyKeyboard,)|" \ "(?:ReplyKeyboardRemove,))?(?:Reply,)?$" \ "|^(?:Markdown,)(?:InlineKeyboard,)?(?:Reply,)?(?:Update,)$')" assert ce.match([ lyr.Markdown(''), tgr.InlineKeyboard([]), tgr.Reply(), tgr.Update(), ])
def test_match(): ce = ClassExp(r'(int|bool)+ float') assert ce.match([42, 42, 42, True, 42, 42.0]) assert not ce.match([42, True, 42, True])
def match_exp(self, expression: Text): e = ClassExp(expression) return e.match(self._layers)