@@ -27,6 +27,33 @@ def docx_path(name):
2727 return absjoin (test_file_dir , '%s.docx' % name )
2828
2929
30+ def snippet_seq (name , offset = 0 , count = 1024 ):
31+ """
32+ Return a tuple containing the unicode text snippets read from the snippet
33+ file having *name*. Snippets are delimited by a blank line. If specified,
34+ *count* snippets starting at *offset* are returned.
35+ """
36+ path = os .path .join (test_file_dir , 'snippets' , '%s.txt' % name )
37+ with open (path , 'rb' ) as f :
38+ text = f .read ().decode ('utf-8' )
39+ snippets = text .split ('\n \n ' )
40+ start , end = offset , offset + count
41+ return tuple (snippets [start :end ])
42+
43+
44+ def snippet_text (snippet_file_name ):
45+ """
46+ Return the unicode text read from the test snippet file having
47+ *snippet_file_name*.
48+ """
49+ snippet_file_path = os .path .join (
50+ test_file_dir , 'snippets' , '%s.txt' % snippet_file_name
51+ )
52+ with open (snippet_file_path , 'rb' ) as f :
53+ snippet_bytes = f .read ()
54+ return snippet_bytes .decode ('utf-8' )
55+
56+
3057def test_file (name ):
3158 """
3259 Return the absolute path to test file having *name*.
0 commit comments