@@ -67,11 +67,17 @@ def check_json(expected, result):
6767 assert expected == result
6868
6969
70+ def get_test_content (test_location ):
71+ """
72+ Read file at test_location and return a unicode string.
73+ """
74+ return get_unicode_content (get_test_loc (test_location ))
75+
76+
7077def get_unicode_content (location ):
7178 """
7279 Read file at location and return a unicode string.
7380 """
74- location = get_test_loc (location )
7581 with io .open (location , encoding = 'utf-8' ) as doc :
7682 return doc .read ()
7783
@@ -215,7 +221,7 @@ def test_SingleLineField_has_errors_if_multiline(self):
215221class YamlParseTest (unittest .TestCase ):
216222 maxDiff = None
217223 def test_saneyaml_load_can_parse_simple_fields (self ):
218- test = get_unicode_content ('test_model/parse/basic.about' )
224+ test = get_test_content ('test_model/parse/basic.about' )
219225 result = saneyaml .load (test )
220226
221227 expected = [
@@ -226,7 +232,7 @@ def test_saneyaml_load_can_parse_simple_fields(self):
226232 assert expected == list (result .items ())
227233
228234 def test_saneyaml_load_can_parse_continuations (self ):
229- test = get_unicode_content ('test_model/parse/continuation.about' )
235+ test = get_test_content ('test_model/parse/continuation.about' )
230236 result = saneyaml .load (test )
231237
232238 expected = [
@@ -238,7 +244,7 @@ def test_saneyaml_load_can_parse_continuations(self):
238244 assert expected == list (result .items ())
239245
240246 def test_saneyaml_load_can_handle_multiline_texts_and_strips_text_fields (self ):
241- test = get_unicode_content ('test_model/parse/complex.about' )
247+ test = get_test_content ('test_model/parse/complex.about' )
242248 result = saneyaml .load (test )
243249
244250 expected = [
@@ -250,7 +256,7 @@ def test_saneyaml_load_can_handle_multiline_texts_and_strips_text_fields(self):
250256 assert expected == list (result .items ())
251257
252258 def test_saneyaml_load_can_parse_verbatim_text_unstripped (self ):
253- test = get_unicode_content ('test_model/parse/continuation_verbatim.about' )
259+ test = get_test_content ('test_model/parse/continuation_verbatim.about' )
254260 result = saneyaml .load (test )
255261
256262 expected = [
@@ -262,15 +268,15 @@ def test_saneyaml_load_can_parse_verbatim_text_unstripped(self):
262268 assert expected == list (result .items ())
263269
264270 def test_saneyaml_load_report_error_for_invalid_field_name (self ):
265- test = get_unicode_content ('test_model/parse/invalid_names.about' )
271+ test = get_test_content ('test_model/parse/invalid_names.about' )
266272 try :
267273 saneyaml .load (test )
268274 self .fail ('Exception not raised' )
269275 except Exception :
270276 pass
271277
272278 def test_saneyaml_dangling_text_is_not_an_invalid_continuation (self ):
273- test = get_unicode_content ('test_model/parse/invalid_continuation.about' )
279+ test = get_test_content ('test_model/parse/invalid_continuation.about' )
274280 result = saneyaml .load (test )
275281 expected = [
276282 (u'single_line' , u'optional' ),
@@ -280,7 +286,7 @@ def test_saneyaml_dangling_text_is_not_an_invalid_continuation(self):
280286 assert expected == list (result .items ())
281287
282288 def test_saneyaml_load_accepts_unicode_keys_and_values (self ):
283- test = get_unicode_content ('test_model/parse/non_ascii_field_name_value.about' )
289+ test = get_test_content ('test_model/parse/non_ascii_field_name_value.about' )
284290 result = saneyaml .load (test )
285291 expected = [
286292 ('name' , 'name' ),
@@ -370,7 +376,7 @@ def check_About_hydrate(self, about, fields):
370376 assert expected == result
371377
372378 def test_About_hydrate_normalize_field_names_to_lowercase (self ):
373- test_content = get_unicode_content ('test_gen/parser_tests/upper_field_names.ABOUT' )
379+ test_content = get_test_content ('test_gen/parser_tests/upper_field_names.ABOUT' )
374380 fields = saneyaml .load (test_content ).items ()
375381 a = model .About ()
376382 for _ in range (3 ):
0 commit comments