B
    u9awh                 @   s   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 ejejfZejedejediZG dd de jZG dd	 d	e jZG d
d de jZG dd de jZdd Zedkre  dS )    N)support)BytesIOs  
        PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NU
        WVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VO
        IiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4w
        LmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+YUJp
        Z0ludDwva2V5PgoJPGludGVnZXI+OTIyMzM3MjAzNjg1NDc3NTc2NDwvaW50
        ZWdlcj4KCTxrZXk+YUJpZ0ludDI8L2tleT4KCTxpbnRlZ2VyPjkyMjMzNzIw
        MzY4NTQ3NzU4NTI8L2ludGVnZXI+Cgk8a2V5PmFEYXRlPC9rZXk+Cgk8ZGF0
        ZT4yMDA0LTEwLTI2VDEwOjMzOjMzWjwvZGF0ZT4KCTxrZXk+YURpY3Q8L2tl
        eT4KCTxkaWN0PgoJCTxrZXk+YUZhbHNlVmFsdWU8L2tleT4KCQk8ZmFsc2Uv
        PgoJCTxrZXk+YVRydWVWYWx1ZTwva2V5PgoJCTx0cnVlLz4KCQk8a2V5PmFV
        bmljb2RlVmFsdWU8L2tleT4KCQk8c3RyaW5nPk3DpHNzaWcsIE1hw588L3N0
        cmluZz4KCQk8a2V5PmFub3RoZXJTdHJpbmc8L2tleT4KCQk8c3RyaW5nPiZs
        dDtoZWxsbyAmYW1wOyAnaGknIHRoZXJlISZndDs8L3N0cmluZz4KCQk8a2V5
        PmRlZXBlckRpY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5hPC9rZXk+CgkJ
        CTxpbnRlZ2VyPjE3PC9pbnRlZ2VyPgoJCQk8a2V5PmI8L2tleT4KCQkJPHJl
        YWw+MzIuNTwvcmVhbD4KCQkJPGtleT5jPC9rZXk+CgkJCTxhcnJheT4KCQkJ
        CTxpbnRlZ2VyPjE8L2ludGVnZXI+CgkJCQk8aW50ZWdlcj4yPC9pbnRlZ2Vy
        PgoJCQkJPHN0cmluZz50ZXh0PC9zdHJpbmc+CgkJCTwvYXJyYXk+CgkJPC9k
        aWN0PgoJPC9kaWN0PgoJPGtleT5hRmxvYXQ8L2tleT4KCTxyZWFsPjAuNTwv
        cmVhbD4KCTxrZXk+YUxpc3Q8L2tleT4KCTxhcnJheT4KCQk8c3RyaW5nPkE8
        L3N0cmluZz4KCQk8c3RyaW5nPkI8L3N0cmluZz4KCQk8aW50ZWdlcj4xMjwv
        aW50ZWdlcj4KCQk8cmVhbD4zMi41PC9yZWFsPgoJCTxhcnJheT4KCQkJPGlu
        dGVnZXI+MTwvaW50ZWdlcj4KCQkJPGludGVnZXI+MjwvaW50ZWdlcj4KCQkJ
        PGludGVnZXI+MzwvaW50ZWdlcj4KCQk8L2FycmF5PgoJPC9hcnJheT4KCTxr
        ZXk+YU5lZ2F0aXZlQmlnSW50PC9rZXk+Cgk8aW50ZWdlcj4tODAwMDAwMDAw
        MDA8L2ludGVnZXI+Cgk8a2V5PmFOZWdhdGl2ZUludDwva2V5PgoJPGludGVn
        ZXI+LTU8L2ludGVnZXI+Cgk8a2V5PmFTdHJpbmc8L2tleT4KCTxzdHJpbmc+
        RG9vZGFoPC9zdHJpbmc+Cgk8a2V5PmFuRW1wdHlEaWN0PC9rZXk+Cgk8ZGlj
        dC8+Cgk8a2V5PmFuRW1wdHlMaXN0PC9rZXk+Cgk8YXJyYXkvPgoJPGtleT5h
        bkludDwva2V5PgoJPGludGVnZXI+NzI4PC9pbnRlZ2VyPgoJPGtleT5uZXN0
        ZWREYXRhPC9rZXk+Cgk8YXJyYXk+CgkJPGRhdGE+CgkJUEd4dmRITWdiMlln
        WW1sdVlYSjVJR2QxYm1zK0FBRUNBenhzYjNSeklHOW1JR0pwYm1GeWVTQm5k
        VzVyCgkJUGdBQkFnTThiRzkwY3lCdlppQmlhVzVoY25rZ1ozVnVhejRBQVFJ
        RFBHeHZkSE1nYjJZZ1ltbHVZWEo1CgkJSUdkMWJtcytBQUVDQXp4c2IzUnpJ
        RzltSUdKcGJtRnllU0JuZFc1clBnQUJBZ004Ykc5MGN5QnZaaUJpCgkJYVc1
        aGNua2daM1Z1YXo0QUFRSURQR3h2ZEhNZ2IyWWdZbWx1WVhKNUlHZDFibXMr
        QUFFQ0F6eHNiM1J6CgkJSUc5bUlHSnBibUZ5ZVNCbmRXNXJQZ0FCQWdNOGJH
        OTBjeUJ2WmlCaWFXNWhjbmtnWjNWdWF6NEFBUUlECgkJUEd4dmRITWdiMlln
        WW1sdVlYSjVJR2QxYm1zK0FBRUNBdz09CgkJPC9kYXRhPgoJPC9hcnJheT4K
        CTxrZXk+c29tZURhdGE8L2tleT4KCTxkYXRhPgoJUEdKcGJtRnllU0JuZFc1
        clBnPT0KCTwvZGF0YT4KCTxrZXk+c29tZU1vcmVEYXRhPC9rZXk+Cgk8ZGF0
        YT4KCVBHeHZkSE1nYjJZZ1ltbHVZWEo1SUdkMWJtcytBQUVDQXp4c2IzUnpJ
        RzltSUdKcGJtRnllU0JuZFc1clBnQUJBZ004CgliRzkwY3lCdlppQmlhVzVo
        Y25rZ1ozVnVhejRBQVFJRFBHeHZkSE1nYjJZZ1ltbHVZWEo1SUdkMWJtcytB
        QUVDQXp4cwoJYjNSeklHOW1JR0pwYm1GeWVTQm5kVzVyUGdBQkFnTThiRzkw
        Y3lCdlppQmlhVzVoY25rZ1ozVnVhejRBQVFJRFBHeHYKCWRITWdiMllnWW1s
        dVlYSjVJR2QxYm1zK0FBRUNBenhzYjNSeklHOW1JR0pwYm1GeWVTQm5kVzVy
        UGdBQkFnTThiRzkwCgljeUJ2WmlCaWFXNWhjbmtnWjNWdWF6NEFBUUlEUEd4
        dmRITWdiMllnWW1sdVlYSjVJR2QxYm1zK0FBRUNBdz09Cgk8L2RhdGE+Cgk8
        a2V5PsOFYmVucmFhPC9rZXk+Cgk8c3RyaW5nPlRoYXQgd2FzIGEgdW5pY29k
        ZSBrZXkuPC9zdHJpbmc+CjwvZGljdD4KPC9wbGlzdD4Ks\  
        YnBsaXN0MDDfEBABAgMEBQYHCAkKCwwNDg8QERITFCgpLzAxMjM0NTc2OFdh
        QmlnSW50WGFCaWdJbnQyVWFEYXRlVWFEaWN0VmFGbG9hdFVhTGlzdF8QD2FO
        ZWdhdGl2ZUJpZ0ludFxhTmVnYXRpdmVJbnRXYVN0cmluZ1thbkVtcHR5RGlj
        dFthbkVtcHR5TGlzdFVhbkludFpuZXN0ZWREYXRhWHNvbWVEYXRhXHNvbWVN
        b3JlRGF0YWcAxQBiAGUAbgByAGEAYRN/////////1BQAAAAAAAAAAIAAAAAA
        AAAsM0GcuX30AAAA1RUWFxgZGhscHR5bYUZhbHNlVmFsdWVaYVRydWVWYWx1
        ZV1hVW5pY29kZVZhbHVlXWFub3RoZXJTdHJpbmdaZGVlcGVyRGljdAgJawBN
        AOQAcwBzAGkAZwAsACAATQBhAN9fEBU8aGVsbG8gJiAnaGknIHRoZXJlIT7T
        HyAhIiMkUWFRYlFjEBEjQEBAAAAAAACjJSYnEAEQAlR0ZXh0Iz/gAAAAAAAA
        pSorLCMtUUFRQhAMoyUmLhADE////+1foOAAE//////////7VkRvb2RhaNCg
        EQLYoTZPEPo8bG90cyBvZiBiaW5hcnkgZ3Vuaz4AAQIDPGxvdHMgb2YgYmlu
        YXJ5IGd1bms+AAECAzxsb3RzIG9mIGJpbmFyeSBndW5rPgABAgM8bG90cyBv
        ZiBiaW5hcnkgZ3Vuaz4AAQIDPGxvdHMgb2YgYmluYXJ5IGd1bms+AAECAzxs
        b3RzIG9mIGJpbmFyeSBndW5rPgABAgM8bG90cyBvZiBiaW5hcnkgZ3Vuaz4A
        AQIDPGxvdHMgb2YgYmluYXJ5IGd1bms+AAECAzxsb3RzIG9mIGJpbmFyeSBn
        dW5rPgABAgM8bG90cyBvZiBiaW5hcnkgZ3Vuaz4AAQIDTTxiaW5hcnkgZ3Vu
        az5fEBdUaGF0IHdhcyBhIHVuaWNvZGUga2V5LgAIACsAMwA8AEIASABPAFUA
        ZwB0AHwAiACUAJoApQCuALsAygDTAOQA7QD4AQQBDwEdASsBNgE3ATgBTwFn
        AW4BcAFyAXQBdgF/AYMBhQGHAYwBlQGbAZ0BnwGhAaUBpwGwAbkBwAHBAcIB
        xQHHAsQC0gAAAAAAAAIBAAAAAAAAADkAAAAAAAAAAAAAAAAAAALsc               @   s   e Zd Zdd Zd>ddZdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Z dS )?TestPlistlibc             C   s"   yt tj W n   Y nX d S )N)osunlinkr   TESTFN)self r	   #/usr/lib/python3.7/test_plistlib.pytearDown`   s    zTestPlistlib.tearDownNc             C   sv   t ddddddddggd	d
