
[c           @   s   d  d l  m Z d d l m Z d d l m Z m Z m Z m	 Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d Z e j e d e j Z d   Z d S(   i   (   t	   cStringIOi   (   t   asciii   (   t   assert_equalt   assert_almost_equalt   setup_functiont   teardown_functionc         C   s   t  |  j   | j    d  S(   N(   R   t
   splitlines(   t   arg1t   arg2(    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   assert_equal_splitlines
   s    c          C   s   d }  t  j d t  j  } | j |   } t | j d d g  t | d d d  t | d d d  t | d d d	  d
 S(   s   Normal SimpleRST Tables   
# comment (with blank line above)
======= =========
   Col1      Col2
======= =========
   1.2    "hello"
   2.4  's worlds
======= =========
t   Readert   Col1t   Col2i   i    g333333@s   "hello"s	   's worldsN(   R   t
   get_readert   RSTt   readR   t   colnamesR   (   t   tablet   readert   dat(    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   test_read_normal   s    
c          C   s_   d }  t  j d t  j d d
  } | j |   } t | j d d g  t | d d d  d	 S(   s1   Normal SimpleRST Table with provided column namess   
# comment (with blank line above)
======= =========
   Col1      Col2
======= =========
   1.2    "hello"
   2.4  's worlds
======= =========
R
   t   namest   name1t   name2i   i    g333333@N(   R   R   (   R   R   R   R   R   R   R   (   R   R   R   (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   test_read_normal_names!   s    
	c          C   sz   d }  t  j d t  j d d d d  } | j |   } t | j d d g  t | d d	 d
  t | d	 d d  d S(   s1   Normal SimpleRST Table with provided column namess   
# comment (with blank line above)
=======  ========== ======
   Col1     Col2      Col3
=======  ========== ======
   1.2     "hello"       3
   2.4    's worlds      7
=======  ========== ======
R
   R   R   R   t   name3t   include_namesi   i    g333333@i   N(   R   R   R   (   R   R   (   R   R   R   R   R   R   R   (   R   R   R   (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   test_read_normal_names_include3   s    
	c          C   s\   d }  t  j d t  j d d
  } | j |   } t | j d g  t | d d d  d	 S(   s4   Nice, typical SimpleRST table with col name excludedso   
======= ==========
  Col1     Col2
======= ==========
  1.2     "hello"
  2.4    's worlds
======= ==========
R
   t   exclude_namesR   R   i   i    s	   's worldsN(   R   (   R   R   R   R   R   R   (   R   R   R   (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   test_read_normal_excludeG   s    		c          C   sX   d }  t  j d t  j  } | j |   } t | d d d  t | d d d  d S(	   s3   The right hand column should be allowed to overflows   
# comment (with blank line above)
===== ===== ====
 Col1  Col2 Col3
===== ===== ====
 1.2    2    Hello
 2.4     4   Worlds
===== ===== ====
R
   i    i   t   Helloi   t   WorldsN(   R   R   R   R   R   (   R   R   R   (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt    test_read_unbounded_right_columnX   s
    
c          C   sB   d }  t  j d t  j  } | j |   } t | j d d  d S(   s3   The right hand column should be allowed to overflows   
# comment (with blank line above)
===== ===== ====
 Col1  Col2 Col3Long
===== ===== ====
 1.2    2    Hello
 2.4     4   Worlds
===== ===== ====
R
   it   Col3LongN(   R   R   R   R   R   R   (   R   R   R   (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt'   test_read_unbounded_right_column_headeri   s    
c          C   sq   d }  t  j d t  j  } | j |   } t | j d d d g  t | d d d  t | d	 d d	  d
 S(   s9   We should be able to read right indented tables correctlys   
# comment (with blank line above)
   ==== ==== ====
   Col1 Col2 Col3
   ==== ==== ====
    3    3.4  foo
    1    4.5  bar
   ==== ==== ====
R
   R   R   t   Col3i    i   t   fooi   N(   R   R   R   R   R   R   (   R   R   R   (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   test_read_right_indented_tabley   s    
c          C   s   d }  t  |   d k s t  t j d t j  } | j |   } t | j d d d g  t | d d d	  t | d
 d d
  d S(   s>    Trailing spaces in the row definition column shouldn't matters   
# comment (with blank line above)
   ==== ==== ====    
   Col1 Col2 Col3
   ==== ==== ====  
    3    3.4  foo
    1    4.5  bar
   ==== ==== ====  
i   R
   R   R   R#   i    i   R$   i   N(   t   lent   AssertionErrorR   R   R   R   R   R   (   R   R   R   (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt&   test_trailing_spaces_in_row_definition   s    s   ====== =========== ============ ===========
  Col1    Col2        Col3        Col4
====== =========== ============ ===========
  1.2    "hello"      1           a
  2.4   's worlds          2           2
====== =========== ============ ===========
R
   c          C   s9   t    }  t j t |  d t j t |  j   d  d S(   s)   Write a table as a normal SimpleRST Tablet   Writers   ==== ========= ==== ====
Col1      Col2 Col3 Col4
==== ========= ==== ====
 1.2   "hello"    1    a
 2.4 's worlds    2    2
==== ========= ==== ====
N(   t   StringIOR   t   writeR   R   R	   t   getvalue(   t   out(    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   test_write_normal   s    	N(   t   extern.six.movesR    R*   t    R   t   commonR   R   R   R   R	   R   R   R   R   R    R"   R%   R(   R   R   R   R   R.   (    (    (    s>   lib/python2.7/site-packages/astropy/io/ascii/tests/test_rst.pyt   <module>   s   "									