a
    nÝEbçŸ  ã                   @   sž  d dl mZ d dlmZ d dlmZmZ d dlZd dlm	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mZ d dlm  mZ d dlmZmZmZmZmZmZmZ d dlm Z! d d	l"m#Z# d dl$Zd d
l$m%Z% ej& 'e(¡Z)ej*g d¢d�dd„ ƒZ+dd„ Z,e -d¡e -d¡dd„ ƒƒZ.dd„ Z/e -d¡e -d¡e -d¡dd„ ƒƒƒZ0ej1j2dej3de -d¡e -d¡gd�ej3de -d¡d�gdd�G dd„ dƒƒZ4dS ) é    )Úpartial)Úreload)ÚBytesIOÚStringION)ÚPath)ÚURLError)Úis_platform_windows)Ú	DataFrameÚ
MultiIndexÚSeriesÚ	TimestampÚ
date_rangeÚread_csvÚto_datetime)Úfile_path_to_url©Ú	read_html)zchinese_utf-16.htmlzchinese_utf-32.htmlzchinese_utf-8.htmlzletz_latin1.html)Úparamsc                 C   s   |ddd| j ƒS )z6Parametrized fixture for HTML encoding test filenames.ÚioÚdataZhtml_encoding)Úparam)ÚrequestÚdatapath© r   úY/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/pandas/tests/io/test_html.pyÚhtml_encoding_file%   s    
r   c                 O   s�   t | ƒt |ƒks,J dt | ƒ› dt |ƒ› �ƒ‚d}ttdd„ | |ƒƒ}|sPJ |ƒ‚t| |ƒD ]0\}}tj||g|¢R i |¤Ž |jrZJ dƒ‚qZd S )Nz*lists are not of equal size len(list1) == z, len(list2) == z$not all list elements are DataFramesc                 S   s   t | tƒot |tƒS ©N)Ú
isinstancer	   )ÚxÚyr   r   r   Ú<lambda>;   ó    z(assert_framelist_equal.<locals>.<lambda>zframes are both empty)ÚlenÚallÚmapÚzipÚtmÚassert_frame_equalÚempty)Zlist1Zlist2ÚargsÚkwargsÚmsgZboth_framesZframe_iZframe_jr   r   r   Úassert_framelist_equal2   s&    ÿþÿýÿr,   Úbs4Úhtml5libc                 C   s^   dd l }|  |dd¡ tjtdd��& t|dddd	ƒd
d� W d   ƒ n1 sP0    Y  d S )Nr   Ú__version__z4.2zPandas requires version©Úmatchr   r   Úhtmlú	spam.htmlr-   ©Úflavor)r-   ÚsetattrÚpytestÚraisesÚImportErrorr   )Zmonkeypatchr   r-   r   r   r   Útest_bs4_version_failsF   s    r:   c                  C   sT   d} d}d| d }t jt|d�� t| d|d� W d   ƒ n1 sF0    Y  d S )Nz
google.comzinvalid flavorz\{z \} is not a valid set of flavorsr0   Zgoogle©r1   r5   )r7   r8   Ú
ValueErrorr   )Úurlr5   r+   r   r   r   Útest_invalid_flavorP   s
    r>   Úlxmlc                 C   s<   | ddddƒ}t |ddgd�}t |ddgd�}t||ƒ d S )	Nr   r   r2   úvalid_markup.htmlr   r?   )Ú	index_colr5   r-   ©r   r,   )r   ÚfilenameZdfs_lxmlZdfs_bs4r   r   r   Útest_same_orderingY   s    rD   r5   )ZmarksÚclass)Úscopec                   @   s´  e Zd Zejdd�dd„ ƒZejddd�dd„ ƒZd	d
