a
    7UbA                     @   sh   d 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 G d
d deZdS )Tests for RSTExporter    N)v4   )ExportersTestsBase   RSTExporter   )onlyif_cmds_existc                   @   sR   e Zd ZdZeZdgZdd Zeddd Z	eddd	 Z
edd
d ZdS )TestRSTExporterr   rstc                 C   s
   t   dS )z3
        Can a RSTExporter be constructed?
        Nr   )self r   Alib/python3.9/site-packages/nbconvert/exporters/tests/test_rst.pytest_constructor   s    z TestRSTExporter.test_constructorZpandocc                 C   s(   t  |  \}}t|dks$J dS )z5
        Can a RSTExporter export something?
        r   N)r   from_filename_get_notebooklen)r   output	resourcesr   r   r   test_export   s    zTestRSTExporter.test_exportc                 C   s   |   }tj|dd}t|d}W d   n1 s80    Y  |  }||\}}|jt	j
dd ||\}}| | |  dS )zNo empty code cells in rstutf8)encoding   N )source)r   ioopennbformatreadexporter_classZfrom_notebook_nodeZcellsappendr   Znew_code_cellZassertEqualstrip)r   ZnbnamefZnbZexporterr   r   Zoutput2r   r   r   test_empty_code_cell'   s    *
z$TestRSTExporter.test_empty_code_cellc                 C   s~   t  | jdd\}}t|dks(J tdtj}||}|dusLJ |d}d|v sbJ d|v snJ d	|v szJ dS )
zS
        Does RSTExporter treat pngs with width/height metadata correctly?
        zpngmetadata.ipynb)Znb_namer   z.. image::.*?\n\s+(.*?)\n\s*\nNr   z:width:z:height:Zpx)	r   r   r   r   recompileDOTALLsearchgroup)r   r   r   Zcheck_for_pngresultZattr_stringr   r   r   test_png_metadata9   s    


z!TestRSTExporter.test_png_metadataN)__name__
__module____qualname____doc__r   r    Zshould_include_rawr   r
   r   r$   r+   r   r   r   r   r      s   

r   )r/   r   Zpytestr%   r   r   baser   r   r   Ztests.utilsr
   r   r   r   r   r   <module>   s   