Ejemplo n.º 1
0
    def testBinaryNoneAndUid(self):
        """Test with a binary plist.

    Note this test data includes a "null" value, which we translate
    into "None" in Python.

    Note also that expected isTrue is None in plist_dict.  This is
    intentional.  In the process of creating test data for this unit test
    with OSX defaults(1), I used a boolean data container for "isNone", set
    it to True, and then hexedited it to becoming a null value.  (See the
    structure relationship in _BinLoadSimple to see why).  Unfortunately
    defaults had tried to save space and assigned isTrue and isNone to
    the same value container, so isTrue also became None when I did this.
    For the purposes of the test I left everything that way instead of
    fighting defaults.
    """
        plist_bin = base64.b64decode("""
YnBsaXN0MDDaAQIDBAUGBwgJCgsMDQ4PEAwSExdTaXM5VmlzVHJ1ZVVpc1VpZFRpc1BpVmlzRGF0
YVdpc0ZhbHNlVmlzTm9uZVNmb29XaXNBcnJheVdpc1RvZGF5EAkAgTA5I0AJHrhgAAAARAECA/8I
CVNiYXKjFBUWUTFRMlEzM0G0a0uAAAAACB0hKC4zOkJJTVVdX2BjbHFyc3d7fX+BAAAAAAAAAQEA
AAAAAAAAGAAAAAAAAAAAAAAAAAAAAIo=""")
        plist_dict = {
            'foo': 'bar',
            'is9': 9,
            'isUid': plist.AppleUid(12345),
            'isArray': ['1', '2', '3'],
            'isData': plist.AppleData('\x01\x02\x03\xff'),
            'isFalse': False,
            'isTrue': None,  # see docstring
            'isPi': 3.1400001049041748,
            'isToday': datetime.datetime(2011,
                                         11,
                                         10,
                                         0,
                                         0,
                                         tzinfo=plist.UTC()),
            'isNone': None,  # see docstring
        }
        self.PlistTest(plist_bin, plist_dict)
Ejemplo n.º 2
0
 def testSequenceToXmlWhenAppleUid(self):
     """Test SequenceToXml()."""
     seq = [plist.AppleUid(999)]
     out = ('<array>\n  <dict>'
            '<key>CF$UID</key><integer>999</integer></dict>\n</array>')
     self.assertEquals(out, plist.SequenceToXml(seq, indent_num=0))