def test_groups_at_regex_helper(): import re from moler.cmd import RegexHelper regex_helper = RegexHelper() if regex_helper.search_compiled(re.compile(r"(\d+)_([A-Z]+)(\w+),(\d+)"), "111_ABCef,222"): ones, uppers, lowers, twos = regex_helper.groups() assert ones == '111' assert uppers == 'ABC' assert lowers == 'ef' assert twos == '222'
def test_groups_without_match_object(): from moler.cmd import RegexHelper regex_helper = RegexHelper() with pytest.raises(WrongUsage) as exc: regex_helper.groups() assert "Nothing was matched before calling" in str(exc)