๓
j๚\c           @@ sพ  d  d l  m 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	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z m Z d  d l m Z d  d	 l m Z d
 e f d     YZ e j e j d  d e f d     Y Z e j e j d  d e f d     Y Z e j e j d  d e f d     Y Z e j e j d  d e f d     Y Z e j e j d  d e f d     Y Z d e j e f d     YZ d e f d     YZ d e f d     YZ  d e j e f d     YZ! d e j e f d      YZ" d! e f d"     YZ# d# e f d$     YZ$ d%   Z% e& d& k rบd  d l' Z' e j( e' j)  e j*   e j+ d' d(  n  d S()   i    (   t   print_function(   t   absolute_importN(   t   FlavorWarning(   t   common(   t   allequal(   t   unittestt   test_filename(   t   PyTablesTestCase(   t   ranget   BackCompatTablesTestCasec           B@ s   e  Z d    Z RS(   c         C@ s  t  j r1 t d d d  t d |  j j  n  t j   3 t j d d t t	 j
 t |  j  d  } Wd QXz | j d	  } g  | D] } | d
 ^ q } t  j rๆ t d | j d | j  t d |  t d t |   n  |  j t |  d  Wd | j   Xd S(   s9   Checking backward compatibility of old formats of tables.s   
s   -=i   s   Running %s.test01_readTable...t   ignoret   categoryt   rNs   /tuple0t   var2s   Nrows int   :s   Last record in table ==>s$   Total selected records in table ==> id   (   R   t   verboset   printt	   __class__t   __name__t   warningst   catch_warningst   filterwarningst   UserWarningt   tablest	   open_fileR   t   h5fnamet   get_nodet   _v_pathnamet   nrowst   lent   assertEqualt   close(   t   selft   h5filet   tablet   rect   result(    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   test01_readTable   s    	!	(   R   t
   __module__R%   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR	      s   s   lzo not availablet   Table2_1LZOc           B@ s   e  Z d  Z RS(   s   Table2_1_lzo_nrv2e_shuffle.h5(   R   R&   R   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR'   2   s   t   Tables_LZO1c           B@ s   e  Z d  Z RS(   s   Tables_lzo1.h5(   R   R&   R   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR(   8   s   t   Tables_LZO1_shufflec           B@ s   e  Z d  Z RS(   s   Tables_lzo1_shuffle.h5(   R   R&   R   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR)   =   s   t   Tables_LZO2c           B@ s   e  Z d  Z RS(   s   Tables_lzo2.h5(   R   R&   R   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR*   C   s   t   Tables_LZO2_shufflec           B@ s   e  Z d  Z RS(   s   Tables_lzo2_shuffle.h5(   R   R&   R   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR+   H   s   t   BackCompatAttrsTestCasec           B@ s    e  Z d  Z d   Z d   Z RS(   s   zerodim-attrs-%s.h5c         C@ s0   t  |  j |  j  |  _ t t |   j   d  S(   N(   R   t   FILENAMEt   formatR   t   superR,   t   setUp(   R    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR0   R   s    c         C@ s:  t  j r1 t d d d  t d |  j j  n  |  j j d  } t j d d d } t j d g d d } |  j	 d	 k rะ |  j
 t | j j |   |  j
 t | j j |   |  j | j j d  nf |  j	 d
 k r6|  j
 t | j j |   |  j
 t | j j |   |  j
 t | j j |   n  d S(   s>   Checking backward compatibility of old formats for attributes.s   
s   -=i   s   Running %s.test01_readAttr...s   /ai   t   dtypet   int32s   1.3s   1.4N(   R   R   R   R   R   R!   R   t   numpyt   arrayR.   t
   assertTrueR   t   attrst   arrdim1t	   arrscalarR   t   pythonscalar(   R    t   at   scalart   vector(    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   test01_readAttrV   s    	(   R   R&   R-   R0   R=   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR,   O   s   	t	   Attrs_1_3c           B@ s   e  Z d  Z RS(   s   1.3(   R   R&   R.   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR>   k   s   t	   Attrs_1_4c           B@ s   e  Z d  Z RS(   s   1.4(   R   R&   R.   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR?   o   s   t   VLArrayTestCasec           B@ s   e  Z e d   Z d   Z RS(   s   flavored_vlarrays-format1.6.h5c         C@ se   |  j  j j } |  j | j d  |  j  j j } |  j | j d  |  j | d d d d g  d S(   s<   Checking backward compatibility with old flavors of VLArray.t   numerict   pythoni   t   5t   6t   77N(   R!   t   roott   vlarray1R   t   flavort   vlarray2(   R    RG   RI   (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   test01_backCompatv   s
    (   R   R&   R   R   RJ   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyR@   s   s   t   TimeTestCasec           B@ s&   e  Z e d   Z d   Z d   Z RS(   s   time-table-vlarray-1_x.h5c         C@ s&   |  j  j j } |  j | j d  d S(   s?   Checking backward compatibility with old TimeXX types (tables).t   littleN(   R!   RF   R"   R   t	   byteorder(   R    R"   (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   test00_table   s    c         C@ sH   |  j  j j } |  j | j d  |  j  j j } |  j | j d  d S(   sA   Checking backward compatibility with old TimeXX types (vlarrays).RL   N(   R!   RF   t   vlarray4R   RM   (   R    RO   t   vlarray8(    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   test01_vlarray   s    (   R   R&   R   R   RN   RQ   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyRK      s   	t   OldFlavorsTestCase01c           B@ s    e  Z e Z d    Z d   Z RS(   c         C@ sพ   t  d  } t j |   } |  j | j j j d  |  j | j j j d  |  j | j j j d  |  j | j j	 j d  |  j | j j
 j d  |  j | j j j d  Wd QXd S(   s3   Checking opening of (X)Array (old 'numeric' flavor)s   oldflavor_numeric.h5RA   RB   N(   R   R   R   R   RF   t   array1RH   t   array2t   carray1t   carray2RG   RI   (   R    R   R!   (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   test01_open   s    c      	   C@ sฑ  t  d  } t j d  } t j | |  zqt j | d  Y} |  j t | j	 j
 j d d  | j	 j j d d  | j	 j j d d  | j	 j j d d  | j	 j j d d	  | j	 j j d d
  |  j r๕ | j   t j |  } n
 | j   |  j | j	 j j d  |  j | j	 j j d  |  j | j	 j j d  |  j | j	 j j d  |  j | j	 j j d  |  j | j	 j j d  Wd QXWd t j |  Xd S(   s2   Checking (X)Array.copy() method ('numetic' flavor)s   oldflavor_numeric.h5s   .h5s   r+t   /t
   array1copyt
   array2copyt   carray1copyt   carray2copyt   vlarray1copyt   vlarray2copyRA   RB   N(   R   t   tempfilet   mktempt   shutilt   copyR   R   t   assertWarnsR   RF   RS   RT   RU   RV   RG   RI   R   t   flushR   RY   RH   RZ   R[   R\   R]   R^   t   ost   remove(   R    t   srcfilet   tmpfileR!   (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   test02_copyซ   s.    		

#(   R   R&   t   FalseR   RW   Ri   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyRR      s   	t   OldFlavorsTestCase02c           B@ s   e  Z e Z RS(    (   R   R&   t   TrueR   (    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyRk   ฮ   s   c          C@ s๓   t  j   }  d } xฺ t |  D]ฬ } |  j t  j t   |  j t  j t   |  j t  j t   |  j t  j t   |  j t  j t	   |  j t  j t
   |  j t  j t   |  j t  j t   |  j t  j t   q W|  S(   Ni   (   R   t	   TestSuiteR   t   addTestt	   makeSuiteR@   RK   RR   Rk   R'   R(   R)   R*   R+   (   t   theSuitet   nitert   n(    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   suiteา   s    t   __main__t   defaultTestRs   (,   t
   __future__R    R   Re   Ra   R_   R   R3   R   t   tables.exceptionsR   t   tables.testsR   t   tables.tests.commonR   R   R   R   t   TestCaset	   six.movesR   R	   t   skipIft	   lzo_availR'   R(   R)   R*   R+   t   TestFileMixinR,   R>   R?   R@   RK   RR   Rk   Rs   R   t   syst
   parse_argvt   argvt   print_versionst   main(    (    (    s;   lib/python2.7/site-packages/tables/tests/test_backcompat.pyt   <module>   sJ   6	