ddddt ddddt dddddgdddddgtddddddt  t d}d|d< |S ) NDoodahAB   g     @@@         g      ?i  l    l   ,        l  @J z<hello & 'hi' there!>u   Mässig, MaßTF   text)abc)ZanotherStringZaUnicodeValueZ
aTrueValueaFalseValueZ
deeperDicts   <binary gunk>s   <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> i  
      !   )aStringZaListZaFloatZanIntZaBigIntZaBigInt2ZaNegativeIntZaNegativeBigIntaDictZsomeDataZsomeMoreDataZ
nestedDataZaDateZanEmptyDictZanEmptyListzThat was a unicode key.u   Åbenraa)dictdatetimelist)r   fmtplr	   r	   r
   _createf   s.    
zTestPlistlib._createc             C   s0   |   }| |d d | |d d d d S )Nr   r   r   r   F)r$   assertEqual)r   r#   r	   r	   r
   test_create   s    zTestPlistlib.test_createc          	   C   s   |   }ttjd}t|| W d Q R X ttjd}t|}W d Q R X | t|t| | 	t
tj|d | 	t
tjd d S )Nwbrbfilename)r$   openr   r   plistlibdumploadr%   r   assertRaisesAttributeError)r   r#   fppl2r	   r	   r
   test_io   s    zTestPlistlib.test_ioc          
   C   sF   t  g}x8tD ]0}| j|d | jttj||d W d Q R X qW d S )N)r"   )objectALL_FORMATSsubTestr.   	TypeErrorr+   dumps)r   r#   r"   r	   r	   r
   test_invalid_type   s    
