ó
‹wÛjc           @   s}  d  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 Z d d l	 Z	 d d l
 Z
 d d l Z d d d „  ƒ  YZ d e f d „  ƒ  YZ d d d	 „  ƒ  YZ d
 d d „  ƒ  YZ d d d „  ƒ  YZ d e j e e f d „  ƒ  YZ d e j e e f d „  ƒ  YZ d e j e e f d „  ƒ  YZ d e j f d „  ƒ  YZ d „  Z e d k rye ƒ  n  d S(   sT   Unit tests for the memoryview

XXX We need more tests! Some tests are in test_bytes
iÿÿÿÿN(   t   test_supportt   AbstractMemoryTestsc           B   s³   e  Z d  Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   t   abcdefc         C   s   |  j  S(   N(   t   source_bytes(   t   self(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   _source   s    c         C   s   t  d  |  j |  j g ƒ S(   N(   t   filtert   Nonet   ro_typet   rw_type(   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   _types   s    c            s„  |  j  } | |  j ƒ } t j | ƒ } |  j | ƒ ‰  |  j ˆ  d | d ƒ ƒ |  j ˆ  d t ƒ |  j ˆ  d | d ƒ ƒ |  j ˆ  d | d ƒ ƒ |  j ˆ  d | d ƒ ƒ |  j t	 ‡  f d †  ƒ |  j t	 ‡  f d †  ƒ |  j t	 ‡  f d	 †  ƒ |  j t	 ‡  f d
 †  ƒ |  j t
 ‡  f d †  ƒ |  j t
 ‡  f d †  ƒ |  j t
 ‡  f d †  ƒ d  ‰  |  j t j | ƒ | ƒ d  S(   Ni    t   ai   t   fiÿÿÿÿiúÿÿÿc              s   ˆ  d S(   Ni   (    (    (   t   m(    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   <lambda>(   t    c              s   ˆ  d S(   Niùÿÿÿ(    (    (   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   )   R   c              s   ˆ  t  j S(   N(   t   syst   maxsize(    (   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   *   R   c              s   ˆ  t  j S(   N(   R   R   (    (   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   +   R   c              s   ˆ  d  S(   N(   R   (    (   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   -   R   c              s   ˆ  d S(   Ng        (    (    (   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   .   R   c              s   ˆ  d S(   NR   (    (    (   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   /   R   (   t   getitem_typeR   R   t   getrefcountt   _viewt   assertEqualt   assertIsInstancet   bytest   assertRaisest
   IndexErrort	   TypeErrorR   (   R   t   tpt   itemt   bt   oldrefcount(    (   R   sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   check_getitem_with_type   s$    	c         C   s%   x |  j  D] } |  j | ƒ q
 Wd  S(   N(   R
   R   (   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_getitem3   s    c         C   so   xh |  j  D]] } | |  j ƒ } |  j | ƒ } |  j t | ƒ g  t t | ƒ ƒ D] } | | ^ qP ƒ q
 Wd  S(   N(   R
   R   R   R   t   listt   ranget   len(   R   R   R   R   t   i(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt	   test_iter7   s    c         C   sL   xE |  j  D]: } | |  j ƒ } |  j | ƒ } |  j | j ƒ  t ƒ q
 Wd  S(   N(   R
   R   R   R   t   __repr__t   str(   R   R   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt	   test_repr=   s    c            sº   |  j  s |  j d ƒ n  |  j  |  j ƒ } t j | ƒ } |  j | ƒ ‰  ‡  f d †  } |  j t | d ƒ |  j t | d ƒ |  j t | t d ƒ ƒ d  ‰  |  j
 t j | ƒ | ƒ d  S(   Ns   no read-only type to testc            s   |  ˆ  d <d  S(   Ni    (    (   t   value(   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   setitemI   s    R   iA   (   R   t   skipTestR   R   R   R   R   R   t
   memoryviewR   R   (   R   R   R   R*   (    (   R   sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_setitem_readonlyC   s    	c            s|  |  j  s |  j d ƒ n  |  j  ‰ |  j  |  j ƒ } t j | ƒ } |  j | ƒ ‰  ˆ d ƒ ˆ  d <|  j ˆ | d ƒ ˆ d ƒ ˆ  d d +|  j ˆ | d ƒ ˆ d	 ƒ ˆ  d d +|  j ˆ | d ƒ ˆ d
 ƒ ˆ  (|  j ˆ | d
 ƒ ˆ  d d !ˆ  d d +|  j ˆ | d ƒ ˆ d
 ƒ ˆ  (ˆ  d d !ˆ  d d +|  j ˆ | d ƒ ‡  ‡ f d †  } |  j t | d d ƒ |  j t | d d ƒ |  j t | t j	 d ƒ |  j t | t j	 d ƒ |  j t
 | d d ƒ |  j t
 | d d ƒ |  j t
 | d d ƒ |  j t | d d	 ƒ |  j t | d d ƒ |  j t | t d d ƒ d ƒ |  j t | t d d ƒ d ƒ d  ‰  |  j t j | ƒ | ƒ d  S(   Ns   no writable type to testt   0i    t   0bcdeft   12i   i   t   012defR   R   i   i   t   cdedeft   ababcfc            s   ˆ | ƒ ˆ  |  <d  S(   N(    (   t   keyR)   (   R   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR*   h   s    i   R   iùÿÿÿg        t   ab(   i    (   R	   R+   R   R   R   R   t   _check_contentsR   R   R   R   t
   ValueErrort   sliceR   R   (   R   R   R   R*   (    (   R   R   sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_setitem_writableQ   sB    		c      	   C   ss   xl |  j  D]a } | |  j ƒ } |  j | ƒ } |  j t ƒ � | d =Wd  QX|  j t ƒ � | d d 5Wd  QXq
 Wd  S(   Ni   i   (   R
   R   R   R   R   (   R   R   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_delitem|   s    c            s{   xt ˆ  j  D]i } ˆ  j | ˆ  j ƒ ƒ } | j ƒ  } d j ‡  f d †  d Dƒ ƒ } ˆ  j | | ƒ ˆ  j | t ƒ q
 Wd  S(   NR   c         3   s   |  ] } ˆ  j  | ƒ Vq d  S(   N(   R   (   t   .0t   c(   R   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pys	   <genexpr>‹   s    R   (   R
   R   R   t   tobytest   joinR   R   R   (   R   R   R   R   t   expected(    (   R   sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_tobytes…   s    c         C   sU   xN |  j  D]C } |  j | |  j ƒ ƒ } | j ƒ  } |  j | t t d ƒ ƒ q
 Wd  S(   NR   (   R
   R   R   t   tolistR   t   mapt   ord(   R   R   R   t   l(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_tolist�   s    c         C   s‚  x{|  j  D]p} |  j | |  j ƒ ƒ } x§ |  j  D]œ } |  j | | d ƒ k ƒ |  j | | d ƒ k ƒ |  j | | d ƒ k ƒ |  j | | d ƒ k ƒ |  j | | d ƒ k ƒ |  j | | d ƒ k ƒ q2 W|  j | | k ƒ |  j | | k ƒ |  j | d d !| k ƒ |  j | d d !| k ƒ |  j | d k ƒ |  j | d k ƒ |  j d | k ƒ |  j d | k ƒ q
 Wd  S(   NR   t   abcdet   abcde1i    i   i   u   abcdef(   R
   R   R   t
   assertTruet   assertFalse(   R   R   R   t   tp_comp(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_compare•   s"    c         C   sÃ   |  j  | |  j ƒ ƒ } |  j | j |  j ƒ |  j | j t ƒ |  j | j |  j ƒ |  j | j d ƒ |  j | j d ƒ |  j t	 | ƒ d ƒ |  j | j
 |  j f ƒ |  j | j d  ƒ | S(   Ni   i   (   i   (   R   R   R   t   formatR   R'   t   itemsizet   ndimt   shapeR#   t   stridest
   suboffsetsR   (   R   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   check_attributes_with_type¯   s    c         C   sB   |  j  s |  j d ƒ n  |  j |  j  ƒ } |  j | j t ƒ d  S(   Ns   no read-only type to test(   R   R+   RR   R   t   readonlyt   True(   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_attributes_readonly»   s    	c         C   sB   |  j  s |  j d ƒ n  |  j |  j  ƒ } |  j | j t ƒ d  S(   Ns   no writable type to test(   R	   R+   RR   R   RS   t   False(   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_attributes_writableÁ   s    	c         C   sÕ   xÎ |  j  D]Ã } t | t ƒ s% q
 n  d | f d „  ƒ  Y} d d d „  ƒ  Y} | | d ƒ ƒ } |  j | ƒ } | ƒ  } | | _ | | _ t j | ƒ } d  } } } t	 j
 ƒ  |  j | ƒ  d  k | ƒ  ƒ q
 Wd  S(   Nt   MySourcec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyRX   Ü   s   t   MyObjectc           B   s   e  Z RS(    (   RY   RZ   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR[   Þ   s   t   abc(    (   R
   t
   isinstancet   typeR   R   t   ot   weakreft   refR   t   gct   collectRH   (   R   R   RX   R[   R   R   R_   t   wr(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_gcÖ   s    			
c         C   sl   |  j  } | d  k r% |  j d ƒ n  | |  j ƒ } |  j | ƒ } t j d ƒ } |  j t | j	 | ƒ d  S(   Ns   no read-only type to testt   ZZZZ(
   R   R   R+   R   R   t   iot   BytesIOR   R   t   readinto(   R   R   R   R   R$   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_writable_readonlyí   s    	(   RY   RZ   R   t   propertyR   R
   R   R    R%   R(   R-   R9   R:   R@   RE   RK   RR   RU   RW   Re   Rj   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR      s$   						+			
						t   BaseBytesMemoryTestsc           B   s&   e  Z e Z e Z e Z d  Z d Z RS(   i   t   B(	   RY   RZ   R   R   t	   bytearrayR	   R   RM   RL   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyRl   ü   s
   t   BaseMemoryviewTestsc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s
   t  | ƒ S(   N(   R,   (   R   t   obj(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR     s    c         C   s   |  j  | | | ƒ ƒ d  S(   N(   R   (   R   R   Rp   t   contents(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR6     s    (   RY   RZ   R   R6   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyRo     s   	t   BaseMemorySliceTestsc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   t   XabcdefYc         C   s   t  | ƒ } | d d !S(   Ni   i   (   R,   (   R   Rp   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   #  s    c         C   s!   |  j  | d d !| | ƒ ƒ d  S(   Ni   i   (   R   (   R   R   Rp   Rq   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR6   '  s    c         C   s`   xY |  j  D]N } t | |  j ƒ ƒ } t j | ƒ } | d d !|  j t j | ƒ | ƒ q
 Wd  S(   Ni   i   (   R
   R,   R   R   R   R   (   R   R   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt	   test_refs*  s
    (   RY   RZ   R   R   R6   Rt   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyRr      s   		t   BaseMemorySliceSliceTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   Rs   c         C   s   t  | ƒ } | d  d S(   Ni   i   (   R,   (   R   Rp   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR   4  s    c         C   s!   |  j  | d d !| | ƒ ƒ d  S(   Ni   i   (   R   (   R   R   Rp   Rq   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR6   8  s    (   RY   RZ   R   R   R6   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyRu   1  s   	t   BytesMemoryviewTestc           B   s   e  Z d  „  Z RS(   c         C   s¥   xž |  j  D]“ } | |  j ƒ } |  j t | ƒ ƒ |  j t d | ƒ ƒ |  j t t ƒ |  j t t | | ƒ |  j t t d | ƒ|  j t t | d t ƒq
 Wd  S(   Nt   objectt   argument(   R
   R   RH   R,   R   R   RT   (   R   R   t   ob(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_constructorA  s    (   RY   RZ   Rz   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyRv   >  s   t   BytesMemorySliceTestc           B   s   e  Z RS(    (   RY   RZ   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR{   W  s   t   BytesMemorySliceSliceTestc           B   s   e  Z RS(    (   RY   RZ   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR|   _  s   t	   OtherTestc           B   s#   e  Z d  „  Z e j d „  ƒ Z RS(   c         C   sY   t  d ƒ } |  j t ƒ �8 t j ƒ  �% t j d d t ƒ t j | ƒ Wd  QXWd  QXd  S(   NR\   t   ignores   .*memoryview(   R,   R   R   t   warningst   catch_warningst   filterwarningst   DeprecationWarningt   copy(   R   R   (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt	   test_copyi  s
     c         C   sy   t  d ƒ } x: t d ƒ D], } |  j t ƒ � t j | | ƒ Wd  QXq Wt j d t f ƒ � t j | d ƒ Wd  QXd  S(   NR\   i   s   .*memoryview(	   R,   R"   R   R   t   picklet   dumpsR    t   check_py3k_warningsR‚   (   R   R   t   proto(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   test_pickleo  s    (   RY   RZ   R„   R    t   cpython_onlyR‰   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyR}   h  s   	c           C   s   t  j t ƒ d  S(   N(   R    t   run_unittestRY   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt	   test_main{  s    t   __main__(    (    (    (    (   t   __doc__t   unittestR   Rb   R`   t   arrayt   testR    Rg   Rƒ   R…   R   R   Rl   Ro   Rr   Ru   t   TestCaseRv   R{   R|   R}   RŒ   RY   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_memoryview.pyt   <module>   s2   ê				