U
    e»{j  ã                   @   s�   d dl mZ d dlmZ ddlmZmZ dd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdZejeejd�Zdd„ ZdS )é    )ÚStringIO)Úasciié   )Úassert_almost_equalÚassert_equalc                 C   s   t |  ¡ | ¡ ƒ d S )N)r   Ú
splitlines)Zarg1Zarg2© r   ú^/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/io/ascii/tests/test_rst.pyÚassert_equal_splitlines
   s    r
   c                  C   sf   d} t jt jd�}| | ¡}t|jddgƒ t|d d dƒ t|d d dƒ t|d d d	ƒ d
S )zNormal SimpleRST Tableú�
# comment (with blank line above)
======= =========
   Col1      Col2
======= =========
   1.2    "hello"
   2.4  's worlds
======= =========
©ÚReaderÚCol1ÚCol2r   r   ç333333@z"hello"ú	's worldsN©r   Ú
get_readerÚRSTÚreadr   Úcolnamesr   ©ÚtableÚreaderÚdatr   r   r	   Útest_read_normal   s    	
r   c                  C   sD   d} t jt jdd�}| | ¡}t|jddgƒ t|d d dƒ d	S )
ú1Normal SimpleRST Table with provided column namesr   )Úname1Úname2)r   Únamesr   r   r   r   r   Nr   r   r   r   r	   Útest_read_normal_names!   s
    	
r    c                  C   sX   d} t jt jddd�}| | ¡}t|jddgƒ t|d d d	ƒ t|d d d
ƒ dS )r   zÅ
# comment (with blank line above)
=======  ========== ======
   Col1     Col2      Col3
=======  ========== ======
   1.2     "hello"       3
   2.4    's worlds      7
=======  ========== ======
)r   r   Úname3)r   r!   )r   r   Zinclude_namesr   r!   r   r   r   é   Nr   r   r   r   r	   Útest_read_normal_names_include2   s    	ý
r#   c                  C   sB   d} t jt jdd�}| | ¡}t|jdgƒ t|d d dƒ dS )	z4Nice, typical SimpleRST table with col name excludedzo
======= ==========
  Col1     Col2
======= ==========
  1.2     "hello"
  2.4    's worlds
======= ==========
)r   )r   Zexclude_namesr   r   r   r   N©r   r   r   r   r   r   r   r   r   r	   Útest_read_normal_excludeH   s
    
r%   c                  C   sD   d} t jt jd�}| | ¡}t|d d dƒ t|d d dƒ dS )	ú3The right hand column should be allowed to overflowzŽ
# comment (with blank line above)
===== ===== ====
 Col1  Col2 Col3
===== ===== ====
 1.2    2    Hello
 2.4     4   Worlds
===== ===== ====
r   r   é   ZHellor   ZWorldsN)r   r   r   r   r   r   r   r   r	   Ú test_read_unbounded_right_columnX   s
    	
r(   c                  C   s0   d} t jt jd�}| | ¡}t|jd dƒ dS )r&   z’
# comment (with blank line above)
===== ===== ====
 Col1  Col2 Col3Long
===== ===== ====
 1.2    2    Hello
 2.4     4   Worlds
===== ===== ====
r   éÿÿÿÿZCol3LongNr$   r   r   r   r	   Ú'test_read_unbounded_right_column_headeri   s    	
r*   c                  C   sV   d} t jt jd�}| | ¡}t|jdddgƒ t|d d dƒ t|d	 d d	ƒ d
S )z9We should be able to read right indented tables correctlyz�
# comment (with blank line above)
   ==== ==== ====
   Col1 Col2 Col3
   ==== ==== ====
    3    3.4  foo
    1    4.5  bar
   ==== ==== ====
r   r   r   ÚCol3r   r'   Úfoor   Nr$   r   r   r   r	   Útest_read_right_indented_tabley   s    	
r-   c                  C   sf   d} t | ƒdkst‚tjtjd�}| | ¡}t|jdddgƒ t|d d d	ƒ t|d
 d d
ƒ dS )z=Trailing spaces in the row definition column shouldn't matterz—
# comment (with blank line above)
   ==== ==== ====    
   Col1 Col2 Col3
   ==== ==== ====  
    3    3.4  foo
    1    4.5  bar
   ==== ==== ====  
é—   r   r   r   r+   r   r'   r,   r   N)ÚlenÚAssertionErrorr   r   r   r   r   r   r   r   r   r	   Ú&test_trailing_spaces_in_row_definition‹   s    ÿ
r1   zø====== =========== ============ ===========
  Col1    Col2        Col3        Col4
====== =========== ============ ===========
  1.2    "hello"      1           a
  2.4   's worlds          2           2
====== =========== ============ ===========
r   c                  C   s*   t ƒ } tjt| tjd� t|  ¡ dƒ dS )z)Write a table as a normal SimpleRST Table)ÚWriterz–==== ========= ==== ====
Col1      Col2 Col3 Col4
==== ========= ==== ====
 1.2   "hello"    1    a
 2.4 's worlds    2    2
==== ========= ==== ====
N)r   r   Úwriter   r   r
   Úgetvalue)Úoutr   r   r	   Útest_write_normal­   s    þr6   N)Úior   Z
astropy.ior   Úcommonr   r   r
   r   r    r#   r%   r(   r*   r-   r1   r   r   r   r   r6   r   r   r   r	   Ú<module>   s   