Changeset 366 for pyyaml/trunk/tests/lib3/test_input_output.py
- Timestamp:
- 08/31/09 04:47:05 (4 years ago)
- File:
-
- 1 edited
-
pyyaml/trunk/tests/lib3/test_input_output.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/tests/lib3/test_input_output.py
r336 r366 1 1 2 2 import yaml 3 import codecs, io 3 import codecs, io, tempfile, os, os.path 4 4 5 5 def test_unicode_input(unicode_filename, verbose=False): … … 95 95 test_unicode_output.unittest = ['.unicode'] 96 96 97 def test_file_output(unicode_filename, verbose=False): 98 data = open(unicode_filename, 'rb').read().decode('utf-8') 99 handle, filename = tempfile.mkstemp() 100 try: 101 stream = io.StringIO() 102 yaml.dump(data, stream, allow_unicode=True) 103 data1 = stream.getvalue() 104 stream = io.BytesIO() 105 yaml.dump(data, stream, encoding='utf-16-le', allow_unicode=True) 106 data2 = stream.getvalue().decode('utf-16-le')[1:] 107 stream = open(filename, 'w', encoding='utf-16-le') 108 yaml.dump(data, stream, allow_unicode=True) 109 stream.close() 110 data3 = open(filename, 'r', encoding='utf-16-le').read() 111 stream = open(filename, 'wb') 112 yaml.dump(data, stream, encoding='utf-8', allow_unicode=True) 113 stream.close() 114 data4 = open(filename, 'r', encoding='utf-8').read() 115 assert data1 == data2, (data1, data2) 116 assert data1 == data3, (data1, data3) 117 assert data1 == data4, (data1, data4) 118 finally: 119 if os.path.exists(filename): 120 os.unlink(filename) 121 122 test_file_output.unittest = ['.unicode'] 123 97 124 def test_unicode_transfer(unicode_filename, verbose=False): 98 125 data = open(unicode_filename, 'rb').read().decode('utf-8')
Note: See TracChangeset
for help on using the changeset viewer.