„ Zejj	e
j	dd„ ƒƒZejj	e
j	dd„ ƒƒZejj	e
j	dd„ ƒƒZejj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d+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Z d5d6„ Z!d7d8„ Z"d9d:„ Z#ejj	e
j	d;d<„ ƒƒZ$ejjejj	e
j	d=d>„ ƒƒƒZ%ejjd?d@„ ƒZ&ejjdAdB„ ƒZ'dCdD„ Z(ejjdEdF„ ƒZ)ejjdGdH„ ƒZ*ejjdIdJ„ ƒZ+ejjdKdL„ ƒZ,ejjdMdN„ ƒZ-ejjdOdP„ ƒZ.ejjdQdR„ ƒZ/dSdT„ Z0ejj	e
j	dUdV„ ƒƒZ1ejj	e
j	dWdX„ ƒƒZ2dYdZ„ Z3d[d\„ Z4d]d^„ Z5d_d`„ Z6dadb„ Z7dcdd„ Z8ejjdedf„ ƒZ9ejjdgdh„ ƒZ:didj„ Z;dkdl„ Z<dmdn„ Z=dodp„ Z>dqdr„ Z?dsdt„ Z@dudv„ ZAdwdx„ ZBdydz„ ZCd{d|„ ZDd}d~„ ZEdd€„ ZFd�d‚„ ZGdƒd„„ ZHd…d†„ ZId‡dˆ„ ZJd‰dŠ„ ZKd‹dŒ„ ZLd�dŽ„ ZMd�d�„ ZNd‘d’„ ZOejjd“d”„ ƒZPd•d–„ ZQej Rd—deSd˜gƒd™fdšeSd›gƒeSd˜gƒfg¡dœd�„ ƒZTej Udž¡dŸd „ ƒZVd¡d¢„ ZWd£d¤„ ZXejjd¥d¦„ ƒZYd§d¨„ ZZd™S )©ÚTestReadHtmlT)Úautousec                 C   s4   |ddddƒ| _ i | _d| jd< |ddddƒ| _d S )Nr   r   r2   r3   zUTF-8Úencodingúbanklist.html)Ú	spam_dataÚspam_data_kwargsÚbanklist_data)Úselfr   r   r   r   Ú	set_filesl   s    
zTestReadHtml.set_filesÚfunction)rH   rF   c                 c   s   t t|d�| _d V  d S )Nr4   )r   r   )rN   r5   r   r   r   r   Úset_defaultss   s    zTestReadHtml.set_defaultsc                 C   sV   t jdddd„ ddd� dj¡ t¡}| ¡ }| j|dd	id
d�d
 }t  ||¡ d S )Né   é   c                  W   s
   t j ¡ S r   )ÚnpÚrandomZrand)r)   r   r   r   r    }   r!   z2TestReadHtml.test_to_html_compat.<locals>.<lambda>F)Z
data_gen_fZc_idx_namesZr_idx_namesz{:.3f}rE   Z	dataframer   )ÚattrsrA   )	r&   ZmakeCustomDataframeÚapplymapÚformatZastypeÚfloatÚto_htmlr   r'   )rN   ÚdfÚoutÚresr   r   r   Útest_to_html_compatx   s    ûùøÿz TestReadHtml.test_to_html_compatc                 C   s~   d}t  t¡� |  |d¡}W d   ƒ n1 s00    Y  t  t¡� |  |d¡}W d   ƒ n1 sf0    Y  t||ƒ d S )NúShttp://www.fdic.gov/resources/resolutions/bank-failures/failed-bank-list/index.htmlúFirst Federal Bank of FloridaúMetcalf Bank)r&   Zassert_produces_warningÚFutureWarningr   r,   ©rN   r=   Údf1Údf2r   r   r   Ú"test_banklist_url_positional_matchˆ   s    ý"þ"z/TestReadHtml.test_banklist_url_positional_matchc                 C   s.   d}| j |dd�}| j |dd�}t||ƒ d S )Nr_   r`   r0   ra   rB   rc   r   r   r   Útest_banklist_urlœ   s    ýþzTestReadHtml.test_banklist_urlc                 C   s.   d}| j |dd�}| j |dd�}t||ƒ d S )Nz\https://raw.githubusercontent.com/pandas-dev/pandas/main/pandas/tests/io/data/html/spam.htmlú	.*Water.*r0   ÚUnitrB   rc   r   r   r   Útest_spam_url­   s
    ÿzTestReadHtml.test_spam_urlc                 C   s:   | j | jdddid�}| j | jdddid�}t||ƒ d S )Nz.*Florida.*ÚidÚtable©r1   rV   ra   )r   rM   r,   ©rN   rd   re   r   r   r   Útest_banklist¹   s    ÿÿzTestReadHtml.test_banklistc                 C   sZ   | j | jdd�}| j | jdd�}t||ƒ |d jd dks@J ‚|d jd dksVJ ‚d S )Nrh   r0   ri   r   ©r   r   Ú
ProximatesZNutrient)r   rK   r,   ÚilocÚcolumnsrn   r   r   r   Ú	test_spamÄ   s
    
