Ignore:
Timestamp:
05/23/06 15:11:21 (8 years ago)
Author:
xi
Message:

Fixed #16 (duplicate keys in dictionary cause unpredictable behavior).
Thanks to nickesk(at)cs.bu.edu for the report.

If a mapping node contains duplicate keys, it is transformed to a list of pairs.
This behaviour may change in the future since it contradicts the YAML specification.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pysyck/trunk/tests/test_loader.py

    r49 r176  
    143143""" 
    144144 
     145DUPLICATE_KEY = """ 
     1460: 0 
     1470: 1 
     148""" 
     149 
    145150class TestDocuments(test_parser.TestDocuments): 
    146151 
     
    289294        self.assertEqual(len(document[0]), 2) 
    290295        self.assertEqual(document[0][0], document[0][1]) 
     296 
     297    def testDuplicateKey(self): 
     298        document = syck.load(DUPLICATE_KEY) 
     299        self.assertEqual(type(document), list) 
     300        self.assertEqual(len(document), 2) 
     301        self.assertEqual(len(document[0]), 2) 
     302        self.assertEqual(len(document[1]), 2) 
     303        self.assertEqual(document[0][0], document[1][0]) 
     304 
Note: See TracChangeset for help on using the changeset viewer.