zTestPlistlib.test_invalid_typec             C   s   x~dD ]v}xpt D ]h}| j||dP tj||d}t|}| |t | || tj||d}| || W d Q R X qW qW x^t D ]V}xPddd d ddd  fD ]2}| j||d | jt	tj||d W d Q R X qW qW d S )	N)r         i  i   l    l        l    l    r   l         )r#   r"   )r"   l           r      r   l         )
r4   r5   r+   r7   loadsassertIsInstanceintr%   r.   OverflowError)r   r#   r"   datar1   data2r	   r	   r
   test_int   s    



 
zTestPlistlib.test_intc             C   s   xdD ]z}xtt D ]l}| j||dT tjt||d}t|}| |t | || tj||d}| || W d Q R X qW qW d S )N)s   <binary gunk>s   <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> <lots of binary gunk> )r#   r"   )r"   )	r4   r5   r+   r7   	bytearrayr<   r=   bytesr%   )r   r#   r"   r@   r1   rA   r	   r	   r
   test_bytearray   s    


zTestPlistlib.test_bytearrayc             C   sJ   |   }t|}t|}| t|t| t|}| || d S )N)r$   r+   r7   r<   r%   r   )r   r#   r@   r1   rA   r	   r	   r
   
test_bytes   s    


zTestPlistlib.test_bytesc             C   s4   ddigggggggg}|  tt|| d S )Ntests   aaaaaa)r%   r+   r<   r7   )r   r@   r	   r	   r
   test_indentation_array   s    z#TestPlistlib.test_indentation_arrayc          
   C   sD   ddddddddd	d
