diff options
author | Mike Pennisi <mike@mikepennisi.com> | 2016-01-31 13:16:12 -0500 |
---|---|---|
committer | Mike Pennisi <mike@mikepennisi.com> | 2016-10-19 15:24:21 -0400 |
commit | 2915fe8527d06c2cb1a4780eeac37ef743c02d9f (patch) | |
tree | 5e21a83c818bd4219e942a9d899ecc957916aab5 /tools | |
parent | 7d4b1d28ae4428829203f8261f57033e534c0efc (diff) | |
download | qtdeclarative-testsuites-2915fe8527d06c2cb1a4780eeac37ef743c02d9f.tar.gz |
Update test harness to support new negative format
Diffstat (limited to 'tools')
-rw-r--r-- | tools/packaging/monkeyYaml.py | 25 | ||||
-rw-r--r-- | tools/packaging/test/test_monkeyYaml.py | 21 |
2 files changed, 37 insertions, 9 deletions
diff --git a/tools/packaging/monkeyYaml.py b/tools/packaging/monkeyYaml.py index b017e55b5..21c3fa42e 100644 --- a/tools/packaging/monkeyYaml.py +++ b/tools/packaging/monkeyYaml.py @@ -14,12 +14,16 @@ mYamlListPattern = re.compile(r"^\[(.*)\]$") mYamlMultilineList = re.compile(r"^ *- (.*)$") def load(str): + return myReadDict(str.splitlines())[1] + +def myReadDict(lines, indent=""): dict = None key = None emptyLines = 0 - - lines = str.splitlines() while lines: + if not lines[0].startswith(indent): + break + line = lines.pop(0) if myIsAllSpaces(line): emptyLines += 1 @@ -31,7 +35,7 @@ def load(str): dict = {} key = result.group(1).strip() value = result.group(2).strip() - (lines, value) = myReadValue(lines, value) + (lines, value) = myReadValue(lines, value, indent) dict[key] = value else: if dict and key and key in dict: @@ -40,17 +44,20 @@ def load(str): else: raise Exception("monkeyYaml is confused at " + line) emptyLines = 0 - return dict + return lines, dict -def myReadValue(lines, value): +def myReadValue(lines, value, indent): if value == ">" or value == "|": (lines, value) = myMultiline(lines, value) value = value + "\n" return (lines, value) - if lines and not value and myMaybeList(lines[0]): - return myMultilineList(lines, value) - else: - return lines, myReadOneLine(value) + if lines and not value: + if myMaybeList(lines[0]): + return myMultilineList(lines, value) + indentMatch = re.match("(" + indent + r"\s+)", lines[0]) + if indentMatch: + return myReadDict(lines, indentMatch.group(1)) + return lines, myReadOneLine(value) def myMaybeList(value): return mYamlMultilineList.match(value) diff --git a/tools/packaging/test/test_monkeyYaml.py b/tools/packaging/test/test_monkeyYaml.py index df6667105..92d4e6139 100644 --- a/tools/packaging/test/test_monkeyYaml.py +++ b/tools/packaging/test/test_monkeyYaml.py @@ -185,6 +185,27 @@ es6id: 19.1.2.1 """ self.assertEqual(monkeyYaml.load(y), yaml.load(y)) + def test_nested_1(self): + y = """ +es61d: 19.1.2.1 +negative: + stage: early + type: ReferenceError +description: foo +""" + self.assertEqual(monkeyYaml.load(y), yaml.load(y)) + + def test_nested_2(self): + y = """ +es61d: 19.1.2.1 +first: + second_a: + third: 1 + second_b: 3 +description: foo +""" + self.assertEqual(monkeyYaml.load(y), yaml.load(y)) + if __name__ == '__main__': unittest.main() |