B
    u9a                 @   s  d dl Zd dlm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
Z
d dlZd dlZejddgdZejddgdZdd ZG d	d
 d
ZG dd deejZeedG dd deejZG dd dZG dd deejZeedG dd deejZedkre  dS )    N)supportuuid_uuid)Zblocked)Zfreshc             C   s   yt |  dS    dS d S )NTF)
__import__)name r   /usr/lib/python3.7/test_uuid.py
importable   s
    r	   c               @   s  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
eddeejdkddd Zejdd Zeejdkddd Zeejdkddd Zeejdkddd Zeejdkddd Zd d! Zd"d# Zd$d% Zeejdkd&d'd( ZdS ))BaseTestUUIDNc             C   s  | j }g }xdddddddddd| jjd fdd	d
ddddddd| jjd fdddddddddd| jjdfdddd d!d"d#d$d%d&| jjd fd'd(d)d*d+d,d-d.d/d0| jjd1fd2d3d4d5d6d7d8d9d:d0| jjd1fd;d<d=d>d?d@dAdBdCd0| jjd1fdDdEdFdGdHdIdJdKdLd0| jjd1fdMdNdOdPdQdRdSdTdUdV| jjd1fdWdXdYdZd[d\d]d^d_d`| jjdfdadbdcdddedfdgdhdidj| jjdkfdldmdndodpdqdrdsdtdu| jjd1fdvdwdxdydzd{d|d}d~d| jjd fdddddddddd| jjd fgD ]\}}}}}}}	}
}}}}g }xf| j|| j|| j|| jj|d| jj|d| jj|d| jj|	d| j|
gD ]}|t|| |t||	 ||j| ||j	| ||j
| ||j|d  ||j|d1  ||j|d  ||j|d  ||j|dk  ||j|d  ||j| ||j|	 ||j|
 ||j| ||j| ||j| ||j| || q8W x(|D ] }x|D ]}||| qRW qHW |t|jtj |t|j	tj || qW xtt|D ]}xtt|D ]}|||k || || k  |||k|| || k |||k|| || k |||k|| || k |||k|| || k |||k|| || k qW qW |d d  }|  |  ||| d S )Nz$00000000-0000-0000-0000-000000000000z&{00000000-0000-0000-0000-000000000000} 00000000000000000000000000000000s                   )r   r   r   r   r   r   r   z-urn:uuid:00000000-0000-0000-0000-000000000000z$00010203-0405-0607-0809-0a0b0c0d0e0fz&{00010203-0405-0607-0809-0a0b0c0d0e0f}Z 000102030405060708090a0b0c0d0e0fs    	