iiiiiiiii}|  tt|| d S )N123456789s   aaaaaa)r%   r+   r<   r7   )r   r@   r	   r	   r
   test_indentation_dict   s    (z"TestPlistlib.test_indentation_dictc             C   s<   dddddigggggigii}|  tt|| d S )NrI   rJ   rK   rG   s   aaaaaa)r%   r+   r<   r7   )r   r@   r	   r	   r
   test_indentation_dict_mix   s     z&TestPlistlib.test_indentation_dict_mixc             C   sl   xfdD ]^}xXt D ]P}| j||d8 tjt| |d}tj||d}| |t| d W d Q R X qW qW d S )N)TF)r"   use_builtin_types)rT   )r"   z2generated data was not identical to Apple's output)r4   r5   r+   r<   TESTDATAr7   r%   )r   rT   r"   r#   r@   r	   r	   r
   test_appleformatting   s    


z!TestPlistlib.test_appleformattingc          
   C   s   d | _ x|tD ]t}| j|d^ | j|d}tjt| |d}| t|t|d tt| }| t|t|d W d Q R X qW d S )N)r"   z2generated data was not identical to Apple's output)	ZmaxDiffr4   r5   r$   r+   r<   rU   r%   r   )r   r"   r#   r1   r	   r	   r
   test_appleformattingfromliteral   s    
z,TestPlistlib.test_appleformattingfromliteralc          
   C   s   xt D ]}| j|dx t }| j|d}tj|||d tjt| |d}| t	|t	| tt| }| t	|t	| W d Q R X qW d S )N)r"   )
r4   r5   r   r$   r+   r,   r-   getvaluer%   r   )r   r"   r   r#   r1   r	   r	   r
   test_bytesio   s    
zTestPlistlib.test_bytesioc             C   s   t  }d|d< d|d< d|d< xtD ]}xdD ]}| j||d t }tj||||d tjt| t jd	}| 	t
|t
| |r| 	t| dddg n| 	t| dddg W d Q R X q0W q&W d S )
Nr   r   r   r   r   r   )FT)r"   	sort_keys)	dict_type)collectionsOrderedDictr4   r5   r   r+   r,   r-   rX   r%   r   r!   keys)r   r#   r"   rZ   r   r1   r	   r	   r
   test_keysort_bytesio   s    