zTestReadHtml.test_spamc                 C   s(   |   | j¡}|D ]}t|tƒsJ ‚qd S r   )r   rK   r   r	   ©rN   Údfsr[   r   r   r   Útest_spam_no_matchÌ   s    zTestReadHtml.test_spam_no_matchc                 C   s0   | j | jddid�}|D ]}t|tƒsJ ‚qd S )Nrk   rl   )rV   )r   rM   r   r	   ru   r   r   r   Útest_banklist_no_matchÑ   s    z#TestReadHtml.test_banklist_no_matchc                 C   s6   | j | jddd�d }|jd dks(J ‚|jr2J ‚d S )Nrh   é   ©r1   Úheaderr   rq   )r   rK   rs   r(   ©rN   r[   r   r   r   Útest_spam_headerÖ   s    zTestReadHtml.test_spam_headerc                 C   s2   | j | jddd�}| j | jddd�}t||ƒ d S ©Nrh   é   ©r1   Úskiprowsri   ©r   rK   r,   rn   r   r   r   Útest_skiprows_intÛ   s    zTestReadHtml.test_skiprows_intc                 C   s:   | j | jdtdƒd�}| j | jdtdƒd�}t||ƒ d S ©Nrh   ry   r€   ri   )r   rK   Úranger,   rn   r   r   r   Útest_skiprows_rangeá   s    z TestReadHtml.test_skiprows_rangec                 C   s:   | j | jdddgd�}| j | jdddgd�}t||ƒ d S ©Nrh   r   ry   r€   ri   r‚   rn   r   r   r   Útest_skiprows_listç   s    zTestReadHtml.test_skiprows_listc                 C   s:   | j | jdddhd�}| j | jdddhd�}t||ƒ d S r‡   r‚   rn   r   r   r   Útest_skiprows_setí   s    zTestReadHtml.test_skiprows_setc                 C   s2   | j | jddd�}| j | jddd�}t||ƒ d S r~   r‚   rn   r   r   r   Útest_skiprows_sliceó   s    z TestReadHtml.test_skiprows_slicec                 C   s:   | j | jdtdƒd�}| j | jdtdƒd�}t||ƒ d S r„   ©r   rK   Úslicer,   rn   r   r   r   Útest_skiprows_slice_shortù   s    z&TestReadHtml.test_skiprows_slice_shortc                 C   s@   | j | jdtddƒd�}| j | jdtdddƒd�}t||ƒ d S )	Nrh   ry   é   r€   ri   rR   r   éÿÿÿÿr‹   rn   r   r   r   Útest_skiprows_slice_longÿ   s    z%TestReadHtml.test_skiprows_slice_longc                 C   s>   | j | jdt d¡d�}| j | jdt d¡d�}t||ƒ d S r„   )r   rK   rT   Zaranger,   rn   r   r   r   Útest_skiprows_ndarray  s    z"TestReadHtml.test_skiprows_ndarrayc                 C   sD   t jtdd��" | j| jddd� W d   ƒ n1 s60    Y  d S )Nz%is not a valid type for skipping rowsr0   rh   Zasdfr€   )r7   r8   Ú	TypeErrorr   rK   ©rN   r   r   r   Útest_skiprows_invalid  s    z"TestReadHtml.test_skiprows_invalidc                 C   s2   | j | jddd�}| j | jddd�}t||ƒ d S ©Nrh   r   ©r1   rA   ri   r‚   rn   r   r   r   Ú
test_index  s    zTestReadHtml.test_indexc                 C   s6   | j | jdddd�}| j | jdddd�}t||ƒ d S ©Nrh   r   r   )r1   r{   rA   ri   r‚   rn   r   r   r   Útest_header_and_index_no_types  s    z+TestReadHtml.test_header_and_index_no_typesc                 C   s6   | j | jdddd�}| j | jdddd�}t||ƒ d S r˜   r‚   rn   r   r   r   Ú test_header_and_index_with_types  s    z-TestReadHtml.test_header_and_index_with_typesc                 C   s2   | j | jddd�}| j | jddd�}t||ƒ d S r•   r‚   rn   r   r   r   Útest_infer_types  s    zTestReadHtml.test_infer_typesc                 C   sª   t | jfi | j¤Ž�}t| ¡ ƒ}W d   ƒ n1 s60    Y  t | jfi | j¤Ž�}t| ¡ ƒ}W d   ƒ n1 sv0    Y  | j|dd�}| j|dd�}t||ƒ d S ©Nrh   r0   ri   )ÚopenrK   rL   r   Úreadr   r,   )rN   ÚfÚdata1Údata2rd   re   r   r   r   Útest_string_io%  s    **zTestReadHtml.test_string_ioc                 C   sf   t | jfi | j¤Ž�}| ¡ }W d   ƒ n1 s20    Y  | j|dd�}| j|dd�}t||ƒ d S rœ   )r�   rK   rL   rž   r   r,   )rN   rŸ   r   rd   re   r   r   r   Útest_string0  s
    &zTestReadHtml.test_stringc                 C   s’   t | jfi | j¤Ž�}| j|dd�}W d   ƒ n1 s80    Y  t | jfi | j¤Ž�}| j|dd�}W d   ƒ n1 sz0    Y  t||ƒ d S rœ   )r�   rK   rL   r   r,   )rN   rŸ   rd   re   r   r   r   Útest_file_like9  s
    ,,zTestReadHtml.test_file_likec                 C   s@   t jtdd�� | jddd� W d   ƒ n1 s20    Y  d S )Nz#urlopen error unknown url type: gitr0   zgit://github.comrh   )r7   r8   r   r   r“   r   r   r   Útest_bad_url_protocolB  s    z"TestReadHtml.test_bad_url_protocolc                 C   sH   d}t jttf|d�� | jddd� W d   ƒ n1 s:0    Y  d S )NzNName or service not known|Temporary failure in name resolution|No tables foundr0   zhttp://www.a23950sdfa908sd.comrh   )r7   r8   r   r<   r   ©rN   r+   r   r   r   Útest_invalid_urlH  s    ÿzTestReadHtml.test_invalid_urlc                 C   sP   | j }| jttj |¡ƒdddid�}t|tƒs4J ‚|D ]}t|tƒs8J ‚q8d S )NZFirstrk   rl   rm   )	rM   r   r   ÚosÚpathÚabspathr   Úlistr	   ©rN   r=   rv   r[   r   r   r   Útest_file_urlS  s    ÿzTestReadHtml.test_file_urlc                 C   sL   | j }tjtdd��$ | j|dddid� W d   ƒ n1 s>0    Y  d S )NzNo tables foundr0   r`   rk   Z	tasdfablerm   )rM   r7   r8   r<   r   )rN   r=   r   r   r   Útest_invalid_table_attrs]  s
    
ÿz%TestReadHtml.test_invalid_table_attrsc                 O   s$   | j | jg|¢R dddidœ|¤ŽS )NÚMetcalfrk   rl   rm   )r   rM   )rN   r)   r*   r   r   r   Ú
_bank_datae  s    ÿÿÿÿzTestReadHtml._bank_datac                 C   s(   | j ddgd�d }t|jtƒs$J ‚d S )Nr   r   ©r{   ©r°   r   rs   r
   r|   r   r   r   Útest_multiindex_headerj  s    z#TestReadHtml.test_multiindex_headerc                 C   s(   | j ddgd�d }t|jtƒs$J ‚d S )Nr   r   ©rA   )r°   r   Úindexr
   r|   r   r   r   Útest_multiindex_indexo  s    z"TestReadHtml.test_multiindex_indexc                 C   s>   | j ddgddgd�d }t|jtƒs*J ‚t|jtƒs:J ‚d S )Nr   r   )r{   rA   )r°   r   rs   r
   rµ   r|   r   r   r   Útest_multiindex_header_indext  s    z)TestReadHtml.test_multiindex_header_indexc                 C   s*   | j ddgdd�d }t|jtƒs&J ‚d S ©Nr   r   )r{   r�   r²   r|   r   r   r   Ú&test_multiindex_header_skiprows_tuplesz  s    z3TestReadHtml.test_multiindex_header_skiprows_tuplesc                 C   s*   | j ddgdd�d }t|jtƒs&J ‚d S r¸   r²   r|   r   r   r   Útest_multiindex_header_skiprows  s    z,TestReadHtml.test_multiindex_header_skiprowsc                 C   s@   | j ddgddgdd�d }t|jtƒs,J ‚t|jtƒs<J ‚d S )Nr   r   )r{   rA   r�   )r°   r   rµ   r
   rs   r|   r   r   r   Ú%test_multiindex_header_index_skiprows„  s    z2TestReadHtml.test_multiindex_header_index_skiprowsc                 C   s\   | j }| jttj |¡ƒt t d¡¡ddid�}t|t	ƒs@J ‚|D ]}t|t