s    	
)i i  i     	   l   ,(l   ,(H@p`   z-urn:uuid:00010203-0405-0607-0809-0a0b0c0d0e0fl    80i	  z$02d9e6d5-9467-382e-8f9b-9300a64ac3cdz&{02d9e6d5-9467-382e-8f9b-9300a64ac3cd}Z 02d9e6d59467382e8f9b9300a64ac3cds   Քg8. Js   g.8 J)iig  i.8        l   CLL l	   CLL|e5l z-urn:uuid:02d9e6d5-9467-382e-8f9b-9300a64ac3cdl   fQtAi     z$12345678-1234-5678-1234-567812345678z&{12345678-1234-5678-1234-567812345678}Z 12345678123456781234567812345678s   4Vx4Vx4Vx4Vxs   xV44xV4Vx4Vx)ixV4i4  ixV     4   l   xVh$Y l	   xVh$YgF+ z-urn:uuid:12345678-1234-5678-1234-567812345678l   xVh$H3i4  z$6ba7b810-9dad-11d1-80b4-00c04fd430c8z&{6ba7b810-9dad-11d1-80b4-00c04fd430c8}Z 6ba7b8109dad11d180b400c04fd430c8s   kр O0s   k O0)iki  i        l   0l	   05'Sk z-urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8l   8OWvr      z$6ba7b811-9dad-11d1-80b4-00c04fd430c8z&{6ba7b811-9dad-11d1-80b4-00c04fd430c8}Z 6ba7b8119dad11d180b400c04fd430c8s   kр O0s   k O0)iki  i  r   r   l   0l	   05gSk z-urn:uuid:6ba7b811-9dad-11d1-80b4-00c04fd430c8l   8OWvz$6ba7b812-9dad-11d1-80b4-00c04fd430c8z&{6ba7b812-9dad-11d1-80b4-00c04fd430c8}Z 6ba7b8129dad11d180b400c04fd430c8s   kр O0s   k O0)iki  i  r   r   l   0l	   05Sk z-urn:uuid:6ba7b812-9dad-11d1-80b4-00c04fd430c8l   8OWvz$6ba7b814-9dad-11d1-80b4-00c04fd430c8z&{6ba7b814-9dad-11d1-80b4-00c04fd430c8}Z 6ba7b8149dad11d180b400c04fd430c8s   kр O0s   k O0)iki  i  r   r   l   0l	   05'Sk z-urn:uuid:6ba7b814-9dad-11d1-80b4-00c04fd430c8l   8OWvz$7d444840-9dc0-11d1-b245-5ffdce74fad2z&{7d444840-9dc0-11d1-b245-5ffdce74fad2}Z 7d4448409dc011d1b2455ffdce74fad2s   }DH@ѲE_ts   @HD}E_t)i@HD}i  i     E   l   z l	   z*8'$"} z-urn:uuid:7d444840-9dc0-11d1-b245-5ffdce74fad2l   @HzwiE2  z$e902893a-9d22-3c7e-a7b8-d6e313b71d9fz&{e902893a-9d22-3c7e-a7b8-d6e313b71d9f}Z e902893a9d223c7ea7b8d6e313b71d9fs   :"<~s   :"~<)l   :	R i"  i~<        l   n'[ l	   n'[=GG$ND z-urn:uuid:e902893a-9d22-3c7e-a7b8-d6e313b71d9fl   :	Rtci'  z$eb424026-6f54-4ef8-a4d0-bb658a1fc6cfz&{eb424026-6f54-4ef8-a4d0-bb658a1fc6cf}Z eb4240266f544ef8a4d0bb658a1fc6cfs   B@&oTNлes   &@BToNлe)l   &@V iTo  iN        l   F?m l	   F?m&oj	 ! z-urn:uuid:eb424026-6f54-4ef8-a4d0-bb658a1fc6cfl   &@VS=wi$     z$f81d4fae-7dec-11d0-a765-00a0c91e6bf6z&{f81d4fae-7dec-11d0-a765-00a0c91e6bf6}Z f81d4fae7dec11d0a76500a0c91e6bf6s   O}Чe ks   O}e k)l   O:p i}  i  r   e   l   k<l	   k<(;
=k z-urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6l   O:pwie'  z$fffefdfc-fffe-fffe-fffe-fffefdfcfbfaz&{fffefdfc-fffe-fffe-fffe-fffefdfcfbfa}Z fffefdfcfffefffefffefffefdfcfbfas   s   )l   } i  i        l   {{ l	   {{?~ z-urn:uuid:fffefdfc-fffe-fffe-fffe-fffefdfcfbfal   }i?  z$ffffffff-ffff-ffff-ffff-ffffffffffffz&{ffffffff-ffff-ffff-ffff-ffffffffffff}Z ffffffffffffffffffffffffffffffffs   )l    i  i  r   r   l    l	    z-urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffffl   i?  )bytes)bytes_le)fields)int      )assertEqualr   ZRESERVED_NCSRFC_4122ZRESERVED_FUTUREUUIDstrr#   r    r!   r"   time_lowtime_midtime_hi_versionclock_seq_hi_variantclock_seq_lownodehexurntime	clock_seqvariantversionappendtypebuiltinsrangelenreversesort)selfequalZ	ascendingstringZcurlyr0   r    r!   r"   Zintegerr1   r2   r3   r4   r5   ZequivalentsuvijZresortedr   r   r   	test_UUID   sV   0"

&zBaseTestUUID.test_UUIDc          	      s  fdd}fdd}|fdd |fdd |fdd |fdd |fdd |fd	d |fd
d |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fdd |fd d |fd!d d"\j  j jd# j jd$ j jd% j jd& j jd' |fd(d |fd)d |fd*d |fd+d |fd,d xg d-fggD ]}xg d.fggD ]}xg d/fggD ]}xg d0fggD ]z}xrg d1fggD ]`}t|| | | |  t d2krZ| fd3d t d4kr| fd5d qW qW qW qW qW j |fd6d |fd7d |fd8d |fd9d |fd:d |fd;d |fd<d |fd=d |fd>d |fd?d |fd@d |fdAd |fdBd |fdCd d S )DNc                s     t| S )N)assertRaises
ValueError)f)r=   r   r   <lambda>       z.BaseTestUUID.test_exceptions.<locals>.<lambda>c                s     t| S )N)rE   	TypeError)rG   )r=   r   r   rH      rI   c                  s    j dS )N )r   r(   r   )r=   r   r   rH      rI   c                  s    j dS )Nabc)r   r(   r   )r=   r   r   rH      rI   c                  s    j dS )NZ1234567812345678123456781234567)r   r(   r   )r=   r   r   rH      rI   c                  s    j dS )NZ!123456781234567812345678123456789)r   r(   r   )r=   r   r   rH      rI   c                  s    j dS )NZ 123456781234567812345678z2345678)r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )NrL   )r    )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )Nz               )r    )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )Nz                 )r    )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )NrL   )r!   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )Nz               )r!   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )Nz                 )r!   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r$   r   r   r%   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r$   r   r   r%         )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   r   r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)l        r   r   r   r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   rO   r   r   r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   i   r   r   r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   rO   r   r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   i   r   r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   r   rO   r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   r      r   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   r   r   rO   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   r   r   rP   r   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   r   r   r   rO   )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )N)r   r   r   r   r   l          )r"   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jdddS )Nr   r   )r5   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jdddS )Nr   rM   )r5   )r   r(   r   )r=   r   r   rH      rI   c                  s    j jddS )NrO   )r#   )r   r(   r   )r=   r   r   rH     rI   c                  s    j jdd> dS )Nr   r   )r#   )r   r(   r   )r=   r   r   rH     rI   )r   s                   )r   r   r   r   r   r   r   )r0   )r    )r!   )r"   )r#   c                  s
    j  S )N)r   r(   r   )r=   r   r   rH     rI   c                  s   j  S )N)r   r(   r   )bhr=   r   r   rH     rI   c                  s   j   S )N)r   r(   r   )rQ   rR   r=   r   r   rH     rI   c                  s   j   S )N)r   r(   r   )rQ   rG   rR   r=   r   r   rH     rI   c                  s   j   S )N)r   r(   r   )rQ   rG   rR   rB   r=   r   r   rH     rI   r0   r    r!   r#   r"   r   c                  s   j jf S )N)r   r(   r   )argsrR   r=   r   r   rH     rI   r   c                  s   j jf  S )N)r   r(   r   )rS   r=   r   r   rH      rI   c                  s   t d S )Nr0   )setattrr   )rR   r@   r   r   rH   $  rI   c                  s   t d S )Nr    )rT   r   )rQ   r@   r   r   rH   %  rI   c                  s   t d S )Nr!   )rT   r   )rQ   r@   r   r   rH   &  rI   c                  s   t d S )Nr"   )rT   r   )rG   r@   r   r   rH   '  rI   c                  s   t d S )Nr#   )rT   r   )rB   r@   r   r   rH   (  rI   c                  s   t  ddS )Nr*   r   )rT   r   )r@   r   r   rH   )  rI   c                  s   t  ddS )Nr+   r   )rT   r   )r@   r   r   rH   *  rI   c                  s   t  ddS )Nr,   r   )rT   r   )r@   r   r   rH   +  rI   c                  s   t  ddS )Nr,   r   )rT   r   )r@   r   r   rH   ,  rI   c                  s   t  ddS )Nr-   r   )rT   r   )r@   r   r   rH   -  rI   c                  s   t  ddS )Nr.   r   )rT   r   )r@   r   r   rH   .  rI   c                  s   t  ddS )Nr/   r   )rT   r   )r@   r   r   rH   /  rI   c                  s
    t  k S )N)objectr   )r@   r   r   rH   2  rI   c                  s
    t  kS )N)rU   r   )r@   r   r   rH   3  rI   )r   r(   dictr:   )r=   ZbadvalueZbadtypeZhhZbbZbbleiiZffr   )rS   rQ   rG   rR   rB   r=   r@   r   test_exceptions   s    0zBaseTestUUID.test_exceptionsc             C   sR   | j  }| d|  k o dk n  d|  | j  }| ||d||f  d S )Nr   l          z%012xz%012x != %012x)r   getnode
