a
    7Ub                     @   s|   d 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	 d	d
l
mZ d	dlmZmZ G dd de	ZG dd deZdS )z#
Module with tests for exporter.py
    N)Config)patch   )ExportersTestsBase   )Preprocessor   Exporter)get_export_namesExporterDisabledErrorc                   @   s   e Zd ZdZdd ZdS )PizzaPreprocessorzdSimple preprocessor that adds a 'pizza' entry to the NotebookNode.  Used 
    to test Exporter.
    c                 C   s   d|d< ||fS )Ncheesepizza )selfZnb	resourcesr   r   Flib/python3.9/site-packages/nbconvert/exporters/tests/test_exporter.py
preprocess$   s    zPizzaPreprocessor.preprocessN)__name__
__module____qualname____doc__r   r   r   r   r   r      s   r   c                   @   s@   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S )TestExporterz'Contains test functions for exporter.pyc                 C   s
   t   dS )zCan an Exporter be constructed?Nr	   )r   r   r   r   test_constructor-   s    zTestExporter.test_constructorc                 C   s*   t  }||  \}}t|ts&J dS )z!Can an Exporter export something?N)r
   from_filename_get_notebook
isinstancedict)r   exporternotebookr   r   r   r   test_export2   s    zTestExporter.test_exportc                 C   sD   t ddt gii}t|d}||  \}}| |d d dS )zDo preprocessors work?r
   Zpreprocessorsconfigr   r   N)r   r   r
   r   r   assertEqual)r   r#   r   r    r   r   r   r   test_preprocessor9   s    
zTestExporter.test_preprocessorc                 C   s(   t dddii}t }| d|v  dS )z#Can we disable a specific importer?r
   enabledFN)r   r   ZassertFalser   r#   export_namesr   r   r   test_get_export_names_disable@   s    z*TestExporter.test_get_export_names_disablec                 C   s2   t ddiddid}t|d}| |dg dS )z5Can we disable all exporters then enable a single oner&   FTr
   ZNotebookExporterr"   r    N)r   r   r$   r'   r   r   r   r)   F   s    
c                 C   s   t ddiddid}dtjd< td0}t|d}|  | |d	g W d
   n1 s^0    Y  tjd= t|d}| |d	g d
S )z
        Does get_export_names behave correctly with respect to
        NBCONVERT_DISABLE_CONFIG_EXPORTERS being set in the
        environment?
        r&   FTr*   1Z"NBCONVERT_DISABLE_CONFIG_EXPORTERSz%nbconvert.exporters.base.get_exporterr"   r    N)r   osenvironr   r   Zassert_not_calledZassertNotEqualr$   )r   r#   Zexpr(   r   r   r   *test_get_exporter_disable_config_exportersO   s    


,
z7TestExporter.test_get_exporter_disable_config_exportersN)	r   r   r   r   r   r!   r%   r)   r.   r   r   r   r   r   )   s   	r   )r   r,   Ztraitlets.configr   Zunittest.mockr   baser   Zpreprocessors.baser   r   r
   r   r   r   r   r   r   r   r   <module>   s   