ƒsDJ ‚qDd S )NZFloridark   rl   rm   )rM   r   r   r¨   r©   rª   ÚreÚcompiler   r«   r	   r¬   r   r   r   Útest_regex_idempotencyŠ  s    ýz#TestReadHtml.test_regex_idempotencyc                 C   sH   d}t jt|d��" | j| jddd� W d   ƒ n1 s:0    Y  d S )Nz\(you passed a negative value\)r0   ZWaterr�   r€   )r7   r8   r<   r   rK   r¦   r   r   r   Útest_negative_skiprows–  s    z#TestReadHtml.test_negative_skiprowsc                 C   s&   d}| j |dd�}t|ƒdks"J ‚d S )Núhttps://docs.python.org/2/ÚPythonr0   r   ©r   r"   )rN   r=   rv   r   r   r   Útest_multiple_matches›  s    z"TestReadHtml.test_multiple_matchesc                 C   s<   d}| j |dd�}dd„ |D ƒ}t|ƒtddgƒks8J ‚d S )NrÀ   rÁ   r0   c                 S   s   g | ]}|j d  dd… ‘qS )rp   r   rR   )rr   )Ú.0r[   r   r   r   Ú
<listcomp>§  r!   z7TestReadHtml.test_python_docs_table.<locals>.<listcomp>ZRepoZWhat)r   Úsorted)rN   r=   rv   Úzzr   r   r   Útest_python_docs_table¢  s    z#TestReadHtml.test_python_docs_tablec                 C   s"   d}|   |¡}t|ƒdksJ ‚dS )z@
        Make sure that read_html ignores empty tables.
        aà  
            <table>
                <thead>
                    <tr>
                        <th>A</th>
                        <th>B</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>1</td>
                        <td>2</td>
                    </tr>
                </tbody>
            </table>
            <table>
                <tbody>
                </tbody>
            </table>
        r   NrÂ   )rN   r2   Úresultr   r   r   Útest_empty_tablesª  s    
zTestReadHtml.test_empty_tablesc                 C   s:   |   d¡d }tddgddggddgd	�}t ||¡ d S )
NaÎ  <table>
            <thead>
                <tr>
                    <th>A</th>
                    <th>B</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>2</td>
                </tr>
            </tbody>
            <tbody>
                <tr>
                    <td>3</td>
                    <td>4</td>
                </tr>
            </tbody>
        </table>r   r   ry   rS   rR   ÚAÚB©r   rs   ©r   r	   r&   r'   ©rN   rÉ   Úexpectedr   r   r   Útest_multiple_tbodyÅ  s    ÿëz TestReadHtml.test_multiple_tbodyc                 C   s0   |   d¡d }tddidgd�}t ||¡ dS )zt
        Don't fail with bs4 when there is a header and only one column
        as described in issue #9178
        a3  <table>
                <thead>
                    <tr>
                        <th>Header</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>first</td>
                    </tr>
                </tbody>
            </table>r   ÚHeaderÚfirst©r   rµ   NrÎ   rÏ   r   r   r   Útest_header_and_one_columnã  s    ÿóz'TestReadHtml.test_header_and_one_columnc                 C   s4   |   d¡d }tg d¢gg d¢d�}t ||¡ dS )zK
        Ensure parser adds <tr> within <thead> on malformed HTML.
        aœ  <table>
            <thead>
                <tr>
                    <th>Country</th>
                    <th>Municipality</th>
                    <th>Year</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Ukraine</td>
                    <th>Odessa</th>
                    <td>1944</td>
                </tr>
            </tbody>
        </table>r   )ZUkraineZOdessaé˜  )ZCountryZMunicipalityZYearrÍ   NrÎ   rÏ   r   r   r   Útest_thead_without_trû  s    ÿïþz"TestReadHtml.test_thead_without_trc                 C   s†   d}t ddggddgd�}t ddgddggddgd�}|jd	d
�}|jdd
�}|  |¡d }|  |¡d }t ||¡ t ||¡ dS )zh
        Make sure that read_html reads tfoot, containing td or th.
        Ignores empty tfoot
        a†  <table>
            <thead>
                <tr>
                    <th>A</th>
                    <th>B</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>bodyA</td>
                    <td>bodyB</td>
                </tr>
            </tbody>
            <tfoot>
                {footer}
            </tfoot>
        </table>ZbodyAZbodyBrË   rÌ   rÍ   ZfootAZfootBÚ )Úfooterz%<tr><td>footA</td><th>footB</th></tr>r   N)r	   rX   r   r&   r'   )rN   Zdata_templateZ	expected1Z	expected2r    r¡   Zresult1Zresult2r   r   r   Útest_tfoot_read  s    ÿzTestReadHtml.test_tfoot_readc                 C   s4   | j ddd�d }tddggdd�}t ||¡ d S )Na
  
            <table>
                <tr>
                    <td>S</td>
                    <td>I</td>
                </tr>
                <tr>
                    <td>text</td>
                    <td>1944</td>
                </tr>
            </table>
        r   r±   ÚtextrÖ   )ÚSÚI©rs   rÎ   rÏ   r   r   r   Ú&test_parse_header_of_non_string_column?  s    óòz3TestReadHtml.test_parse_header_of_non_string_columnc                    sÂ   ddl m‰  ‡ fdd„}| j| jdddid�d }t|d	d
ddƒttdœd�}|j|jks^J ‚g d¢}g d¢}| |¡ ||¡}| |¡}|j	ddd�}	ddg}
|	|
  