z!TestPlistlib.test_keysort_bytesioc             C   s   t  }d|d< d|d< d|d< xtD ]}xdD ]}| j||dt tj|||d}tj|t jd	}| t|t| |r| t	|
 dddg n| t	|
 dddg W d Q R X q0W q&W d S )
Nr   r   r   r   r   r   )FT)r"   rZ   )r[   )r\   r]   r4   r5   r+   r7   r<   r%   r   r!   r^   )r   r#   r"   rZ   r@   r1   r	   r	   r
   test_keysort  s    

zTestPlistlib.test_keysortc          
   C   sb   ddi}xTt D ]L}| j|d6 | jttj||d t }| jttj|||d W d Q R X qW d S )N*   aNumber)r"   )r4   r5   r.   r6   r+   r7   r   r,   )r   r#   r"   r   r	   r	   r
   test_keys_no_string  s    
z TestPlistlib.test_keys_no_stringc          
   C   s   ddd}xt D ]}| j|dr tj||ddd}t|}| |ddi t }tj|||ddd | }t| }| |ddi W d Q R X qW d S )	Nrb   ZaWord)ra   snake)r"   TF)r"   ZskipkeysrZ   rd   )	r4   r5   r+   r7   r<   r%   r   r,   rX   )r   r#   r"   r@   r1   r0   r	   r	   r
   test_skipkeys  s    

zTestPlistlib.test_skipkeysc          
   C   s   dddd}xzt D ]r}| j|d\ tj||d}t|}| |ddgddgddgd |tjkrz| |d	 |d
  W d Q R X qW d S )N)r   r   )r      )firstsecondthird)r"   r   r   r   rf   rg   rh   )r4   r5   r+   r7   r<   r%   
FMT_BINARYassertIsNot)r   r#   r"   r@   r1   r	   r	   r
   test_tuple_members3  s    


zTestPlistlib.test_tuple_membersc          
   C   s   ddgddgddgd}xpt D ]h}| j|dR tj||d}t|}| |ddgddgddgd | |d |d  W d Q R X qW d S )	Nr   r   r   rf   )rg   rh   ri   )r"   rg   rh   )r4   r5   r+   r7   r<   r%   rk   )r   r#   r"   r@   r1   r	   r	   r
   test_list_membersF  s    

zTestPlistlib.test_list_membersc          
   C   s   ddiddiddid}xpt D ]h}| j|dR tj||d}t|}| |ddiddiddid | |d |d  W d Q R X qW d S )	Nr   r   r   r   )rg   rh   ri   )r"   rg   rh   )r4   r5   r+   r7   r<   r%   rk   )r   r#   r"   r@   r1   r	   r	   r
   test_dict_membersX  s    

zTestPlistlib.test_dict_membersc          
   C   s   xt dD ]}t|}d| }|dks.|dkrZtj|tjd}|dkr| t|| n&| t tj|tjd W d Q R X tj|tj	d q
W d S )N   zstring containing %s    z
	)r"   )
rangechrr+   r7   FMT_XMLr%   r<   r.   
ValueErrorrj   )r   ir   Z
testStringr@   r	   r	   r
   test_controlcharactersj  s    z#TestPlistlib.test_controlcharactersc          
   C   sR   ddi}xDt D ]<}| j|d& tj||d}| t|| W d Q R X qW d S )NZpythonu   🐍)r"   )r4   r5   r+   r7   r%   r<   )r   r#   r"   r@   r	   r	   r
   test_non_bmp_charactersx  s
    
z$TestPlistlib.test_non_bmp_charactersc             C   sr   xlt D ]d}| j|dN | t tjd|d W d Q R X | t tjd|d W d Q R X W d Q R X qW d S )N)r"   u   u   )r4   r5   r.   UnicodeEncodeErrorr+   r7   )r   r"   r	   r	   r
   test_lone_surrogates  s    
