"""Test utils.""" import abc import random import string import pytest def match_any(*cls): """Match any of type.""" class Any(metaclass=abc.ABCMeta): def __eq__(self, other): return isinstance(other, cls) for c in cls: Any.register(c) return Any() @pytest.mark.parametrize(('value', 'expected_type'), [ (random.randint(-100, 100), int), (random.random() * random.randint(-100, 100), float), (''.join( random.choice(string.ascii_letters + string.digits) for _ in range(10)), str) ]) def test_match_any(value, expected_type): """Test match_any.""" assert value == match_any(expected_type)