B
    u9aº  ã               @   s`   d dl Z d dlZd dlZd dlZd dlT G dd„ dejƒZG dd„ dejƒZe	dkr\e 
¡  dS )é    N)Ú*c               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚEmptyNodeListTestCasez"Tests for the EmptyNodeList class.c          	   C   sf   t ƒ }|  | d¡¡ |  | d¡¡ |  t¡ |d  W d Q R X |  t¡ |d  W d Q R X d S )Nr   éÿÿÿÿ)ÚEmptyNodeListÚassertIsNoneÚitemÚassertRaisesÚ
IndexError)ÚselfÚ	node_list© r   ú-/usr/lib/python3.7/test_xml_dom_minicompat.pyÚtest_emptynodelist_item   s    z-EmptyNodeListTestCase.test_emptynodelist_itemc          	   C   s8   t ƒ }|  |jd¡ |  tjj¡ d|_W d Q R X d S )Nr   éo   )r   ÚassertEqualÚlengthr   ÚxmlÚdomÚNoModificationAllowedErr)r
   r   r   r   r   Útest_emptynodelist_length   s    z/EmptyNodeListTestCase.test_emptynodelist_lengthc             C   s   t ƒ tƒ  }|  |tƒ ¡ d S )N)r   ÚNodeListr   )r
   r   r   r   r   Útest_emptynodelist___add__"   s    z0EmptyNodeListTestCase.test_emptynodelist___add__c             C   s"   ddgt ƒ  }|  |ddg¡ d S )Né   é   )r   r   )r
   r   r   r   r   Útest_emptynodelist___radd__&   s    z1EmptyNodeListTestCase.test_emptynodelist___radd__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s
   r   c               @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )ÚNodeListTestCasezTests for the NodeList class.c          	   C   s¼   t ƒ }|  | d¡¡ |  | d¡¡ |  t¡ |d  W d Q R X |  t¡ |d  W d Q R X | d¡ | d¡ |  | d¡d¡ |  | d¡¡ |  |d d¡ |  |d d¡ d S )Nr   r   r   iç  )r   r   r   r   r	   Úappendr   )r
   r   r   r   r   Útest_nodelist_item.   s    

z#NodeListTestCase.test_nodelist_itemc          	   C   s>   t ddgƒ}|  |jd¡ |  tjj¡ d|_W d Q R X d S )Nr   r   r   )r   r   r   r   r   r   r   )r
   r   r   r   r   Útest_nodelist_lengthE   s    z%NodeListTestCase.test_nodelist_lengthc             C   s0   t ddgƒddg }|  |t ddddgƒ¡ d S )Né   é   r   r   )r   r   )r
   r   r   r   r   Útest_nodelist___add__M   s    z&NodeListTestCase.test_nodelist___add__c             C   s0   ddgt ddgƒ }|  |t ddddgƒ¡ d S )Nr   r   r#   r$   )r   r   )r
   r   r   r   r   Útest_nodelist___radd__Q   s    z'NodeListTestCase.test_nodelist___radd__c             C   s’   xŒt tjd ƒD ]z}tƒ }t ||¡}t |¡}|  ||¡ |  ||¡ | d¡ | d¡ t ||¡}t |¡}|  ||¡ |  ||¡ qW d S )Nr   r   )	ÚrangeÚpickleZHIGHEST_PROTOCOLr   ÚdumpsÚloadsÚassertIsNotr   r    )r
   Úprotor   ZpickledZ	unpickledr   r   r   Útest_nodelist_pickle_roundtripU   s    



z/NodeListTestCase.test_nodelist_pickle_roundtripc             C   sŠ   t ƒ }t |¡}|  ||¡ |  ||¡ | dg¡ | dg¡ t |¡}|  ||¡ |  ||¡ x"t||ƒD ]\}}|  ||¡ qnW d S )Nr   r   )r   Úcopyr+   r   r    ÚzipZassertIs)r
   r   ÚcopiedÚxÚyr   r   r   Útest_nodelist_copyh   s    

z#NodeListTestCase.test_nodelist_copyc             C   s–   t ƒ }t |¡}|  ||¡ |  ||¡ | dg¡ | dg¡ t |¡}|  ||¡ |  ||¡ x.t||ƒD ] \}}|  ||¡ |  ||¡ qnW d S )Nr   r   )r   r.   Zdeepcopyr+   r   r    r/   )r
   r   r0   r1   r2   r   r   r   Útest_nodelist_deepcopyx   s    

z'NodeListTestCase.test_nodelist_deepcopyN)r   r   r   r   r!   r"   r%   r&   r-   r3   r4   r   r   r   r   r   +   s   r   Ú__main__)r.   r(   ZunittestZxml.domr   Zxml.dom.minicompatZTestCaser   r   r   Úmainr   r   r   r   Ú<module>   s    ^