t¡|	|
< t |	|¡ d S )Nr   ©Ú_remove_whitespacec                    s&   z
ˆ | ƒW S  t y    |  Y S 0 d S r   )ÚAttributeError©r   rà   r   r   Útry_remove_wsZ  s    
z8TestReadHtml.test_banklist_header.<locals>.try_remove_wsr¯   rk   rl   rm   r   r   Úcsvzbanklist.csv)úUpdated DateúClosing Date©Ú
converters)
z+First Vietnamese American BankIn Vietnamesez!Westernbank Puerto RicoEn Espanolz)R-G Premier Bank of Puerto RicoEn EspanolzEurobankEn EspanolzSanderson State BankEn EspanolzKWashington Mutual Bank(Including its subsidiary Washington Mutual Bank FSB)zSilver State BankEn Espanolz$AmTrade International BankEn EspanolzHamilton Bank, NAEn Espanolz5The Citizens Savings BankPioneer Community Bank, Inc.)
zFirst Vietnamese American BankzWesternbank Puerto RicozR-G Premier Bank of Puerto RicoZEurobankzSanderson State BankzWashington Mutual BankzSilver State BankzAmTrade International BankzHamilton Bank, NAzThe Citizens Savings BankT)ÚdatetimeÚnumericrç   ræ   )Úpandas.io.htmlrá   r   rM   r   r   ÚshaperW   ÚreplaceÚ_convertÚapplyr   r&   r'   )rN   r   rä   r[   Zground_truthÚoldÚnewZdfnewZgtnewZ	convertedZ	date_colsr   rà   r   Útest_banklist_headerV  s$    ÿþ
z!TestReadHtml.test_banklist_headerc                 C   sp   d}t | jƒ�}| ¡ }W d   ƒ n1 s,0    Y  ||v sBJ ‚| j| jdddid�d }|| ¡ v slJ ‚d S )NzGold Canyonrk   rl   rm   r   )r�   rM   rž   r   Z	to_string)rN   ÚgcrŸ   Zraw_textr[   r   r   r   Útest_gold_canyonˆ  s    &ÿþzTestReadHtml.test_gold_canyonc                 C   s4   | j ddd�d }| j ddd�d }t ||¡ d S )Na�  <table>
                        <thead>
                            <tr style="text-align: right;">
                            <th></th>
                            <th>C_l0_g0</th>
                            <th>C_l0_g1</th>
                            <th>C_l0_g2</th>
                            <th>C_l0_g3</th>
                            <th>C_l0_g4</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                            <th>R_l0_g0</th>
                            <td> 0.763</td>
                            <td> 0.233</td>
                            <td> nan</td>
                            <td> nan</td>
                            <td> nan</td>
                            </tr>
                            <tr>
                            <th>R_l0_g1</th>
                            <td> 0.244</td>
                            <td> 0.285</td>
                            <td> 0.392</td>
                            <td> 0.137</td>
                            <td> 0.222</td>
                            </tr>
                        </tbody>
                    </table>r   r´   a¸  <table>
                    <thead>
                        <tr style="text-align: right;">
                        <th></th>
                        <th>C_l0_g0</th>
                        <th>C_l0_g1</th>
                        <th>C_l0_g2</th>
                        <th>C_l0_g3</th>
                        <th>C_l0_g4</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                        <th>R_l0_g0</th>
                        <td> 0.763</td>
                        <td> 0.233</td>
                        </tr>
                        <tr>
                        <th>R_l0_g1</th>
                        <td> 0.244</td>
                        <td> 0.285</td>
                        <td> 0.392</td>
                        <td> 0.137</td>
                        <td> 0.222</td>
                        </tr>
                    </tbody>
                 </table>)r   r&   r'   )rN   rÐ   rÉ   r   r   r   Útest_different_number_of_cols”  s    á à"äãz*TestReadHtml.test_different_number_of_colsc                 C   s4   |   d¡d }tg d¢gg d¢d�}t ||¡ d S )NaZ  
            <table>
                <tr>
                    <th>A</th>
                    <th colspan="1">B</th>
                    <th rowspan="1">C</th>
                </tr>
                <tr>
                    <td>a</td>
                    <td>b</td>
                    <td>c</td>
                </tr>
            </table>
        r   )ÚaÚbÚc)rË   rÌ   ÚCrÞ   rÎ   rÏ   r   r   r   Útest_colspan_rowspan_1Ø  s    ÿñz#TestReadHtml.test_colspan_rowspan_1c                 C   s8   | j ddd�d }tg d¢gg d¢d�}t ||¡ d S )Na…  
            <table>
                <tr>
                    <td colspan="2">X</td>
                    <td>Y</td>
                    <td rowspan="2">Z</td>
                    <td>W</td>
                </tr>
                <tr>
                    <td>A</td>
                    <td colspan="2">B</td>
                    <td>C</td>
                </tr>
            </table>
        r   r±   )rË   rÌ   rÌ   ÚZrú   )ÚXzX.1ÚYrü   ÚWrÍ   rÎ   rÏ   r   r   r   Ú test_colspan_rowspan_copy_valuesï  s    ðïÿz-TestReadHtml.test_colspan_rowspan_copy_valuesc                 C   s8   | j ddd�d }tg d¢gg d¢d�}t ||¡ d S )Na(  
            <table>
                <tr>
                    <td rowspan="2">A</td>
                    <td rowspan="2" colspan="3">B</td>
                    <td>C</td>
                </tr>
                <tr>
                    <td>D</td>
                </tr>
            </table>
        r   r±   )rË   rÌ   rÌ   rÌ   ÚD)rË   rÌ   zB.1zB.2rú   rÍ   rÎ   rÏ   r   r   r   Útest_colspan_rowspan_both_not_1  s    óòÿz,TestReadHtml.test_colspan_rowspan_both_not_1c                 C   s8   | j ddd�d }tddggddgd�}t ||¡ d S )Nzñ
            <table>
                <tr>
                    <td>A</td>
                    <td rowspan="2">B</td>
                </tr>
                <tr>
                    <td>C</td>
                </tr>
            </table>
        r   r±   rú   rÌ   rË   rÍ   rÎ   rÏ   r   r   r   Útest_rowspan_at_end_of_row.  s    ôóz'TestReadHtml.test_rowspan_at_end_of_rowc                 C   s>   | j ddd�d }tddgddggddgd�}t ||¡ d S )Nz³
            <table>
                <tr>
                    <td rowspan="3">A</td>
                    <td rowspan="3">B</td>
                </tr>
            </table>
        r   r±   rË   rÌ   rÍ   rÎ   rÏ   r   r   r   Útest_rowspan_only_rowsI  s    ÷
