a
    ߙfb                     @   sF  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 dlmZ ejd	ejd
ddZejdejd
ddZe jdG dd dZdd Ze jdG dd dZe jdG dd dZG dd dZdd Zdd Z dd  Z!d!d" Z"d#d$ Z#d%d& Z$d'd( Z%G d)d* d*Z&dS )+    N)StringIO)table)ascii)TableQTable)simple_table)units)consolei  Zdtyped               
table_typec                   @   s   e Zd Zdd Zdd ZdS )
TestMultiDc                 C   s"  t jddgddggt jdt jddgdd	ggt jdt jd
dgddggt jdg}||}| }|g dksrJ |jdd}|dt| dddddgksJ tjj}|jrdnd}|	 
 d|j d| ddt| d| ddddddgksJ ||g}| }|g dksJ d S )!z*Test printing with multidimensional column      
   r   r
   r         (      r   2   <   )zcol0 [2] col1 [2] col2 [2]z-------- -------- --------z  1 .. 2   3 .. 4   5 .. 6z10 .. 20 30 .. 40 50 .. 60Thtml<table id="table">zK<thead><tr><th>col0 [2]</th><th>col1 [2]</th><th>col2 [2]</th></tr></thead>z6<tr><td>1 .. 2</td><td>3 .. 4</td><td>5 .. 6</td></tr>z<<tr><td>10 .. 20</td><td>30 .. 40</td><td>50 .. 60</td></tr></table>masked=True  <div><i> length=2</i>	" class="B<thead><tr><th>int64</th><th>int64</th><th>int64</th></tr></thead></table></div>)z
col0 [2,2]z
----------z
   1 .. 20z
   3 .. 40z
   5 .. 60Nnparrayint64pformatidr   confdefault_notebook_table_classmasked_repr_html_
splitlines__name__selfr   arrtlinesnbclassr0    r:   >lib/python3.9/site-packages/astropy/table/tests/test_pprint.pytest_multidim   sR    





	
zTestMultiD.test_multidimc                 C   s  t jdgdggt jdt jdgdggt jdt jdgdggt jdg}||}| }|g dksfJ |jd	d
}|dt| dddddgksJ tjj}|jrdnd}|	 
 d|j d| ddt| d| ddddddgksJ ||g}| }|g dksJ dS )z1Test printing with 'fake' multidimensional column)r   )r   r
   )r   )r   )r   )r   )z col0 [1,1] col1 [1,1] col2 [1,1]z ---------- ---------- ----------z          1          3          5z         10         30         50Tr   r   r   zQ<thead><tr><th>col0 [1,1]</th><th>col1 [1,1]</th><th>col2 [1,1]</th></tr></thead>z'<tr><td>1</td><td>3</td><td>5</td></tr>z*<tr><td>10</td><td>30</td><td>50</td></tr>r   r    r!   r"   r#   r$   r%   r&   r'   )zcol0 [2,1,1]z------------z     1 .. 10z     3 .. 30z     5 .. 50Nr(   r4   r:   r:   r;   test_fake_multidim@   sP    



zTestMultiD.test_fake_multidimN)r3   
__module____qualname__r<   r=   r:   r:   r:   r;   r      s   )r   c               	   C   sN   t dg} t jj}|   ddt|  d| ddddd	d
dgksJJ d S )N)z!<script>alert("gotcha");</script>r   r   z<div><i>Table length=3</i>r   r%   r   z%<thead><tr><th>col0</th></tr></thead>z&<thead><tr><th>str33</th></tr></thead>zI<tr><td>&lt;script&gt;alert(&quot;gotcha&quot;);&lt;/script&gt;</td></tr>z<tr><td>2</td></tr>z<tr><td>3</td></tr>r'   )r   r   r.   r/   r1   r2   r-   )r7   r9   r:   r:   r;   test_html_escapingi   s    
r@   c                   @   s   e Z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d Zdd Zdd Zdd Zdd Zejdd ZdS )
TestPprintc                 C   sH   |t | _d| jd _d| jd _d| jd _d| jd _|t| _d S )Necol0z.6fZcol1zkm**2z
kg s m**-2Zcol19)BIG_WIDE_ARRtbformatZunit	SMALL_ARRts)r5   r   r:   r:   r;   _setupz   s    
zTestPprint._setupc                 C   sZ   | }|  }|dgksJ t|}|jr.dnd}| d|j d| ddgksVJ d S )Nz<No columns>r    r!   <r#   z	length=0>)r,   reprr0   r2   r3   )r5   r   r7   r8   cr0   r:   r:   r;   test_empty_table   s    zTestPprint.test_empty_tablec                 C   s   |  | tjdtjddd}|| }t \}}t||ksJJ |dd D ]&}|d t|  k rv|ksVn J qVdS )zTry getting screen size but fail to defaults because testing doesn't
        have access to screen (fcntl.ioctl fails).
        i  r
   r   r   Nr   )	rI   r)   arangefloat64reshaper,   r	   terminal_sizelen)r5   r   r6   r8   Znlineswidthliner:   r:   r;   test_format0   s    
