a
    7Ub;                     @   s   d Z ddl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mZmZmZmZ ddlmZ dd	lmZ G d
d de
Zdd ZdS )z!
Module with tests for export.py
    N)Config   )ExportersTestsBase   )get_exporterexportExporterNameErrorExporterDisabledErrorget_export_names)Exporter)PythonExporterc                   @   sX   e Zd 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S )
TestExportz%Contains test functions for export.pyc              
   C   sD   zt d}t||   W n$ ty> } zW Y d}~n
d}~0 0 dS )zM
        Is the right error thrown when a bad template name is used?
        Z
not_a_nameN)r   r   _get_notebookr   )selfexportere r   Dlib/python3.9/site-packages/nbconvert/exporters/tests/test_export.pytest_export_wrong_name   s
    z!TestExport.test_export_wrong_namec                 C   sJ   t dddii}tt td|d W d   n1 s<0    Y  dS )zU
        Trying to use a disabled exporter should raise ExporterDisbledError
        ZNotebookExporterZenabledFnotebook)configN)r   pytestZraisesr	   r   )r   r   r   r   r   test_export_disabled&   s    zTestExport.test_export_disabledc                 C   s.   t d}t||  \}}t|dks*J dS )z9
        Can a notebook be exported by filename?
        pythonr   N)r   r   r   len)r   r   output	resourcesr   r   r   test_export_filename/   s    zTestExport.test_export_filenamec                 C   sd   t |  d2}t|d}td}t||\}}W d   n1 sF0    Y  t|dks`J dS )zG
        Can a notebook be exported by a notebook node handle?
        r   r   Nr   )openr   nbformatreadr   r   r   )r   fr   r   r   r   r   r   r   test_export_nbnode8   s
    ,zTestExport.test_export_nbnodec                 C   sX   t |  d&}td}t||\}}W d   n1 s:0    Y  t|dksTJ dS )z<
        Can a notebook be exported by a filesteam?
        r   r   Nr   )r    r   r   r   r   )r   r#   r   r   r   r   r   r   test_export_filestreamC   s    ,z!TestExport.test_export_filestreamc                 C   s(   t t |  \}}t|dks$J dS )zL
        Can a notebook be exported using an instanciated exporter?
        r   Nr   r   r   r   r   r   r   r   r   r   test_export_using_exporterM   s    z%TestExport.test_export_using_exporterc                 C   s&   t t|  \}}t|dks"J dS )zJ
        Can a notebook be exported using an exporter class type?
        r   Nr&   r'   r   r   r    test_export_using_exporter_classU   s    z+TestExport.test_export_using_exporter_classc                 C   s*   t t|  i d\}}t|dks&J dS )zP
        Can a notebook be exported along with a custom resources dict?
        )r   r   Nr&   r'   r   r   r   test_export_resources]   s    z TestExport.test_export_resourcesc                 C   s.   zt d|  \}}W n ty(   Y n0 dS )zG
        Is the right error thrown if no exporter is provided?
        N)r   r   	TypeErrorr'   r   r   r   test_no_exportere   s    zTestExport.test_no_exporterN)__name__
__module____qualname____doc__r   r   r   r$   r%   r(   r)   r*   r,   r   r   r   r   r      s   		
r   c                  C   sl   t jt jtjjd} tjd|  dt	 v s6J z&t
d}t|tsRJ |W tjd= n
tjd= 0 d S )NZexporter_entrypointr   Zentrypoint_test)ospathjoindirname	nbconvertZtests__file__sysinsertr
   r   
issubclassr   )pclsr   r   r   test_get_exporter_entrypointn   s    r<   )r0   r1   r7   r!   Znbconvert.testsr5   r   Ztraitlets.configr   baser   r   r   r   r	   r
   r   r   r   r   r   r<   r   r   r   r   <module>   s   W