öz#TestReadHtml.test_rowspan_only_rowsc                 C   sT   |   d¡d }tddgddggddgddggd�}tdd	gg|d
�}t ||¡ d S )Nam  
            <table>
                <tr>
                    <th>A</th>
                    <th>B</th>
                </tr>
                <tr>
                    <th>a</th>
                    <th>b</th>
                </tr>
                <tr>
                    <td>1</td>
                    <td>2</td>
                </tr>
            </table>
        r   rË   rÌ   r÷   rø   r   ©ZlevelsÚcodesry   rÍ   ©r   r
   r	   r&   r'   ©rN   rÉ   rs   rÐ   r   r   r   Ú+test_header_inferred_from_rows_with_only_th\  s    ÿï$z8TestReadHtml.test_header_inferred_from_rows_with_only_thc                 C   sd   t dtddd�iƒ}| ¡ }| j|dgdd�}t ||d ¡ | j|dgdd�}t ||d ¡ d S )NÚdateú1/1/2001é
   ©Zperiodsr   r   ©Zparse_datesrA   )r	   r   rZ   r   r&   r'   )rN   r[   rÐ   r]   r   r   r   Útest_parse_dates_listv  s    z"TestReadHtml.test_parse_dates_listc                 C   sn   t tddd�ƒ}t| dd„ ¡| dd„ ¡dœƒ}| j| ¡ dd	d
gid	d�}td|iƒ}t ||d ¡ d S )Nr  r  r  c                 S   s   t |  ¡ ƒS r   )Ústrr
  rã   r   r   r   r    ‚  r!   z7TestReadHtml.test_parse_dates_combine.<locals>.<lambda>c                 S   s   t |  ¡ ƒS r   )r  Útimerã   r   r   r   r    ƒ  r!   )r
  r  rê   r   ry   r  r   )r   r   r	   r$   r   rZ   r&   r'   )rN   Z	raw_datesr[   r]   Znewdfr   r   r   Útest_parse_dates_combine~  s    þÿÿz%TestReadHtml.test_parse_dates_combinec                 C   s°   |ddddƒ}t j |¡s,J t|ƒ› d�ƒ‚t j |¡sJJ t|ƒ› d�ƒ‚| j|ddd	�d
 }|jdkslJ ‚d|jd v s~J ‚|d jt	 d¡ks–J ‚t	 
|jd d¡s¬J ‚d S )Nr   r   r2   úwikipedia_states.htmlz is not a filez is an empty fileÚArizonar   rz   r   )é<   é   ÚUnnamedr�   úsq miÚfloat64)r   r  çHázPN$A)r¨   r©   ÚisfileÚreprÚgetsizer   rí   rs   ÚdtyperT   ÚallcloseÚloc©rN   r   r   rÉ   r   r   r   Útest_wikipedia_states_tableŒ  s    z(TestReadHtml.test_wikipedia_states_tablec                 C   sp   |ddddƒ}| j |ddd�d }|jdks0J ‚d	|jd
 d v sFJ ‚|jjdksVJ ‚t |jd d¡slJ ‚d S )Nr   r   r2   r  r  r   r–   )r  é   r  r�   r   ry   )ZAlaska)zTotal area[2]r  r  )r   rí   rs   ZnlevelsrT   r  r   r!  r   r   r   Ú test_wikipedia_states_multiindex–  s    z-TestReadHtml.test_wikipedia_states_multiindexc                 C   sB   | j dddgd�}tddggt ddg¡d	�}t |d |¡ d S )
NaK  
                <table>
                    <thead>
                        <tr><th></th><th></tr>
                        <tr><th>A</th><th>B</th></tr>
                    </thead>
                    <tbody>
                        <tr><td>a</td><td>b</td></tr>
                    </tbody>
                </table>
            r   r   r±   r÷   rø   )úUnnamed: 0_level_0rË   )zUnnamed: 1_level_0rÌ   rÞ   )r   r	   r
   Úfrom_tuplesr&   r'   rÏ   r   r   r   Ú%test_parser_error_on_empty_header_rowž  s    ôÿþz2TestReadHtml.test_parser_error_on_empty_header_rowc                 C   sL   | j ddd�d }tddidgd�}|d jt d¡ks<J ‚t ||¡ d S )	Na�  <html>
            <body>
             <table>
                <thead>
                    <tr>
                        <th>Header</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>1100#101</td>
                    </tr>
                </tbody>
            </table>
            </body>
        </html>ú#)Údecimalr   rÒ   g–C‹lg0‘@rÔ   r  )r   r	   r  rT   r&   r'   rÏ   r   r   r   Útest_decimal_rowsµ  s    ïîzTestReadHtml.test_decimal_rowsc              	   C   sV   t  d¡}dD ]B}tjt|d��  | j| j|d� W d   ƒ q1 sF0    Y  qd S )Nz–Passing a bool to header is invalid. Use header=None for no header or header=int or list-like of ints to specify the row(s) making up the column names)TFr0   r±   )r¼   Úescaper7   r8   r’   r   rK   )rN   r+   Úargr   r   r   Útest_bool_header_argÐ  s    ÿz!TestReadHtml.test_bool_header_argc                 C   s6   | j ddtid�d }tdddgiƒ}t ||¡ d S )Naƒ  <table>
                 <thead>
                   <tr>
                     <th>a</th>
                    </tr>
                 </thead>
                 <tbody>
                   <tr>
                     <td> 0.763</td>
                   </tr>
                   <tr>
                     <td> 0.244</td>
                   </tr>
                 </tbody>
               </table>r÷   rè   r   z0.763z0.244)r   r  r	   r&   r'   rÏ   r   r   r   Útest_convertersÛ  s    ðïzTestReadHtml.test_convertersc                 C   s6   | j ddgd�d }tddtjgiƒ}t ||¡ d S )Na‚  <table>
                 <thead>
                   <tr>
                     <th>a</th>
                   </tr>
                 </thead>
                 <tbody>
                   <tr>
                     <td> 0.763</td>
                   </tr>
                   <tr>
                     <td> 0.244</td>
                   </tr>
                 </tbody>
               </table>g¬Zd;Ï?)Z	na_valuesr   r÷   gÑ"Ûù~jè?©r   r	   rT   Únanr&   r'   rÏ   r   r   r   Útest_na_valuesô  s    ðïzTestReadHtml.test_na_valuesc                 C   sh   d}t dddgiƒ}| j|dd�d }t ||¡ t dtjtjgiƒ}| j|dd�d }t ||¡ d S )	Naé  <table>
                        <thead>
                            <tr>
                            <th>a</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                            <td> N/A</td>
                            </tr>
                            <tr>
                            <td> NA</td>
                            </tr>
                        </tbody>
                    </table>r÷   zN/AZNAF)Zkeep_default_nar   T)r	   r   r&   r'   rT   r0  )rN   Z	html_dataÚexpected_dfÚhtml_dfr   r   r   Útest_keep_default_na  s    z!TestReadHtml.test_keep_default_nac                 C   s>   |   d¡d }tddgtjtjggddgd�}t ||¡ d S )Nak  
            <table>
                <tr>
                    <th>A</th>
                    <th>B</th>
                </tr>
                <tr>
                    <td>a</td>
                    <td>b</td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        r   r÷   rø   rË   rÌ   rÍ   r/  rÏ   r   r   r   Útest_preserve_empty_rows&  s    ÿï z%TestReadHtml.test_preserve_empty_rowsc                 C   sT   |   d¡d }tddgddggddgddggd�}tdd	gg|d