zTestPprint.test_format0c                 C   s.   |  | | jjddd}|g dks*J dS )z2Basic test of formatting, unit header row included   r   	max_lines	max_widthz&    col0         col1    ...   col19  &    km2                  ... kg s / m2&------------ ----------- ... ---------&0.000000e+00    1.000000 ...      19.0&         ...         ... ...       ...&1.960000e+03 1961.000000 ...    1979.0&1.980000e+03 1981.000000 ...    1999.0Length = 100 rowsNrI   rE   r,   r5   r   r8   r:   r:   r;   test_format1   s    
zTestPprint.test_format1c                 C   s0   |  | | jjdddd}|g dks,J dS )z2Basic test of formatting, unit header row excludedrW   r   FrY   rZ   	show_unit)z#    col0         col1    ... col19 z#------------ ----------- ... ------z#0.000000e+00    1.000000 ...   19.0z#2.000000e+01   21.000000 ...   39.0z#         ...         ... ...    ...z#1.960000e+03 1961.000000 ... 1979.0z#1.980000e+03 1981.000000 ... 1999.0rb   Nrc   rd   r:   r:   r;   test_format2   s    
zTestPprint.test_format2c                 C   s0   |  | | jjdddd}|g dks,J dS )zInclude the unit header rowrW   r   Trf   r[   Nrc   rd   r:   r:   r;   test_format3   s    
zTestPprint.test_format3c                 C   s0   |  | | jjdddd}|g dks,J dS )z"Do not include the name header rowrW   r   F)rY   rZ   Z	show_name)r\   r]   r^   z&2.000000e+01   21.000000 ...      39.0r_   r`   ra   rb   Nrc   rd   r:   r:   r;   test_format4   s    
zTestPprint.test_format4c                 C   s.   |  | | jjddd}|g dks*J dS )zBasic table printrN   rX   zcol0 col1 col2z---- ---- ----z   0    1    2z   3    4    5z   6    7    8z   9   10   11z  12   13   14z  15   16   17NrI   rH   r,   rd   r:   r:   r;   test_noclip   s    
zTestPprint.test_noclipc                 C   s.   |  | | jjddd}|g dks*J dS )z(max lines below hard limit of 8
        r   rN   rX   rk   Nrl   rd   r:   r:   r;   
test_clip1   s    
zTestPprint.test_clip1c                 C   s2   |  | | jjddddd}|g dks.J dS )zAmax lines below hard limit of 8 and output longer than 8
        r   rN   T)rY   rZ   rg   Z
show_dtype)z col0  col1  col2z                 zint64 int64 int64z----- ----- -----z    0     1     2z  ...   ...   ...z   15    16    17Length = 6 rowsNrl   rd   r:   r:   r;   
test_clip2   s    
zTestPprint.test_clip2c                 C   s0   |  | | jjdddd}|g dks,J dS )zUMax lines below hard limit of 8 and max width below hard limit
        of 10
        r   r   Trf   )zcol0 ...z     ...z---- ...z   0 ...z ... ...z  12 ...z  15 ...ro   Nrl   rd   r:   r:   r;   