assertTruer&   )r=   Znode1node2r   r   r   test_getnode5  s    
$
zBaseTestUUID.test_getnodec                s    fdd}t tjd j x jjD ]|} jjd|d}|t|| |t|| xFt	t
jd D ]4} j|d |t
t
||| W d Q R X qnW q*W W d Q R X d S )Nc                s      | |   | j|j d S )N)r&   is_safe)actualexpected)r=   r   r   check>  s    z1BaseTestUUID.test_pickle_roundtrip.<locals>.checkr    d82579ce6642a0de7ddf490a7aec7aa5)r]   r   )Zprotocol)r   	swap_itemsysmodulesr   SafeUUIDr(   copyZdeepcopyr9   pickleZHIGHEST_PROTOCOLZsubTestloadsdumps)r=   r`   r]   r@   protor   )r=   r   test_pickle_roundtrip=  s    z"BaseTestUUID.test_pickle_roundtripc       	         s    fdd}ddddddd	d
dddddg}dddddg}dddddg} j d} j jd j jjd} j jd j jjd}ttjd j ` x|D ]}|t	
|| qW x|D ]}|t	
|| qW x|D ]}|t	
|| qW W d Q R X d S )Nc                s      | |   | j|j d S )N)r&   r]   )r^   r_   )r=   r   r   r`   M  s    zBBaseTestUUID.test_unpickle_previous_python_versions.<locals>.checksr   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR(dS'int'
L287307832597519156748809049798316161701L
sb.so   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR}UintL287307832597519156748809049798316161701L
sb.s+   cuuid
UUID
)}Uintzz
I}ޠBfy% sb.sp   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR(dVint
L287307832597519156748809049798316161701L
sb.sr   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR}X   intL287307832597519156748809049798316161701L
sb.s.   cuuid
UUID
)}X   intzz
I}ޠBfy% sb.s.   cuuid
UUID
)}X   intzz
I}ޠBfy% sb.s6   +       uuidUUID)}intzz
I}ޠBfy% sb.s   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR(dVint
L287307832597519156748809049798316161701L
sVis_safe
cuuid
SafeUUID
(NtRsb.s   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR}(X   intL287307832597519156748809049798316161701L
X   is_safecuuid
SafeUUID
(NtRub.sM   cuuid
UUID
)}(X   intzz
I}ޠBfy% X   is_safecuuid
SafeUUID
NRub.sM   cuuid
UUID
)}(X   intzz
I}ޠBfy% X   is_safecuuid
SafeUUID
NRub.sQ   F       uuidUUID)}(intzz
I}ޠBfy% is_safeh SafeUUIDNRub.s   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR(dVint
L287307832597519156748809049798316161701L
sVis_safe
cuuid
SafeUUID
(I0
tRsb.s   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR}(X   intL287307832597519156748809049798316161701L
X   is_safecuuid
SafeUUID
(K tRub.sN   cuuid
UUID
)}(X   intzz
I}ޠBfy% X   is_safecuuid
SafeUUID
K Rub.sN   cuuid
UUID
)}(X   intzz
I}ޠBfy% X   is_safecuuid
SafeUUID
K Rub.sR   G       uuidUUID)}(intzz
I}ޠBfy% is_safeh SafeUUIDK Rub.s   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR(dVint
L287307832597519156748809049798316161701L
sVis_safe
cuuid
SafeUUID
(I-1
tRsb.s   ccopy_reg
_reconstructor
(cuuid
UUID
c__builtin__
object
NtR}(X   intL287307832597519156748809049798316161701L
X   is_safecuuid
SafeUUID
(JtRub.sQ   cuuid
UUID
)}(X   intzz
I}ޠBfy% X   is_safecuuid
SafeUUID
JRub.sQ   cuuid
UUID
)}(X   intzz
I}ޠBfy% X   is_safecuuid
SafeUUID
JRub.sU   J       uuidUUID)}(intzz
I}ޠBfy% is_safeh SafeUUIDJRub.ra   )r]   r   )r   r(   re   safeunsafer   rb   rc   rd   rg   rh   )	r=   r`   Zpickled_uuidsZpickled_uuids_safeZpickled_uuids_unsafer@   Zu_safeZu_unsafeZpickledr   )r=   r   &test_unpickle_previous_python_versionsL  sH    


