Changeset 351
- Timestamp:
- 08/29/09 16:59:56 (2 years ago)
- Location:
- pyyaml/trunk
- Files:
-
- 8 added
- 4 modified
-
lib/yaml/emitter.py (modified) (1 diff)
-
lib3/yaml/emitter.py (modified) (1 diff)
-
tests/data/utf16be.code (added)
-
tests/data/utf16be.data (added)
-
tests/data/utf16le.code (added)
-
tests/data/utf16le.data (added)
-
tests/data/utf8-implicit.code (added)
-
tests/data/utf8-implicit.data (added)
-
tests/data/utf8.code (added)
-
tests/data/utf8.data (added)
-
tests/lib/test_representer.py (modified) (1 diff)
-
tests/lib3/test_representer.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/lib/yaml/emitter.py
r347 r351 790 790 # Write BOM if needed. 791 791 if self.encoding and self.encoding.startswith('utf-16'): 792 self.stream.write(u'\ xFF\xFE'.encode(self.encoding))792 self.stream.write(u'\uFEFF'.encode(self.encoding)) 793 793 794 794 def write_stream_end(self): -
pyyaml/trunk/lib3/yaml/emitter.py
r329 r351 786 786 # Write BOM if needed. 787 787 if self.encoding and self.encoding.startswith('utf-16'): 788 self.stream.write('\ xFF\xFE'.encode(self.encoding))788 self.stream.write('\uFEFF'.encode(self.encoding)) 789 789 790 790 def write_stream_end(self): -
pyyaml/trunk/tests/lib/test_representer.py
r330 r351 7 7 test_constructor._make_objects() 8 8 for allow_unicode in [False, True]: 9 native1 = test_constructor._load_code(open(code_filename, 'rb').read()) 10 native2 = None 11 try: 12 output = yaml.dump(native1, Dumper=test_constructor.MyDumper, 13 allow_unicode=allow_unicode) 14 native2 = yaml.load(output, Loader=test_constructor.MyLoader) 9 for encoding in ['utf-8', 'utf-16-be', 'utf-16-le']: 10 native1 = test_constructor._load_code(open(code_filename, 'rb').read()) 11 native2 = None 15 12 try: 16 if native1 == native2: 17 continue 18 except TypeError: 19 pass 20 value1 = test_constructor._serialize_value(native1) 21 value2 = test_constructor._serialize_value(native2) 22 if verbose: 23 print "SERIALIZED NATIVE1:" 24 print value1 25 print "SERIALIZED NATIVE2:" 26 print value2 27 assert value1 == value2, (native1, native2) 28 finally: 29 if verbose: 30 print "NATIVE1:" 31 pprint.pprint(native1) 32 print "NATIVE2:" 33 pprint.pprint(native2) 34 print "OUTPUT:" 35 print output 13 output = yaml.dump(native1, Dumper=test_constructor.MyDumper, 14 allow_unicode=allow_unicode, encoding=encoding) 15 native2 = yaml.load(output, Loader=test_constructor.MyLoader) 16 try: 17 if native1 == native2: 18 continue 19 except TypeError: 20 pass 21 value1 = test_constructor._serialize_value(native1) 22 value2 = test_constructor._serialize_value(native2) 23 if verbose: 24 print "SERIALIZED NATIVE1:" 25 print value1 26 print "SERIALIZED NATIVE2:" 27 print value2 28 assert value1 == value2, (native1, native2) 29 finally: 30 if verbose: 31 print "NATIVE1:" 32 pprint.pprint(native1) 33 print "NATIVE2:" 34 pprint.pprint(native2) 35 print "OUTPUT:" 36 print output 36 37 37 38 test_representer_types.unittest = ['.code'] -
pyyaml/trunk/tests/lib3/test_representer.py
r330 r351 7 7 test_constructor._make_objects() 8 8 for allow_unicode in [False, True]: 9 native1 = test_constructor._load_code(open(code_filename, 'rb').read()) 10 native2 = None 11 try: 12 output = yaml.dump(native1, Dumper=test_constructor.MyDumper, 13 allow_unicode=allow_unicode) 14 native2 = yaml.load(output, Loader=test_constructor.MyLoader) 9 for encoding in ['utf-8', 'utf-16-be', 'utf-16-le']: 10 native1 = test_constructor._load_code(open(code_filename, 'rb').read()) 11 native2 = None 15 12 try: 16 if native1 == native2: 17 continue 18 except TypeError: 19 pass 20 value1 = test_constructor._serialize_value(native1) 21 value2 = test_constructor._serialize_value(native2) 22 if verbose: 23 print("SERIALIZED NATIVE1:") 24 print(value1) 25 print("SERIALIZED NATIVE2:") 26 print(value2) 27 assert value1 == value2, (native1, native2) 28 finally: 29 if verbose: 30 print("NATIVE1:") 31 pprint.pprint(native1) 32 print("NATIVE2:") 33 pprint.pprint(native2) 34 print("OUTPUT:") 35 print(output) 13 output = yaml.dump(native1, Dumper=test_constructor.MyDumper, 14 allow_unicode=allow_unicode, encoding=encoding) 15 native2 = yaml.load(output, Loader=test_constructor.MyLoader) 16 try: 17 if native1 == native2: 18 continue 19 except TypeError: 20 pass 21 value1 = test_constructor._serialize_value(native1) 22 value2 = test_constructor._serialize_value(native2) 23 if verbose: 24 print("SERIALIZED NATIVE1:") 25 print(value1) 26 print("SERIALIZED NATIVE2:") 27 print(value2) 28 assert value1 == value2, (native1, native2) 29 finally: 30 if verbose: 31 print("NATIVE1:") 32 pprint.pprint(native1) 33 print("NATIVE2:") 34 pprint.pprint(native2) 35 print("OUTPUT:") 36 print(output) 36 37 37 38 test_representer_types.unittest = ['.code']