test_clip3   s    
zTestPprint.test_clip3c                 C   sD   |  | dD ]0}| jj|dd}t|tdtd|ksJ qdS )zTest a range of max_lines)r   r   r   r   r      rW   r   e   f   g   h      F)rY   rg   rW   rt   N)rI   rE   r,   rS   maxmin)r5   r   rY   r8   r:   r:   r;   
test_clip4  s    
zTestPprint.test_clip4c                 C   s2   |  | | j }t|tjd d ks.J dS z)Test that all rows are printed by defaultr   r   N)rI   rE   pformat_allrS   rD   shaperd   r:   r:   r;   test_pformat_all  s    

zTestPprint.test_pformat_allc                 C   s>   |  | | j  | \}}t|tjd d ks:J dS r{   )rI   rE   Z
pprint_allZ
readouterrrS   rD   r}   )r5   r   Zcapsysouterrr:   r:   r;   test_pprint_all  s    

zTestPprint.test_pprint_allN)r3   r>   r?   rI   rM   rV   re   rh   ri   rj   rm   rn   rp   rq   rz   r~   pytestZfixturer   r:   r:   r:   r;   rA   w   s   		rA   c                   @   sL   e Z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S )
TestFormatc                 C   s  |ddgddggdd}t |d dks,J d	|d _t |d d
ksJJ d|d _t |d dkshJ d|d _t |d dksJ d|d _t |d dksJ d|d _t |d dksJ tt d|d _W d    n1 s0    Y  |d jdks
J d S )Nr   r   r   r   abnamesr   z a 
---
  1
  25.2f  a  
-----
 1.00
 2.00	{ %4.2f }z#   a    
--------
{ 1.00 }
{ 2.00 }%{0:}z a 
---
 %1
 %2	 {0:05d} z   a   
-------
 00001 
 00002 
%4.2f {0:}z   a   
-------
%4.2f 1
%4.2f 2fail)strrF   r   raises
ValueErrorr5   r   r7   r:   r:   r;   test_column_format   s    




(zTestFormat.test_column_formatc                 C   s   ddl m} |ddr |tdgdgd}d|d _t|d  g d	ksVJ d
|d _t|d  g dks|J W d    n1 s0    Y  d S )Nr   r.   rY   rW   r   r   r   r   ) a ---z %0 %1...%18z%19Length = 20 rowsr   )	    a    	---------z	 { 0.00 }	 { 1.00 }	      ...	{ 18.00 }z	{ 19.00 }r   )astropyr.   set_tempr)   rO   rF   r   r2   )r5   r   r.   r7   r:   r:   r;   !test_column_format_with_threshold>  s    

z,TestFormat.test_column_format_with_thresholdc                 C   sR   |ddgddggdd}dd |d	 _ t|d	 d
ks:J t|d	 d
ksNJ d S )N      ?       @r   r   r   r   c                 S   s   t | d S N      @r   xr:   r:   r;   <lambda>]      z4TestFormat.test_column_format_func.<locals>.<lambda>r    a 
---
3.0
6.0rF   r   r   r:   r:   r;   test_column_format_funcU  s    z"TestFormat.test_column_format_funcc                 C   s^   |ddgddggdd}G dd d}| |d	 _ t|d	 d
ksFJ t|d	 d
ksZJ d S )Nr   r   r   r   r   r   c                   @   s   e Zd Zdd ZdS )z6TestFormat.test_column_format_callable.<locals>.formatc                 S   s   t |d S r   r   r5   r   r:   r:   r;   __call__j  s    z?TestFormat.test_column_format_callable.<locals>.format.__call__Nr3   r>   r?   r   r:   r:   r:   r;   rF   i  s   rF   r   r   r   )r5   r   r7   rF   r:   r:   r;   test_column_format_callablea  s
    z&TestFormat.test_column_format_callablec                 C   sX   |ddgddggdd}dd }t t ||d	 _W d    n1 sJ0    Y  d S )