z!TestPlistlib.test_lone_surrogatesc          
   C   sz   xtt D ]l}| j|dV d}ddddg}ttj||d}ttj||d}| || | || W d Q R X qW d S )N)r"   abcr   r   r   )r4   r5   r+   r<   r7   r%   )r   r"   Ztest1Ztest2Zresult1Zresult2r	   r	   r
   test_nondictroot  s    
zTestPlistlib.test_nondictrootc             C   s*   x$dD ]}|  ttjd|   qW d S )N)z<key>key inside an array</key>z-<key>key inside an array2</key><real>3</real>z&<true/><key>key inside an array3</key>z <plist><array>%s</array></plist>)r.   ru   r+   r<   encode)r   rv   r	   r	   r
   test_invalidarray  s    

zTestPlistlib.test_invalidarrayc             C   sB   x<dD ]4}|  ttjd|   |  ttjd|   qW d S )N)z0<key><true/>k</key><string>compound key</string>z<key>single key</key>z<string>missing key</string>ze<key>k1</key><string>v1</string><real>5.3</real><key>k1</key><key>k2</key><string>double key</string>z<plist><dict>%s</dict></plist>z-<plist><array><dict>%s</dict></array></plist>)r.   ru   r+   r<   r}   )r   rv   r	   r	   r
   test_invaliddict  s
    


zTestPlistlib.test_invaliddictc             C   s   |  ttjd d S )Ns-   <plist><integer>not integer</integer></plist>)r.   ru   r+   r<   )r   r	   r	   r
   test_invalidinteger  s    
z TestPlistlib.test_invalidintegerc             C   s   |  ttjd d S )Ns*   <plist><integer>not real</integer></plist>)r.   ru   r+   r<   )r   r	   r	   r
   test_invalidreal  s    
zTestPlistlib.test_invalidrealc          
   C   s   t tj }xddtjfddtjfddtjfgD ]n\}}}| jtjd}| j|dD |	d|}||
d| }t|}| t|t| W d Q R X q.W d S )	Ns   utf-8zutf-8s   utf-16z	utf-16-lez	utf-16-be)r"   )encodings   UTF-8)rU   r+   rt   codecsBOM_UTF8BOM_UTF16_LEBOM_UTF16_BEr$   r5   replacedecoder}   r<   r%   r   )r   baseZxml_encodingr   Zbomr#   r@   r1   r	   r	   r
   test_xml_encodings  s    



zTestPlistlib.test_xml_encodings)N)!__name__
__module____qualname__r   r$   r&   r2   r8   rB   rE   rF   rH   rR   rS   rV   rW   rY   r_   r`   rc   re   rl   rm   rn   rw   rx   rz   r|   r~   r   r   r   r   r	   r	   r	   r
   r   ^   s<   


r   c               @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestBinaryPlistlibc             C   s   d}|  t|ddi d S )Ns<   bplist00    QaQb                                  r   r   )r%   r+   r<   )r   r@   r	   r	   r
   test_nonstandard_refs_size  s    z-TestBinaryPlistlib.test_nonstandard_refs_sizec             C   s   xd ddddddt  ddd	dd
d
tdtdddgdddifD ]H}| j|d2 tj|gd tjd}| t|dt	| W d Q R X qBW d S )NFTi90  g^@abcdes   abcdei  r   r   r   r   iY  )r   iY  12)xi  )r"   iL  )
r    r+   DatarC   r5   r7   rj   Z
assertLesslenrepr)r   r   r@   r	   r	   r
   test_dump_duplicates  s    z'TestBinaryPlistlib.test_dump_duplicatesc             C   s   xd ddddddt  ddd	dd
d
tdtdddgdddifD ]v}| j|d` tj|gd tjd}t|\}}t|t	rt
|}| || | || | || W d Q R X qBW d S )NFTi90  g^@r   s   abcdei  r   r   r   r   iY  )r   iY  r   )r   r   )r"   )r    r+   r   rC   r5   r7   rj   r<   
isinstancetupler!   r%   assertIs)r   r   r@   r   r   r	   r	   r
   test_identity  s    
