def test_match_anywhere(expression, pattern, expected_results): expression = expression pattern = Pattern(pattern) results = list(match_anywhere(expression, pattern)) assert len(results) == len(expected_results), "Invalid number of results" for result in expected_results: assert result in results, "Results differ from expected"
def test_match_anywhere_error(): with pytest.raises(ValueError): next(match_anywhere(f(x_), f(x_)))