�}t ||¡ d S )NaU  
            <table>
                <thead>
                    <tr><th></th><th></tr>
                    <tr><th>A</th><th>B</th></tr>
                    <tr><th>a</th><th>b</th></tr>
                </thead>
                <tbody>
                    <tr><td>1</td><td>2</td></tr>
                </tbody>
            </table>
        r   rË   rÌ   r÷   rø   r   r  ry   rÍ   r  r  r   r   r   Ú,test_ignore_empty_rows_when_inferring_header>  s    ÿó$z9TestReadHtml.test_ignore_empty_rows_when_inferring_headerc                 C   sJ   t g d¢d�}g d¢g d¢g|_|jdd�}|  |¡d }t ||¡ d S )N))ZHillaryéD   r  )ZBernieéJ   r  )ZDonaldéE   ÚR)r   )r%  ZAgeZParty)ÚNamezUnnamed: 1_level_1zUnnamed: 2_level_1F©rµ   r   )r	   rs   rZ   r   r&   r'   )rN   r2  r2   r3  r   r   r   Útest_multiple_header_rowsS  s    ÿþz&TestReadHtml.test_multiple_header_rowsc                 C   s@   |ddddƒ}| j |dd�}t|tƒs*J ‚t|d tƒs<J ‚d S )Nr   r   r2   r@   r   r´   )r   r   r«   r	   )rN   r   rC   rv   r   r   r   Útest_works_on_valid_markup`  s    z'TestReadHtml.test_works_on_valid_markupc                 C   s&   |ddddƒ}| j |dddgd� d S )	Nr   r   r2   rJ   rh   r?   r.   r;   r   )rN   r   rM   r   r   r   Útest_fallback_successf  s    z"TestReadHtml.test_fallback_successc                 C   s:   t ddd�}ttj dd¡|d�}| ¡ }d|v s6J ‚d S )Nz
2000-01-01r  r  rR   r<  )r   r	   rT   rU   ZrandnrZ   )rN   Úrngr[   rÉ   r   r   r   Útest_to_html_timestampk  s    z#TestReadHtml.test_to_html_timestampzdisplayed_only,exp0,exp1ZfooNFzfoo  bar  baz  quxc                 C   sT   t dƒ}| j||d�}t |d |¡ |d ur@t |d |¡ nt|ƒdksPJ ‚d S )Na  <html>
          <body>
            <table>
              <tr>
                <td>
                  foo
                  <span style="display:none;text-align:center">bar</span>
                  <span style="display:none">baz</span>
                  <span style="display: none">qux</span>
                </td>
              </tr>
            </table>
            <table style="display: none">
              <tr>
                <td>foo</td>
              </tr>
            </table>
          </body>
        </html>)Údisplayed_onlyr   r   )r   r   r&   r'   r"   )rN   rB  Zexp0Zexp1r   rv   r   r   r   Útest_displayed_onlyr  s    	ÿz TestReadHtml.test_displayed_onlyz\ignore:You provided Unicode markup but also provided a value for from_encoding.*:UserWarningc           
      C   s"  t j |¡}t j |¡d }| d¡\}}z¸t|dƒ�(}| j| ¡ |dd� ¡ }W d   ƒ n1 sd0    Y  t|dƒ�,}| jt	| ¡ ƒ|dd� ¡ }W d   ƒ n1 sª0    Y  | j||dd� ¡ }	t
 ||¡ t
 ||	¡ W n: t�y   tƒ �rd|v �sd|v �rt ¡  ‚ Y n0 d S )Nr   Ú_Úrb)rI   rA   Z16Z32)r¨   r©   ÚbasenameÚsplitextÚsplitr�   r   rž   Úpopr   r&   r'   Ú	Exceptionr   r7   Úskip)
