def test_not_match(self, basic_logfile): """Does the LogMatcher raise an exception when match is found.""" matcher = LogMatcher(log_path=basic_logfile) matcher.not_match(regex=re.compile(r"bob"), timeout=0.5) matcher.seek() with pytest.raises(Exception): matcher.not_match(regex=re.compile(r"third"), timeout=0.5)
def test_match_all(self, basic_logfile): """Can the LogMatcher find all the correct lines in the log file.""" matcher = LogMatcher(log_path=basic_logfile) matches = matcher.match_all(regex=re.compile(r".+ir.+"), timeout=0.5) assert len(matches) == 2 assert matches[0].group(0) == "first" assert matches[1].group(0) == "third" matcher.seek() matches = matcher.match_all(regex=re.compile(r".+th.*"), timeout=0.5) assert len(matches) == 2 assert matches[0].group(0) == "fourth" assert matches[1].group(0) == "fifth"