z3BaseTestUUID.test_unpickle_previous_python_versionsc          
   C   s   dd }t jjj| jd |g|gd | j }W d Q R X | d|  k oPdk n  d|  y| jj|d W n, tk
r } z| 	d W d d }~X Y nX d S )	Nc               S   s   dS )Nl          r   r   r   r   r   rH     rI   z/BaseTestUUID.test_uuid1_eui64.<locals>.<lambda>)Z_nodeZ_NODE_GETTERS_WIN32Z_NODE_GETTERS_UNIXr   l          z%012x)r/   z"uuid1 was given an invalid node ID)
unittestmockpatchZmultipler   rY   rZ   uuid1rF   Zfail)r=   Ztoo_large_getterr/   er   r   r   test_uuid1_eui64  s    $zBaseTestUUID.test_uuid1_eui64c                s   j }x` fddtdD D ]F}||j jj ||jd  |j jjj	 jjj
 jjjh qW i }x& fddtdD D ]}d||< qW |t| d  jd}||jd  jd}||jd  jd	}||jd	  jdd}||jd ||jd
@ d> |jB d  jdd}||jd ||jd
@ d> |jB d  jdd}||jd ||jd
@ d> |jB d d S )Nc                s   g | ]} j  qS r   )r   rr   ).0rB   )r=   r   r   
<listcomp>  s    z+BaseTestUUID.test_uuid1.<locals>.<listcomp>
   r   c                s   g | ]} j  qS r   )r   rr   )ru   rB   )r=   r   r   rv     s    i  r   l   ,Hl    ?   r   i4  i?  )r&   r9   r4   r   r'   r5   ZassertInr]   re   rl   rm   unknownr:   keysrr   r/   r-   r.   )r=   r>   r@   uuidsr   )r=   r   
test_uuid1  s8    zBaseTestUUID.test_uuid1rw   r%   posixzPOSIX-only testc             C   s4   | j js| d | j  }| |j| j jj d S )Nz#requires uuid_generate_time_safe(3))r   Z_has_uuid_generate_time_safeskipTestrr   assertNotEqualr]   re   ry   )r=   r@   r   r   r   test_uuid1_safe  s    

zBaseTestUUID.test_uuid1_safec          	   #   sl   t jdkr| d | j  | jj  dkr8| d tjj	| jd fdd dV  W dQ R X dS )zQ
        Mock uuid._generate_time_safe() to return a given *safe_value*.
        r}   zPOSIX-only testNzneed uuid._generate_time_safe_generate_time_safec                  s     d fS )Nr   r   r   )rG   
safe_valuer   r   rH     rI   z6BaseTestUUID.mock_generate_time_safe.<locals>.<lambda>)
osr   r~   r   Z_load_system_functionsr   ro   rp   rq   rU   )r=   r   r   )rG   r   r   mock_generate_time_safe  s    



z$BaseTestUUID.mock_generate_time_safec          	   C   s8   |  d $ | j }| |j| jjj W d Q R X d S )N)r   r   rr   r&   r]   re   ry   )r=   r@   r   r   r   test_uuid1_unknown   s    
zBaseTestUUID.test_uuid1_unknownc          	   C   s8   |  d$ | j }| |j| jjj W d Q R X d S )Nr   )r   r   rr   r&   r]   re   rl   )r=   r@   r   r   r   test_uuid1_is_safe(  s    
zBaseTestUUID.test_uuid1_is_safec          	   C   s8   |  d$ | j }| |j| jjj W d Q R X d S )NrO   )r   r   rr   r&   r]   re   rm   )r=   r@   r   r   r   test_uuid1_is_unsafe.  s    
z!BaseTestUUID.test_uuid1_is_unsafec          	   C   s8   |  d$ | j }| |j| jjj W d Q R X d S )Nr   )r   r   rr   r&   r]   re   ry   )r=   r@   r   r   r   test_uuid1_bogus_return_value4  s    
z*BaseTestUUID.test_uuid1_bogus_return_valuec             C   s   | j }x| j| jjddf| j| jjddf| j| jjddf| j| jjddfgD ]D\}}||j| jj ||j	d	 ||| j
| |t|| q\W d S )
Nz
python.orgz$6fa459ea-ee8a-3ca4-894e-db77e160355ezhttp://python.org/z$9fe8e8c4-aaa8-32a9-a55c-4535a88b748dz1.3.6.1z$dd1a1cef-13d5-368a-ad82-eca71acd4cd1zc=caz$658d3002-db6b-3040-a1d1-8ddd7d189a4dr   )r&   r   Zuuid3NAMESPACE_DNSNAMESPACE_URLNAMESPACE_OIDNAMESPACE_X500r4   r'   r5   r(   r)   )r=   r>   r@   rA   r   r   r   
test_uuid3:  s    zBaseTestUUID.test_uuid3c                s    j }x: fddtdD D ] }||j jj ||jd qW i }x& fddtdD D ]}d||< q^W |t| d d S )Nc                s   g | ]} j  qS r   )r   uuid4)ru   rB   )r=   r   r   rv   P  s    z+BaseTestUUID.test_uuid4.<locals>.<listcomp>rw   r   c                s   g | ]} j  qS r   )r   r   )ru   rB   )r=   r   r   rv   V  s    i  r   )r&   r9   r4   r   r'   r5   r:   rz   )r=   r>   r@   r{   r   )r=   r   
test_uuid4L  s    zBaseTestUUID.test_uuid4c             C   s   | j }x| j| jjddf| j| jjddf| j| jjddf| j| jjddfgD ]D\}}||j| jj ||j	d	 ||| j
| |t|| q\W d S )
Nz
python.orgz$886313e1-3b8a-5372-9b90-0c9aee199e5dzhttp://python.org/z$4c565f0d-3f5a-5890-b41b-20cf47701c5ez1.3.6.1z$1447fa61-5277-5fef-a9b3-fbc6e44f4af3zc=caz$cc957dd1-a972-5349-98cd-874190002798r%   )r&   r   Zuuid5r   r   r   r   r4   r'   r5   r(   r)   )r=   r>   r@   rA   r   r   r   
test_uuid5Z  s    zBaseTestUUID.test_uuid5zrequires Posixc             C   s   t  }t  }|dkrTt |d  | j }t |d |jd t 	d nZt |d  | 
t j|d  | j j}t |d t |d dd}| || d S )Nr   r   zlatin-1d   )r   pipeforkcloser   r   writer0   encode_exitZ
addCleanupwaitpidreaddecoder   )r=   ZfdspidvalueZparent_valueZchild_valuer   r   r   testIssue8621l  s    
zBaseTestUUID.testIssue8621)__name__
__module____qualname__r   rD   rX   r\   rk   rn   rt   r|   r   Zrequires_mac_verro   
skipUnlessr   r   r   
contextlibcontextmanagerr   r   r   r   r   r   r   r   r   r   r   r   r   r
      s(    ;_y(
r
   c               @   s   e Zd ZeZdS )TestUUIDWithoutExtModuleN)r   r   r   py_uuidr   r   r   r   r   r     s   r   zrequires the C _uuid modulec               @   s   e Zd ZeZdS )TestUUIDWithExtModuleN)r   r   r   c_uuidr   r   r   r   r   r     s   r   c               @   sD  e Zd ZdZeejdkddd Zd$ddZ	eejdkddd	 Z
eejdkdd
d Zeejdkddd Zeejdkddd Zeejdkddd Zeejdkddd Zeeddeedddd Zdd Zeejdkddd Zeejdkdeed d!d"d# ZdS )%BaseTestInternalsNr}   zrequires Posixc          
   C   s   d}t j }t| |_t jjjt	ddd@ t jjjt
d|d  | jjdddgd	d
 d}W d Q R X W d Q R X | |d d S )Nz
fake hwaddr
cscotun0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
eth0      Link encap:Ethernet  HWaddr 12:34:56:78:90:ab
Zwhichz/sbin/ifconfig)Zreturn_valuePopenifconfigrK   s   hwaddrc             S   s   | d S )Nr   r   )xr   r   r   rH     rI   z1BaseTestInternals.test_find_mac.<locals>.<lambda>)ZcommandrS   Zhw_identifiersZ	get_indexl   ,H)ro   rp   Z	MagicMockioBytesIOr   stdoutrq   rU   shutil
subprocessr   Z	_find_macr&   )r=   datapopenZmacr   r   r   test_find_mac  s    


 zBaseTestInternals.test_find_macc             C   s`   |r|d kr|  d|  d| }tjdkr8t|dd | d|  k oNdk n  d|  d S )	Nz	requires z%012xr$    )endr   l          z%s is not an RFC 4122 node ID)r~   r   verboseprintrZ   )r=   r/   Zrequiresr0   r   r   r   