z TestBinaryPlistlib.test_identityc             C   s   g }| | ttj|tjd}| |d | g f}|d  | ttj|tjd}| |d d | i }||d< ttj|tjd}| |d | d S )N)r"   r   r   )appendr+   r<   r7   rj   r   )r   r   r   r	   r	   r
   test_cycles  s    
zTestBinaryPlistlib.test_cyclesc          
   C   sd   x^dD ]V}| j |d@ tjdtj|d }tj|tjd}| t|| W d Q R X qW d S )N)l    l        )tsr   )Zseconds)r"   )	r5   r    ZutcfromtimestampZ	timedeltar+   r7   rj   r%   r<   )r   r   dr@   r	   r	   r
   test_large_timestamp  s    

z'TestBinaryPlistlib.test_large_timestampc          
   C   s>   x8dD ]0}|  tj tjd| tjd W d Q R X qW d S )N)    s"                                *s"                         s"                                 	s%    
                             s)                                	s#   Q                            
s$   a                             s   bplist00)r"   )r.   r+   ZInvalidFileExceptionr<   rj   )r   r@   r	   r	   r
   test_invalid_binary  s    
.z&TestBinaryPlistlib.test_invalid_binaryN)	r   r   r   r   r   r   r   r   r   r	   r	   r	   r
   r     s   
	r   c               @   s$   e Zd Zdd Zdd Zdd ZdS )TestPlistlibDeprecatedc          
   C   s  dddddd}dddt ddd}| tjtj | t t |tj W d Q R X | t t 	tj}W d Q R X | 
|| ttj ttjd(}| t t || W d Q R X W d Q R X ttjd&}| t t 	|}W d Q R X W d Q R X | 
|| d S )	Nra   	   values   buffer)keyaltr@   )r   subr'   r(   )r+   r   Z
addCleanupr   r   r   assertWarnsDeprecationWarningZ
writePlistZ	readPlistr%   r   r*   )r   Zpl_inZpl_outr1   r0   r	   r	   r
   test_io_deprecated3  s,     z)TestPlistlibDeprecated.test_io_deprecatedc             C   s   dddddd}|  t t|}W d Q R X |  t t|}W d Q R X | |t | |tdtddtddd |  t t|}W d Q R X | || d S )Nra   r   r   s   buffer)r   r   r@   )r   r   )	r   r   r+   ZwritePlistToBytesreadPlistFromBytesr=   r   r%   r   )r   r#   r@   r1   rA   r	   r	   r
   test_bytes_deprecatedZ  s$    z,TestPlistlibDeprecated.test_bytes_deprecatedc          	   C   s   dt di}ddi}t |}t |}| || | || t j|dd}| || | || | t t |}W d Q R X | || | || d S )Nr   s   helloF)rT   )r+   r   r7   r<   r%   r   r   r   )r   Zin_dataZout_databufZcurr	   r	   r
   test_dataobject_deprecatedw  s    

z1TestPlistlibDeprecated.test_dataobject_deprecatedN)r   r   r   r   r   r   r	   r	   r	   r
   r   2  s   'r   c               @   s   e Zd Zdd ZdS )MiscTestCasec             C   s   ddh}t j| t|d d S )NZPlistFormatZPLISTHEADER)	blacklist)r   Zcheck__all__r+   )r   r   r	   r	   r
   test__all__  s    zMiscTestCase.test__all__N)r   r   r   r   r	   r	   r	   r
   r     s   r   c               C   s   t ttt d S )N)r   Zrun_unittestr   r   r   r	   r	   r	   r
   	test_main  s    r   __main__)Zunittestr+   r   r    r   Zbinasciir\   rG   r   ior   rt   rj   r4   Z
a2b_base64rU   ZTestCaser   r   r   r   r   r   r	   r	   r	   r
   <module>   s,   3  csY