summaryrefslogtreecommitdiff
path: root/selftest/testlist.py
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-03-04 03:12:35 +0100
committerJelmer Vernooij <jelmer@samba.org>2012-03-04 18:02:06 +0100
commit7a614ac7104cc59f6af70de1b0ba3eee472c3c21 (patch)
treef473d18e7b66b0ff32c779ae3064806db861fa8a /selftest/testlist.py
parent8b583dc64cc0510b4b8d64086ea72b2502249350 (diff)
downloadsamba-7a614ac7104cc59f6af70de1b0ba3eee472c3c21.tar.gz
samba-7a614ac7104cc59f6af70de1b0ba3eee472c3c21.tar.bz2
samba-7a614ac7104cc59f6af70de1b0ba3eee472c3c21.zip
selftest.testlist: Add read_test_regexes.
Diffstat (limited to 'selftest/testlist.py')
-rw-r--r--selftest/testlist.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/selftest/testlist.py b/selftest/testlist.py
index 8fb31fd898..e535194510 100644
--- a/selftest/testlist.py
+++ b/selftest/testlist.py
@@ -19,13 +19,14 @@
"""Selftest test list management."""
-__all__ = ['find_in_list']
+__all__ = ['find_in_list', 'read_test_regexes']
import re
def find_in_list(list, fullname):
"""Find test in list.
+ :param list: List with 2-tuples with regex and reason
"""
for (regex, reason) in list:
if re.match(regex, fullname):
@@ -34,3 +35,21 @@ def find_in_list(list, fullname):
else:
return ""
return None
+
+
+def read_test_regexes(f):
+ """Read tuples with regular expression and optional string from a file.
+
+ :param f: File-like object to read from
+ :return: Iterator over tuples with regular expression and test name
+ """
+ for l in f.readlines():
+ l = l.strip()
+ if l[0] == "#":
+ continue
+ try:
+ (test, reason) = l.split("#", 1)
+ except ValueError:
+ yield l, None
+ else:
+ yield test.strip(), reason.strip()