Nr   r   r   r   r   r   c                 S   s   d S Nr:   r   r:   r:   r;   funct  s    zBTestFormat.test_column_format_func_wrong_number_args.<locals>.funcr   r   r   r   rF   )r5   r   r7   r   r:   r:   r;   )test_column_format_func_wrong_number_argsp  s    z4TestFormat.test_column_format_func_wrong_number_argsc                 C   sd   t ddgddggg}||dgd}dd |d _d	}t|d |ksLJ t|d |ks`J d S )
Nr   r   r   r   r   r   c                 S   s   t | d S r   r   r   r:   r:   r;   r     r   z;TestFormat.test_column_format_func_multiD.<locals>.<lambda>z3   a [2]    
------------
  3.0 .. 6.0
30.0 .. 60.0)r)   r*   rF   r   )r5   r   r6   r7   outstrr:   r:   r;   test_column_format_func_multiDz  s    
z)TestFormat.test_column_format_func_multiDc                 C   sT   |ddgddggdd}t t dd |d	 _W d    n1 sF0    Y  d S )
Nr   r   r   r   r   r   c                 S   s   | d S )Nr   r:   r   r:   r:   r;   r     r   z<TestFormat.test_column_format_func_not_str.<locals>.<lambda>r   r   r   r:   r:   r;   test_column_format_func_not_str  s    z*TestFormat.test_column_format_func_not_strc                 C   s   |dgdgdgdggdd}d|d _ d	|d
 _ d|d _ d|d _ t|d dksXJ t|d
 dkslJ t|d dksJ t|d dksJ d S )Nr   r   r   r   )long title along title blong title clong title dr   rJ   r   ^r   >r   0=r   z&long title a
------------
1           z&long title b
------------
     2      z&long title c
------------
           3z&long title d
------------
000000000004r   r   r:   r:   r;   test_column_alignment  s    



z TestFormat.test_column_alignmentN)r3   r>   r?   r   r   r   r   r   r   r   r   r:   r:   r:   r;   r     s   
r   c                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )TestFormatWithMaskedElementsc                 C   s   t g dg dgddd}g d|d _t|d dks<J d	|d _t|d d
ksZJ d|d _t|d dksxJ d|d _t|d dksJ d|d _t|d dksJ d|d _t|d dksJ d S )N)r   r   r   r   r   r   r   Tr   r0   TFTr   z a 
---
 --
  2
 --r   z  a  
-----
   --
 2.00
   --r   z,   a    
--------
      --
{ 2.00 }
      --r   z a 
---
 --
 %2
 --r   z'   a   
-------
     --
 00002 
     --r   z'   a   
-------
     --
%4.2f 2
     --)r   maskr   rF   r5   r7   r:   r:   r;   r     s    




z/TestFormatWithMaskedElements.test_column_formatc                 C   s   ddl m} |dd ttdgdgdd}d	|d _d|d jd< d|d jd
< t|d 	 g dkstJ d|d _t|d 	 g dksJ W d    n1 s0    Y  d S )Nr   r   rY   rW   r   r   Tr   r   rN   )r   r    --r   r   r   r   r   r   )r   r   	       --r   r   r   r   r   )
r   r.   r   r   r)   rO   rF   r   r   r2   )r5   r.   r7   r:   r:   r;   .test_column_format_with_threshold_masked_table  s    

zKTestFormatWithMaskedElements.test_column_format_with_threshold_masked_tablec                 C   sb   t g dg dgddd}g d|d _dd	 |d _t|d d
ksJJ t|d d
ks^J d S )Nr   r   r   r   r   Tr   r   r   c                 S   s   t | d S r   r   r   r:   r:   r;   r     r   zFTestFormatWithMaskedElements.test_column_format_func.<locals>.<lambda> a 
---
 --
6.0
 --r   r   rF   r   r   r:   r:   r;   r     s
    z4TestFormatWithMaskedElements.test_column_format_funcc                 C   sf   t g dg dgddd}g d|d _dd	 }||d _t|d d
ksNJ t|d d
ksbJ d S )Nr   r   r   Tr   r   r   c                 S   s    | t jju rdS t| d S d S )Nz!!r   )r)   Zmar0   r   r   r:   r:   r;   format_func  s    z]TestFormatWithMaskedElements.test_column_format_func_with_special_masked.<locals>.format_funcz a 
---
 !!
6.0
 !!r   )r5   r7   r   r:   r:   r;   +test_column_format_func_with_special_masked  s    
zHTestFormatWithMaskedElements.test_column_format_func_with_special_maskedc                 C   sn   t g dg dgddd}g d|d _G dd	 d	}| |d _t|d d
ksVJ t|d d
ksjJ d S )Nr   r   r   Tr   r   r   c                   @   s   e Zd Zdd ZdS )zHTestFormatWithMaskedElements.test_column_format_callable.<locals>.formatc                 S   s   t |d S r   r   r   r:   r:   r;   r     s    zQTestFormatWithMaskedElements.test_column_format_callable.<locals>.format.__call__Nr   r:   r:   r:   r;   rF     s   rF   r   r   )r5   r7   rF   r:   r:   r;   r     s    z8TestFormatWithMaskedElements.test_column_format_callablec                 C   s   t ddgddggddd}ddg|d	 _d
d }tt ||d	 _W d    n1 sZ0    Y  ddg|d	 _t|d	 dksJ d S )Nr   r   r   r   r   Tr   Fr   c                 S   s   d S r   r:   r   r:   r:   r;   r     s    zTTestFormatWithMaskedElements.test_column_format_func_wrong_number_args.<locals>.funcz a 
---
 --
 --)r   r   r   r   r   rF   r   )r5   r7   r   r:   r:   r;   r     s    (zFTestFormatWithMaskedElements.test_column_format_func_wrong_number_argsc                 C   s   t ddgddggg}t|dgdd}d|d jd< d|d jd	< d
d |d _d}t|d |ksjJ t|d |ks~J d S )Nr   r   r   r   r   Tr   )r   r   )r   r   c                 S   s   t | d S r   r   r   r:   r:   r;   r     r   zMTestFormatWithMaskedElements.test_column_format_func_multiD.<locals>.<lambda>z+  a [2]   
----------
 3.0 .. --
30.0 .. --)r)   r*   r   r   rF   r   )r5   r6   r7   r   r:   r:   r;   r     s    
z;TestFormatWithMaskedElements.test_column_format_func_multiDN)
r3   r>   r?   r   r   r   r   r   r   r   r:   r:   r:   r;   r     s   r   c                  C   sF   t jddgt jd} t| gdgd}d|d _t|d dksBJ dS )	z
    Test for #148, that np.float32 cannot by itself be formatted as float,
    but has to be converted to a python float.
    r   r   r
   r   r   r   r   N)r)   r*   float32r   rF   r   )datr7   r:   r:   r;   test_pprint_npfloat32  s    
r   c                  C   sP   t ddd} dd}tj| |gdgd}t|}|d  g dksLJ d	S )
z
    Test for #1346 and #4944. Make sure a bytestring (dtype=S<N>) in Python 3
    is printed correctly (without the "b" prefix like b'string').
    valzutf-8)encoding   bläh)colZS10r
   r   )zcol ----z valr   N)bytesencoder)   r*   r   r   r,   )r   Zblahr   r7   r:   r:   r;   test_pprint_py3_bytes$  s
    

r   c                  C   s$   t ddg} t| ds J dS )zhRegression test for #2213, making sure a nameless column can be printed
    using None as the name.
    r   r   NoneN)r   ZColumnr   
startswith)r   r:   r:   r;   test_pprint_nameless_col0  s    r   c                  C   s   t jddgt jd} t| gdgd}|jdd}|dt| d	d
dddgksRJ |jddd}|dt| dd
dddgksJ |jdddgd}|dt| dd
dddgksJ dS )zTest HTML printingr   r   r
   r   r   Tr   r   r   z"<thead><tr><th>a</th></tr></thead>z<tr><td>1.0</td></tr>z<tr><td>2.0</td></tr>r   ztable-striped)r   Z
tableclassz" class="table-striped">r   z" class="table table-striped">N)r)   r*   r   r   r,   r-   )r   r7   r8   r:   r:   r;   	test_html8  s2    

r   c                  C   s  t ddd} |  g dks J d| d _|  g dks>J g d}d	d	d	gd
fD ]}|| j|dksTJ qT| jddg dksJ | jddg dksJ | jdd	gdg dksJ t ddd} | jddg dksJ | jddg dksJ | jddg dksJ tddgddggddgd}d|d _| g dksLJ |jddg dksfJ |jd dgdg d ksJ d!| d _| jddg d"ksJ tt | jd#gd W d    n1 s0    Y  tt | jd$d W d    n1 s0    Y  tt | jd$d W d    n1 sH0    Y  |   tt  | jg d%d W d    n1 s0    Y  tt | jd&d W d    n1 s0    Y  d S )'Nr   ZiS)kinds) a   b --- ---z  1   bz  2   crJ   r   )r   r   z1     bz2     c)r   r   z 1   b z 2   c r   )r   r   )align)r   r   z1   b  z2   c  r   )r   r   z001 00bz002 00c)r   r   z1    b z2    c z^^)r   r   z^1^ ^b^z^2^ ^c^z^>)r   r   z^^1 ^^bz^^2 ^^cz^<)r   r   z1^^ b^^z2^^ c^^r   r   r   Zcolumn1Zcolumn2r   z#^.2f)column1 column2------- -------z##1.00#       1z##2.00#       2z!<)r   r   z1.00!!! 1!!!!!!z2.00!!! 2!!!!!!)r   r   z##1.00# 1!!!!!!z##2.00# 2!!!!!!z+d)r   r   z+01 00bz+02 00cr   r   )rJ   rJ   rJ   zx=)	r   r,   rF   r   r   r   r   	TypeErrorZpprint)r7   Ztpfr   t1r:   r:   r;   
test_alignU  s@    


.,,0r   c                  C   s:   t ddgtj g} d| d _|   t| }|  dS )zBTest for #5802 (fix for #5800 where format_func key is not unique)r   r   z%frC   N)r   umrF   r,   r   )r7   Zqtr:   r:   r;   test_auto_format_func  s
    
r   c                  C   s$   t dgg} |  g dks J dS )z
    Test printing a bytestring column with a value that fails
    decoding to utf-8 and gets replaced by U+FFFD.  See
    https://docs.python.org/3/library/codecs.html#codecs.replace_errors
    s   Z)rC   r   u     Z�N)r   r,   )r7   r:   r:   r;   test_decode_replace  s    r   c                   @   s   e Zd ZdZdd Zejdddd Zdd	 Z	d
d Z
ejddejddddgfdd Zejddejddddgdfdd Zejdddd Zejdddd Zdd Zdd Zdd ZdS )TestColumnsShowHidez$Tests of show and hide table columnsc                 C   s   t dddd| _d S )Nr   r   i)sizeZcolsr   )r   r7   )r5   r:   r:   r;   setup_method  s    z TestColumnsShowHide.setup_methodattr)pprint_exclude_namespprint_include_namesc                 C   sX   | j }ttt|d| dks$J t||}t|d| dksFJ | d u sTJ d S )Nz<PprintIncludeExclude name=z default=None>z value=None>)r7   rK   getattrr   )r5   r   r7   t_show_hider:   r:   r;   
test_basic  s
    
zTestColumnsShowHide.test_basicc                 C   sB   | j }d|_d|_|dd }| dks.J | dks>J d S )Nr   r   r   r   r   r   )r7   r   r   r5   r7   t2r:   r:   r;   
test_slice  s    zTestColumnsShowHide.test_slicec                 C   s   | j }d|_d|_| }| dks*J | dks:J d|_d|_| dksVJ | dksfJ | dksvJ | dksJ d S )	Nr   r   r   r   rL   d)rL   )r   )r7   r   r   copyr   r:   r:   r;   	test_copy  s    zTestColumnsShowHide.test_copyvaluezr   c                 C   s:  | j }t||}t|tr |fnt|}||4 | |ksBJ |jd ||iksXJ W d    n1 sl0    Y  | d u sJ |ji ksJ t||| | |ksJ |d  | d u sJ || | |ksJ |d . | d u sJ |ji ksJ W d    n1 s0    Y  | |ks6J d S )NZ__attributes__)r7   r   
isinstancer   tuplesetmetasetattrr5   r   r   r7   r   expr:   r:   r;   test_setting  s$    
4

0z TestColumnsShowHide.test_setting)r   r   c                 C   s   | j }t||}t|tr |fnt|}|| | |ks@J || | |ksXJ || | d u spJ || |d | |dkrd ndksJ |ddg tj	t
d| d |d W d    n1 s0    Y  d S )Nr   r   r   z	x not in )match)r   r   )r7   r   r  r   r  addremover  r   r   r   r  r:   r:   r;   test_add_remove  s    





z#TestColumnsShowHide.test_add_removec                 C   s<   | j }t||}|ddg |dd | dks8J d S )Nr   r   aa)r  r   )r7   r   r  Zrename_columnr5   r   r7   Zt_hide_showr:   r:   r;   test_rename7  s
    
zTestColumnsShowHide.test_renamec                 C   s6   | j }t||}|ddg |d= | dks2J d S )Nr   r   r   )r7   r   r  r  r:   r:   r;   test_remove?  s
    
zTestColumnsShowHide.test_removec                 C   sf   | j }ddg|_ddg|_t }tj||dd tj| dd}| dksRJ | dksbJ d S )	Nr   yr   r   Zecsv)rF   )r   r  )r   r   )r7   r   r   r   r   writereadgetvalue)r5   r7   r   r   r:   r:   r;   test_serializationG  s    

z&TestColumnsShowHide.test_serializationc              	   C   s  | j }g d}|jddg | }W d   n1 s<0    Y  ||ksRJ |jddg | }W d   n1 s0    Y  ||ksJ |jddg | }W d   n1 s0    Y  ||ksJ |jddg | }W d   n1 s
0    Y  ||ks"J |jg dH |jdg | }W d   n1 sb0    Y  W d   n1 s0    Y  ||ksJ dS )zHTest that pprint_include/exclude_names actually changes the print output)z b   d r   z  2   4r   rL   Nr   r   )r   rL   r   )r7   r   r  r|   r   r5   r7   r  r   r:   r:   r;   test_outputU  s&    &&&(HzTestColumnsShowHide.test_outputc              	   C   s"  | j }d|d< d|d< g d}|jd | }W d   n1 sH0    Y  ||ks^J g d}|jdD |jd	 | }W d   n1 s0    Y  W d   n1 s0    Y  ||ksJ g d
}|jd	 | }W d   n1 s0    Y  ||ksJ dS )zATest that pprint_include/exclude_names works with globs (fnmatch)r   Za2r   Za23)z a   a2 a23z--- --- ---z  1   1   2za*N)z a   a2r   z  1   1za??)z a   b   c   d   a2z--- --- --- --- ---z  1   2   3   4   1)r7   r   r  r|   r   r  r:   r:   r;   test_output_globst  s    &D(z%TestColumnsShowHide.test_output_globsN)r3   r>   r?   __doc__r   r   markZparametrizer   r   r   r  r  r  r  r  r  r  r:   r:   r:   r;   r     s&   

!

r   )'r   Znumpyr)   ior   r   r   Z
astropy.ior   Zastropy.tabler   r   Zastropy.table.table_helpersr   r   r   Zastropy.utilsr	   rO   rP   rQ   rD   r+   rG   r  Zusefixturesr   r@   rA   r   r   r   r   r   r   r   r   r   r   r:   r:   r:   r;   <module>   s6   
T
 &
|c