rN   r   Ú	base_pathÚrootrD  rI   ZfobjZfrom_stringZfrom_file_likeÚfrom_filenamer   r   r   Útest_encode™  s,    
ÿ(ÿ(ÿ
zTestReadHtml.test_encodec                 C   s~   | j j d¡dkrt d¡ G dd„ dtƒ}|dƒ}|   |¡sBJ ‚tjtdd�� |   |¡ W d   ƒ n1 sp0    Y  d S )	Nr5   r?   zNot applicable for lxmlc                   @   s   e Zd Zdd„ ZdS )zFTestReadHtml.test_parse_failure_unseekable.<locals>.UnseekableStringIOc                 S   s   dS ©NFr   r“   r   r   r   ÚseekableÀ  s    zOTestReadHtml.test_parse_failure_unseekable.<locals>.UnseekableStringIO.seekableN)Ú__name__Ú
__module__Ú__qualname__rQ  r   r   r   r   ÚUnseekableStringIO¿  s   rU  z?
            <table><tr><td>spam<foobr />eggs</td></tr></table>z#passed a non-rewindable file objectr0   )r   ÚkeywordsÚgetr7   rK  r   r8   r<   )rN   rU  Úbadr   r   r   Útest_parse_failure_unseekable¹  s    
ÿz*TestReadHtml.test_parse_failure_unseekablec                 C   s>   G dd„ dƒ}|dƒ}|dƒ}|   |¡s,J ‚|   |¡s:J ‚d S )Nc                   @   s6   e Zd Zdd„ Zddd„Zdd„ Zdd	„ Zd
d„ ZdS )z9TestReadHtml.test_parse_failure_rewinds.<locals>.MockFilec                 S   s   || _ d| _d S rP  )r   Úat_end)rN   r   r   r   r   Ú__init__Ñ  s    zBTestReadHtml.test_parse_failure_rewinds.<locals>.MockFile.__init__Nc                 S   s   | j r
dn| j}d| _ |S )NrØ   T)rZ  r   )rN   Úsizer   r   r   r   rž   Õ  s    z>TestReadHtml.test_parse_failure_rewinds.<locals>.MockFile.readc                 S   s
   d| _ d S rP  )rZ  )rN   Úoffsetr   r   r   ÚseekÚ  s    z>TestReadHtml.test_parse_failure_rewinds.<locals>.MockFile.seekc                 S   s   dS )NTr   r“   r   r   r   rQ  Ý  s    zBTestReadHtml.test_parse_failure_rewinds.<locals>.MockFile.seekablec                 S   s   dsJ ‚d S rP  r   r“   r   r   r   Ú__iter__à  s    zBTestReadHtml.test_parse_failure_rewinds.<locals>.MockFile.__iter__)N)rR  rS  rT  r[  rž   r^  rQ  r_  r   r   r   r   ÚMockFileÐ  s
   
r`  z/<table><tr><td>spam<br />eggs</td></tr></table>z2<table><tr><td>spam<foobr />eggs</td></tr></table>r   )rN   r`  ZgoodrX  r   r   r   Útest_parse_failure_rewindsÍ  s
    z'TestReadHtml.test_parse_failure_rewindsc                 C   s�   G dd„ dt jƒ}ttjjƒ |ddddƒ}|| j|fd�}|| j|fd�}| ¡  | ¡  | ¡ s\| ¡ rnq\d |j	  u r†|j	u sŒn J ‚d S )Nc                       s   e Zd Z‡ fdd„Z‡  ZS )z@TestReadHtml.test_importcheck_thread_safety.<locals>.ErrorThreadc              
      sD   zt ƒ  ¡  W n* ty8 } z|| _W Y d }~nd }~0 0 d | _d S r   )ÚsuperÚrunrJ  Úerr)rN   rd  ©Ú	__class__r   r   rc  ï  s
    zDTestReadHtml.test_importcheck_thread_safety.<locals>.ErrorThread.run)rR  rS  rT  rc  Ú__classcell__r   r   re  r   ÚErrorThreadî  s   rh  r   r   r2   r@   )Útargetr)   )
Ú	threadingÚThreadr   Úpandasr   r2   r   ÚstartÚis_aliverd  )rN   r   rh  rC   Zhelper_thread1Zhelper_thread2r   r   r   Útest_importcheck_thread_safetyê  s    
z+TestReadHtml.test_importcheck_thread_safetyc                 C   sB   |ddddƒ}t |ƒ}|  |¡d }|  |¡d }t ||¡ d S )Nr   r   r2   r3   r   )r   r   r&   r'   )rN   r   Zfile_path_stringÚ	file_pathrd   re   r   r   r   Útest_parse_path_object  s
    z#TestReadHtml.test_parse_path_object)[rR  rS  rT  r7   ÚfixturerO   rQ   r^   ÚmarkÚnetworkr&   rf   rg   rj   Zslowro   rt   rw   rx   r}   rƒ   r†   rˆ   r‰   rŠ   r�   r�   r‘   r”   r—   r™   rš   r›   r¢   r£   r¤   r¥   r§   r­   r®   r°   r³   r¶   r·   r¹   rº   r»   r¾   r¿   rÃ   rÈ   rÊ   rÑ   rÕ   r×   rÚ   rß   ró   rõ   rö   rû   r   r  r  r  r	  r  r  r"  r$  r'  r*  r-  r.  r1  r4  r5  r6  r=  r>  r?  rA  Úparametrizer	   rC  ÚfilterwarningsrO  rY  ra  ro  rq  r   r   r   r   rG   c   sî   	





		
	







&
1
D!

þþ
 ÿ

rG   )5Ú	functoolsr   Ú	importlibr   r   r   r   r¨   Úpathlibr   r¼   rj  Úurllib.errorr   ÚnumpyrT   r7   Zpandas.compatr   Zpandas.util._test_decoratorsÚutilZ_test_decoratorsÚtdrl  r	   r
   r   r   r   r   r   Zpandas._testingZ_testingr&   Zpandas.io.commonr   rì   r   r©   ÚdirnameÚ__file__ZHERErr  r   r,   Z
skip_if_nor:   r>   rD   rs  ru  r   rG   r   r   r   r   Ú<module>   sL   $	ÿ
	þú