check_node  s    
zBaseTestInternals.check_nodec             C   s   | j  }| |d d S )Nr   )r   Z_ifconfig_getnoder   )r=   r/   r   r   r   test_ifconfig_getnode  s    
z'BaseTestInternals.test_ifconfig_getnodec             C   s   | j  }| |d d S )NZip)r   Z_ip_getnoder   )r=   r/   r   r   r   test_ip_getnode  s    
z!BaseTestInternals.test_ip_getnodec             C   s   | j  }| |d d S )NZarp)r   Z_arp_getnoder   )r=   r/   r   r   r   test_arp_getnode  s    
z"BaseTestInternals.test_arp_getnodec             C   s   | j  }| |d d S )NZlanscan)r   Z_lanscan_getnoder   )r=   r/   r   r   r   test_lanscan_getnode  s    
z&BaseTestInternals.test_lanscan_getnodec             C   s   | j  }| |d d S )NZnetstat)r   Z_netstat_getnoder   )r=   r/   r   r   r   test_netstat_getnode  s    
z&BaseTestInternals.test_netstat_getnodentzrequires Windowsc             C   s   | j  }| |d d S )NZipconfig)r   Z_ipconfig_getnoder   )r=   r/   r   r   r   test_ipconfig_getnode  s    
z'BaseTestInternals.test_ipconfig_getnodeZ	win32wnetzrequires win32wnetZnetbioszrequires netbiosc             C   s   | j  }| | d S )N)r   Z_netbios_getnoder   )r=   r/   r   r   r   test_netbios_getnode  s    
z&BaseTestInternals.test_netbios_getnodec             C   sH   | j  }| |d@ d|  | | | j  }| ||d|  d S )Nl        z%012x)r   Z_random_getnoderZ   r   r   )r=   r/   r[   r   r   r   test_random_getnode  s
    


z%BaseTestInternals.test_random_getnodec             C   sX   t dst ds| d y| j }W n tk
rF   | d Y nX | |d d S )Nr   ctypesz,neither _uuid extension nor ctypes availablezrequires uuid_generate_timeZunix)r	   r~   r   Z_unix_getnoderJ   r   )r=   r/   r   r   r   test_unix_getnode  s    
z#BaseTestInternals.test_unix_getnoder   zrequires ctypesc             C   s   | j  }| | d S )N)r   Z_windll_getnoder   )r=   r/   r   r   r   test_windll_getnode  s    
z%BaseTestInternals.test_windll_getnode)N)r   r   r   r   ro   r   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r     s   
	
r   c               @   s   e Zd ZeZdS )TestInternalsWithoutExtModuleN)r   r   r   r   r   r   r   r   r   r     s   r   c               @   s   e Zd ZeZdS )TestInternalsWithExtModuleN)r   r   r   r   r   r   r   r   r   r     s   r   __main__)Zunittest.mockro   Ztestr   r8   r   rf   r   r   rg   r   r   rc   Zimport_fresh_moduler   r   r	   r
   ZTestCaser   r   r   r   r   r   r   mainr   r   r   r   <module>   s6       nd
