summaryrefslogtreecommitdiff
path: root/tests/curl_test_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/curl_test_data.py')
-rwxr-xr-xtests/curl_test_data.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/curl_test_data.py b/tests/curl_test_data.py
index bfe1287d8..21747407d 100755
--- a/tests/curl_test_data.py
+++ b/tests/curl_test_data.py
@@ -24,12 +24,15 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
-import xml.etree.ElementTree as ET
+import re
import logging
log = logging.getLogger(__name__)
+REPLY_DATA = re.compile("<reply>\s*<data>(.*?)</data>", re.MULTILINE | re.DOTALL)
+
+
class TestData(object):
def __init__(self, data_folder):
self.data_folder = data_folder
@@ -39,15 +42,17 @@ class TestData(object):
filename = os.path.join(self.data_folder,
"test{0}".format(test_number))
- # The user should handle the exception from failing to find the file.
- tree = ET.parse(filename)
+ log.debug("Parsing file %s", filename)
+
+ with open(filename, "rb") as f:
+ contents = f.read().decode("utf-8")
- # We need the <reply><data> text.
- reply = tree.find("reply")
- data = reply.find("data")
+ m = REPLY_DATA.search(contents)
+ if not m:
+ raise Exception("Couldn't find a <reply><data> section")
- # Return the text contents of the data
- return data.text
+ # Left-strip the data so we don't get a newline before our data.
+ return m.group(1).lstrip()
if __name__ == '__main__':