
    :Mcyi                         d 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	Z	 ddl
mZ ddlmZ d	d
lmZ  G d de          Z G d de          ZdS )zTest NbConvertApp    N)TemporaryDirectorycheck_help_all_output)HTMLExporter   )PostProcessorBase)onlyif_cmds_exist   )	TestsBasec                       e Zd Zd ZdS )	DummyPostc                 *    t          d|z             d S )NzDummy:%s)print)selffilenames     Alib/python3.11/site-packages/nbconvert/tests/test_nbconvertapp.pypostprocesszDummyPost.postprocess   s    j8#$$$$$    N)__name__
__module____qualname__r    r   r   r   r      s#        % % % % %r   r   c                      e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Z edd          d             Zej        j        d             Z edd          d             Zd Z ed          d             Z ed          d             Z ed          d             Zd Zd Zd Zd Zd Zd Z edd          d             Zej                             e!j"        dk    d          d             Z#d  Z$d! Z%d" Z&d# Z'd$ Z(d% Z)d& Z*d' Z+d( Z,d) Z-d* Z. edd          d+             Z/ ed          d,             Z0 ed          d-             Z1 ed          d.             Z2d/ Z3d0 Z4d1 Z5d2 Z6d3 Z7d4 Z8d5S )6TestNbConvertAppz Collection of NbConvertApp testsc                     |                                  5  |                     dd          \  }}|                     d|           ddd           dS # 1 swxY w Y   dS )z-Will help show if no notebooks are specified?--log-level 0Tignore_return_codez
--help-allNcreate_temp_cwd	nbconvertassertInr   outerrs      r   test_notebook_helpz#TestNbConvertApp.test_notebook_help    s    !!## 	- 	-~~o$~OOHCMM,,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   1AAAc                 $    t          d           dS )z"ipython nbconvert --help-all worksr!   Nr   r   s    r   test_help_outputz!TestNbConvertApp.test_help_output&   s    k*****r   c                    |                      dg          5  |                     d           t          j                            d          sJ t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )z=
        Do search patterns work for notebook names?
        notebook*.ipynbz!--to python *.ipynb --log-level 0notebook1.pynotebook2.pyNr    r!   ospathisfiler(   s    r   	test_globzTestNbConvertApp.test_glob*   s     !!#4"566 	2 	2NN>???7>>.111117>>.111111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2   AA==BBc                    |                                  5  |                     dgd           |                     dt          j                            dd          z              t          j                            t          j                            dd                    sJ t          j                            t          j                            dd                    sJ 	 ddd           dS # 1 swxY w Y   dS )	zJ
        Do search patterns work for subdirectory notebook names?
        r+   subdir/z--to python --log-level 0 subdir*.ipynbr,   r-   Nr    copy_files_tor!   r/   r0   joinr1   r(   s    r   test_glob_subdirz!TestNbConvertApp.test_glob_subdir3   s(    !!## 	J 	J 12I>>>NN7"',,xQZ:[:[[\\\7>>"',,x"H"HIIIII7>>"',,x"H"HIIIIII		J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J   CC//C36C3c                    |                                  5  |                     dgd           |                     dt          j                            dd          z              t          j                            d          sJ t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )	z'build_directory affects export locationr+   r5   z)--to python --log-level 0 --output-dir . r6   r7   r,   r-   Nr8   r(   s    r   test_build_dirzTestNbConvertApp.test_build_dir=   s    !!## 	2 	2 12I>>>NN;bgll8U^>_>__   7>>.111117>>.111111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   BB33B7:B7c                    |                                  5  |                     dgd           |                     dt          j                            dd          z              t          j                            t          j                            dd                    sJ t          j                            t          j                            dd                    sJ 	 ddd           dS # 1 swxY w Y   dS )z|
        Test that nbconvert can convert file using a full qualified name for a
        package, import and use it.
        r+   r6   z=--to nbconvert.tests.fake_exporters.MyExporter --log-level 0 r7   znotebook1.test_extznotebook2.test_extNr8   r(   s    r    test_convert_full_qualified_namez1TestNbConvertApp.test_convert_full_qualified_nameG   s4   
 !!## 	P 	P 12H===NNO',,x334   7>>"',,x9M"N"NOOOOO7>>"',,x9M"N"NOOOOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Pr<   c                    |                      dg          5  |                     d           t          j                            d          rJ t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )z2
        Do explicit notebook names work?
        r+   z#--log-level 0 --to python notebook2r,   r-   Nr.   r(   s    r   test_explicitzTestNbConvertApp.test_explicitU   s     !!#4"566 	2 	2NN@AAAw~~n555557>>.111111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2r3   c                    |                      dg          5 }|                     d           t          j                            d          sJ t          dd          5 }t          j        |d          }|j        D ]}d|v r|j	        g k    sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )	z'
        Can we clear outputs?
        r+   z--clear-output notebook1notebook1.ipynbutf8encoding   outputsN)
r    r!   r/   r0   r1   opennbformatreadcellsrI   )r   tdfnbcells        r   test_clear_outputz"TestNbConvertApp.test_clear_output^   sY    !!#4"566 	2"NN56667>>"344444'&999 2Q]1a((H 2 2D D( 2#|r111122 2 2 2 2 2 2 2 2 2 2 2 2 2 2	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s6   AB51BB5B!	!B5$B!	%B55B9<B9c                 l   |                      dg          5  t                      5 }t          j                            |d          }d}t          |d          5 }|                    |           ddd           n# 1 swxY w Y   |                     d|z             t          j                            d          sJ t          dd	          5 }|	                                }ddd           n# 1 swxY w Y   ||k    sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )
z'--template-file '/path/to/template.tpl'r+   zmytemplate.tplsuccess!wN4--log-level 0 notebook2 --to html --template-file %snotebook2.htmlrE   rF   )
r    r   r/   r0   r:   rJ   writer!   r1   rL   )r   rN   templatetest_outputrO   texts         r   test_absolute_template_filez,TestNbConvertApp.test_absolute_template_filel   s'   !!#4"566 		' 		'8J8L8L 		'PRw||B(899H$Kh$$ %$$$% % % % % % % % % % % % % % %NNQT\\]]]7>>"233333&888  Avvxx                             ;&&&&&		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		' 		's}   D)3DA;/D;A??DA?ADC1%D1C55D8C59DD)D	D)D	D))D-0D-c                 H   |                      dg          5  t          j        d           t          j                            dd          }d}t          |d          5 }|                    |           ddd           n# 1 swxY w Y   |                     d|z             t          j                            d          sJ t          dd	
          5 }|	                                }ddd           n# 1 swxY w Y   ||k    sJ 	 ddd           dS # 1 swxY w Y   dS )z(Test --template-file 'relative/path.tpl'r+   relativezpath.tplrT   rU   NrV   rW   rE   rF   )
r    r/   mkdirr0   r:   rJ   rX   r!   r1   rL   )r   rY   rZ   rO   r[   s        r   test_relative_template_filez,TestNbConvertApp.test_relative_template_filey   s   !!#4"566 
	' 
	'HZ   w||J
;;H$Kh$$ %$$$% % % % % % % % % % % % % % %NNQT\\]]]7>>"233333&888  Avvxx                             ;&&&&&
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	's[   ADB 4D B	DB	ADC6*D6C:	:D=C:	>DDDpandocxelatexc                     |                      dg          5  t          j        dd           |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zS
        Generate PDFs with graphics if notebooks have spaces in the name?
        notebook2.ipynbznotebook with spaces.ipynbzd--log-level 0 --to pdf "notebook with spaces" --PDFExporter.latex_count=1 --PDFExporter.verbose=Trueznotebook with spaces.pdfN)r    r/   renamer!   r0   r1   r(   s    r   test_filename_spacesz%TestNbConvertApp.test_filename_spaces   s    
 !!#4"566 	> 	>I')EFFFNN.   7>>"<======	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   AA11A58A5c                     |                      dg          5  |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zE
        Generate PDFs if chromium allowed to be downloaded?
        rd   z1--to webpdf --allow-chromium-download "notebook2"notebook2.pdfNr.   r(   s    r   test_webpdf_with_chromiumz*TestNbConvertApp.test_webpdf_with_chromium   s    
 !!#4"566 	3 	3NNNOOO7>>/222222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3   7AA #A c                     |                      dg          5  |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zT
        Check to see if pdfs compile, even if strikethroughs are included.
        rd   zY--log-level 0 --to pdf "notebook2" --PDFExporter.latex_count=1 --PDFExporter.verbose=Truerh   Nr.   r(   s    r   test_pdfzTestNbConvertApp.test_pdf   s    
 !!#4"566 	3 	3NN.   7>>/222222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3rj   c                     |                      dg          5  |                     d          \  }}|                     d|           ddd           dS # 1 swxY w Y   dS )zDo post processors work?rD   zV--log-level 0 --to python notebook1 --post nbconvert.tests.test_nbconvertapp.DummyPostzDummy:notebook1.pyNr   r#   s      r   test_post_processorz$TestNbConvertApp.test_post_processor   s    !!#4"566 	5 	5~~h HC MM.444		5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   /AAAc                    |                      dg          5  |                     d           t          j                            d          sJ t          d          5 }|                                }ddd           n# 1 swxY w Y   |                     d           t          j                            d          sJ t          dd          5 }|                                }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                     |                    d	          |                    d
                     |                     |                    d	          |                    d
                     dS )zCheck for extra CR charactersrd   z"--log-level 0 --to latex notebook2znotebook2.texNz!--log-level 0 --to html notebook2rW   rE   rF   z
)	r    r!   r/   r0   r1   rJ   rL   assertEqualcount)r   rO   texhtmls       r   test_spurious_crz!TestNbConvertApp.test_spurious_cr   s    !!#4"566 	  	 NN?@@@7>>/22222o&& !ffhh              NN>???7>>"233333&888  Avvxx                             	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	4#))F*;*;<<<D))4::f+=+=>>>>>s[   ADA>2D>B	DB	A
DC1%D1C5	5D8C5	9DDDc                 T   |                      dg          5  |                     d           t          j                            d          sJ t          dd          5 }d|                                vsJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z)Is embedded png data well formed in HTML?rd   z6--log-level 0 --to HTML notebook2.ipynb --template labrW   rE   rF   zdata:image/png;base64,b'Nr    r!   r/   r0   r1   rJ   rL   r   rO   s     r   test_png_base64_html_okz(TestNbConvertApp.test_png_base64_html_ok   sT    !!#4"566 	B 	BNNSTTT7>>"233333&888 BA1AAAAAB B B B B B B B B B B B B B B	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B6   ABB9BB			BB		BB!$B!c                 T   |                      dg          5  |                     d           t          j                            d          sJ t          dd          5 }d|                                v sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z+
        Do export templates work?
        rd   z)--log-level 0 --to slides notebook2.ipynbznotebook2.slides.htmlrE   rF   z/reveal.cssNrw   rx   s     r   test_templatezTestNbConvertApp.test_template   s0   
 !!#4"566 	1 	1NNFGGG7>>"9:::::-??? 11$000001 1 1 1 1 1 1 1 1 1 1 1 1 1 1	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1rz   c                 >   |                      dg          5  |                     d           t          j                            d          sJ |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )ztest --output=outputfile[.ext]rD   z8--log-level 0 --to python notebook1.ipynb --output nb.pyznb.pyz6--log-level 0 --to python notebook1.ipynb --output nb2znb2.pyN)r    r!   r/   r0   existsr(   s    r   test_output_extz TestNbConvertApp.test_output_ext   s    !!#4"566 	, 	,NNUVVV7>>'*****NNSTTT7>>(++++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,   A-BBBc                    |                      dg          5  |                     d           t          j                            d          sJ t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )z[
        Can a search pattern be used along with matching explicit notebook names?
        r+   zA--log-level 0 --to python *.ipynb notebook1.ipynb notebook2.ipynbr,   r-   Nr.   r(   s    r   test_glob_explicitz#TestNbConvertApp.test_glob_explicit        !!#4"566 	2 	2NN^___7>>.111117>>.111111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2r3   c                    |                      dg          5  |                     d           t          j                            d          sJ t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zY
        Can explicit notebook names be used and then a matching search pattern?
        r+   zA--log-level 0 --to=python notebook1.ipynb notebook2.ipynb *.ipynbr,   r-   Nr.   r(   s    r   test_explicit_globz#TestNbConvertApp.test_explicit_glob   r   r3   c                    |                      ddg          5  |                     d           t          j                            d          sJ t          j                            d          rJ 	 ddd           dS # 1 swxY w Y   dS )z/
        Does the default config work?
        r+   jupyter_nbconvert_config.pyr   r,   r-   Nr.   r(   s    r   test_default_configz$TestNbConvertApp.test_default_config   s     !!#46S"TUU 	6 	6NN?+++7>>.11111w~~n555555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6   AA>>BBc                    |                      g d          5  |                     d           t          j                            d          rJ t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )z7
        Can the default config be overridden?
        )r+   r   zoverride.pyz$--log-level 0 --config="override.py"r,   r-   Nr.   r(   s    r   test_override_configz%TestNbConvertApp.test_override_config   s     !!MMM
 
 	2 	2 NNABBBw~~n555557>>.111111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2r   c                     |                                  5  |                     d           |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )z5
        Can notebook names include accents?
           nb1_análisis.ipynbz--log-level 0 --to Python nb1_*u   nb1_análisis.pyNr    create_empty_notebookr!   r/   r0   r1   r(   s    r   test_accents_in_filenamez)TestNbConvertApp.test_accents_in_filename  s     !!## 	6 	6&&'<===NN<===7>>"4555555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6   AA//A36A3c                     |                                  5  |                     d           |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zJ
        Generate PDFs if notebooks have an accent in their name?
        r   zU--log-level 0 --to pdf "nb1_*" --PDFExporter.latex_count=1 --PDFExporter.verbose=Trueu   nb1_análisis.pdfNr   r(   s    r   test_filename_accent_pdfz)TestNbConvertApp.test_filename_accent_pdf  s    
 !!## 	7 	7&&'<===NN.  
 7>>"5666666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7r   ntz-CLI parsing does not work the same on Windows)reasonc                 >   |                      dg          5  |                     d           t          j                            d          sJ |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zF
        Verify that an extension in the cwd can be imported.
        zhello.pyempty.ipynbz?empty --to html --NbConvertApp.writer_class='hello.HelloWriter'z	hello.txtN)r    r   r/   r0   r1   r!   r(   s    r   test_cwd_pluginz TestNbConvertApp.test_cwd_plugin  s    
 !!:,// 	/ 	/&&}5557>>*-----NN\]]]7>>+......		/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/r   c                     |                                  5  |                     d           |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )z:
        Verify that the output suffix is applied
        r   zempty.ipynb --to notebookempty.nbconvert.ipynbNr   r(   s    r   test_output_suffixz#TestNbConvertApp.test_output_suffix)  s     !!## 	; 	;&&}555NN67777>>"9::::::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;r   c                     |                                  5  |                     d           t          j        d           |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )z>
        Verify that the output suffix is not applied
        r   outputz>empty.ipynb --to notebook --FilesWriter.build_directory=outputzoutput/empty.ipynbN)r    r   r/   r_   r!   r0   r1   r(   s    r   test_different_build_dirz)TestNbConvertApp.test_different_build_dir2  s     !!## 	8 	8&&}555HXNN[\\\7>>"6777777		8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   A BB
Bc                 |   |                                  5  |                     d           |                     d           t          j                            d          sJ t          j                            d          rJ t          j                            d          rJ 	 ddd           dS # 1 swxY w Y   dS )z@
        Verify that the notebook is converted in place
        r   zempty.ipynb --inplacer   z
empty.htmlNr   r(   s    r   test_inplacezTestNbConvertApp.test_inplace<  s     !!## 	4 	4&&}555NN23337>>-00000w~~&=>>>>>w~~l333333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   BB11B58B5c                 d   |                      dg          5  |                     d           t          j                            d          sJ t          dd          5 }|                                }d|vsJ d|vsJ 	 ddd           n# 1 swxY w Y   |                     d	           t          j                            d          sJ t          dd          5 }|                                }d|v sJ d|v sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )
zM
        Verify that the html has no prompts when given --no-prompt.
        rD   z3notebook1.ipynb --log-level 0 --no-prompt --to htmlnotebook1.htmlrE   rF   	In&nbsp;[Out[6]N'notebook1.ipynb --log-level 0 --to htmlrw   r   rO   r[   text2s       r   test_no_promptzTestNbConvertApp.test_no_promptG  s    !!#4"566 	) 	)NNPQQQ7>>"233333&888 ,Avvxx"$....t+++++, , , , , , , , , , , , , , , NNDEEE7>>"233333&888 )A"e++++5((((() ) ) ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s[   AD%!BD%B	D%B	A
D%!DD%D	D%D	D%%D),D)c                 d   |                      dg          5  |                     d           t          j                            d          sJ t          dd          5 }|                                }d|v sJ d|v sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )	zQ
        Verify that the html has tags in cell attributes if they exist.
        znotebook_tags.ipynbz+notebook_tags.ipynb --log-level 0 --to htmlznotebook_tags.htmlrE   rF   z)celltag_mycelltag celltag_mysecondcelltagcelltag_mymarkdowncelltagNrw   r   rO   r[   s      r   test_cell_tag_outputz%TestNbConvertApp.test_cell_tag_outputY  sF    !!#8"9:: 	; 	;NNHIII7>>"677777*V<<< ;vvxxBdJJJJ2d:::::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s6   AB%!BB%B	B%B	B%%B),B)c                 |   |                      dg          5  |                     d           t          j                            d          sJ t          dd          5 }|                                }d|vsJ d|vsJ d|vsJ 	 d	d	d	           n# 1 swxY w Y   |                     d
           t          j                            d          sJ t          dd          5 }|                                }d|v sJ d|v sJ d|v sJ 	 d	d	d	           n# 1 swxY w Y   d	d	d	           d	S # 1 swxY w Y   d	S )zJ
        Verify that the html has no input when given --no-input.
        rD   z2notebook1.ipynb --log-level 0 --no-input --to htmlr   rE   rF   r   r   z<span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">'x y z'</span><span class="p">)</span>Nr   rw   r   s       r   test_no_inputzTestNbConvertApp.test_no_inpute  sN    !!#4"566 $	 $	NNOPPP7>>"233333&888 Avvxx"$....t++++	/     	                NNDEEE7>>"233333&888 A"e++++5((((	/     	              +$	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	 $	s[   AD1'BD1B	D1B	A
D1%'DD1D	D1 D	!D11D58D5c                    |                      dg          5  |                     d          \  }}|                     d          \  }}|                     d          \  }}d|vsJ d|vsJ d|vsJ d|vsJ d|v sJ d|v sJ t          j        t                    5  |                     d           ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )	z
        Verify that conversion is aborted with '--execute' if an error is
        encountered, but that conversion continues if '--allow-errors' is
        used in addition.
        znotebook3*.ipynbz'--to markdown --stdout notebook3*.ipynbz6--to markdown --allow-errors --stdout notebook3*.ipynbz@--execute --allow-errors --to markdown --stdout notebook3*.ipynb2342z1--execute --to markdown --stdout notebook3*.ipynbN)r    r!   pytestraisesOSError)r   output1_output2output3s        r   test_allow_errorsz"TestNbConvertApp.test_allow_errors  s    !!#5"677 	T 	T 9 JGQ H JGQ R JGQ w&&&&w&&&&w&&&&w&&&& 7?"""7?""" w'' T TRSSST T T T T T T T T T T T T T T3	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	Ts6   BCB?3C?C	CC	CCCc                     |                      dg          5  |                     dd          \  }}d|v sJ d|v sJ d|v sJ 	 ddd           dS # 1 swxY w Y   dS )	zg
        Verify that the stderr output contains the traceback of the cell execution exception.
        znotebook3_with_errors.ipynbz<--execute --to markdown --stdout notebook3_with_errors.ipynbTr   z#print("Some text before the error")z4raise RuntimeError("This is a deliberate exception")z,RuntimeError: This is a deliberate exceptionNr    r!   )r   r   error_outputs      r   test_errors_print_tracebackz,TestNbConvertApp.test_errors_print_traceback  s     !!#@"ABB 	R 	R"nnN#' -  OA| 9LHHHHI\YYYYA\QQQQQ	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	Rs   -AAAc                 T   |                      dg          5  |                     d          \  }}d|vsJ d|v sJ 	 ddd           n# 1 swxY w Y   |                      dg          5  |                     d          \  }}d|v sJ d|v sJ 	 ddd           dS # 1 swxY w Y   dS )	z
        Verify that input cells use fenced code blocks with the language
        name in nb.metadata.kernelspec.language, if that exists
        znotebook1*.ipynbz&--to markdown --stdout notebook1.ipynb	```python```Nznotebook_jl*.ipynbz(--to markdown --stdout notebook_jl.ipynbz```juliar   )r   r   r   r   s       r    test_fenced_code_blocks_markdownz1TestNbConvertApp.test_fenced_code_blocks_markdown  sg   
 !!#5"677 	$ 	$ (PQQJGQg----G#####	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ !!#7"899 	$ 	$(RSSJGQ((((G#####		$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s#   %A		AA*%BB!$B!c                 L   |                      dg          5  t          d          5 }|                                                                }|                     d|          \  }}ddd           n# 1 swxY w Y   d|vsJ d|v sJ 	 ddd           dS # 1 swxY w Y   dS )zH
        Verify that conversion can be done via stdin to stdout
        rD   z--to markdown --stdin --stdoutstdinNr   r   )r    rJ   rL   encoder!   )r   rO   notebookr   r   s        r   !test_convert_from_stdin_to_stdoutz2TestNbConvertApp.test_convert_from_stdin_to_stdout  sJ    !!#4"566 	$ 	$'(( ^A6688??,,!^^,LT\^]]
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ g----G#####	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s5   BAA4(B4A8	8B;A8	<BB Bc                    |                      dg          5  t          d          5 }|                                                                }|                     d|           ddd           n# 1 swxY w Y   t
          j                            d          sJ t          dd          5 }|                                }d|vsJ d	|v sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )
z?
        Verify that conversion can be done via stdin.
        rD   z--to markdown --stdinr   Nznotebook.mdrE   rF   r   r   )r    rJ   rL   r   r!   r/   r0   r1   )r   rO   r   r   s       r   test_convert_from_stdinz(TestNbConvertApp.test_convert_from_stdin  s    !!#4"566 	( 	('(( HA6688??,,6hGGGH H H H H H H H H H H H H H H 7>>-00000mf555 (&&(("'1111'''''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(sX   C4>A1%C41A5	5C48A5	95C4.!CC4C 	 C4#C 	$C44C8;C8c                     |                      ddg          5  |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zG
        Generate PDFs with an image linked in a markdown cell
        zlatex-linked-image.ipynbztestimage.pngz!--to pdf latex-linked-image.ipynbzlatex-linked-image.pdfNr.   r(   s    r   test_linked_imagesz#TestNbConvertApp.test_linked_images  s    
 !!#="OPP 	< 	<NN>???7>>":;;;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<   7AA!$A!c                     |                      ddg          5  |                     d           t          j                            d          sJ 	 ddd           dS # 1 swxY w Y   dS )zf
        Verify that latex conversion succeeds
        with a notebook with an embedded .jpeg
        notebook4_jpeg.ipynbcontainerized_deployments.jpegz--to latex notebook4_jpeg.ipynbznotebook4_jpeg.texNr.   r(   s    r   test_embedded_jpegz#TestNbConvertApp.test_embedded_jpeg  s     !!#9;["\]] 	8 	8NN<===7>>"6777777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8r   c                 X   |                      dg          5  |                     d           t          j                            d          sJ t          dd          5 }|                                }d|v sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )zs
        Check to see if markdown conversion embeds PNGs,
        even if an (unsupported) PDF is present.
        zmarkdown_display_priority.ipynbz=--log-level 0 --to markdown "markdown_display_priority.ipynb"zmarkdown_display_priority.mdrE   rF   zAmarkdown_display_priority_files/markdown_display_priority_0_1.pngNrw   )r   rO   markdown_outputs      r   test_markdown_display_priorityz/TestNbConvertApp.test_markdown_display_priority  s@    !!#D"EFF 	% 	%NNZ[[[7>>"@AAAAA4vFFF %!"#&&((W$% % % % %% % % % % % % % % % % % % % %	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%6   ABB;BB	BB	BB#&B#c                    d }|                      ddg          5  t                      }t          j                            |j        d          }|                     d                    |                      ||          sJ |                                 ddd           n# 1 swxY w Y   |                      ddg          5  |                     d            |d          sJ 	 ddd           n# 1 swxY w Y   |                      ddg          5  |                     d	            |d
          sJ 	 ddd           dS # 1 swxY w Y   dS )zF
        Check if figure files are copied to configured path.
        c                 L    t          t          j        |                     dk    S )Nr   )lenr/   listdir)r0   s    r   
fig_existszFTestNbConvertApp.test_write_figures_to_custom_path.<locals>.fig_exists  s    rz$''((1,,r   r   r   fileszN--log-level 0 notebook4_jpeg.ipynb --to rst --NbConvertApp.output_files_dir={}NzR--log-level 0 notebook4_jpeg.ipynb --to rst --NbConvertApp.output_files_dir=outputr   z+--log-level 0 notebook4_jpeg.ipynb --to rstnotebook4_jpeg_files)	r    r   r/   r0   r:   namer!   formatcleanup)r   r   
output_dirr0   s       r   !test_write_figures_to_custom_pathz2TestNbConvertApp.test_write_figures_to_custom_path  sK   	- 	- 	- !!#9;["\]] 	! 	!+--J7<<
99DNN55;VD\\   :d#####   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! !!#9;["\]] 	( 	(NN9   :h''''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( !!#9;["\]] 	6 	6NNHIII:4555555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s6   A=B$$B(+B(#C66C:=C:#E		EEc                 X   |                      dg          5  |                     d           t          j                            d          sJ t          dd          5 }|                                }d|v sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )Check jupyter widgets URLWidget_List.ipynbz)Widget_List.ipynb --log-level 0 --to htmlzWidget_List.htmlrE   rF   ^var widgetRendererSrc = 'https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js';Nrw   r   s      r   test_widgets_from_nbconvertz,TestNbConvertApp.test_widgets_from_nbconvert,  s@    !!#6"788 	 	NNFGGG7>>"455555(6::: avvxxt                 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   c                 n   |                      dg          5 }t          t          j                            |d                    5 }t          j        |d          }ddd           n# 1 swxY w Y   t                                          |          \  }}d|v sJ 	 ddd           dS # 1 swxY w Y   dS )r   r   rH   Nr   )	r    rJ   r/   r0   r:   rK   rL   r   from_notebook_node)r   tmpdirrO   rP   r   r   s         r   test_widgets_from_htmlexporterz/TestNbConvertApp.test_widgets_from_htmlexporter9  s<   !!#6"788 		Fbgll6+>??@@ )A]1a(() ) ) ) ) ) ) ) ) ) ) ) ) ) ) %99"==IFA q   		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		s5   .B*A'B*'A+	+B*.A+	/-B**B.1B.c                    |                      ddg          5  |                     d           t          j                            d          sJ t          dd          5 }|                                }d|v sJ d|v sJ |                    d	          d
k    sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z<Check that the HTMLExporter does not embed images by defaultnotebook5_embed_images.ipynbr   z.notebook5_embed_images --log-level 0 --to htmlnotebook5_embed_images.htmlrE   rF    ./containerized_deployments.jpeg&src='./containerized_deployments.jpeg'data:image/jpeg;base64r   Nr    r!   r/   r0   r1   rJ   rL   rr   r   s      r   &test_not_embedding_images_htmlexporterz7TestNbConvertApp.test_not_embedding_images_htmlexporterF  s    !!+-MN
 
 		A 		A NNKLLL7>>"?@@@@@3fEEE Avvxx9TAAAA?4GGGGzz":;;q@@@@@	A A A A A A A A A A A A A A A		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A6   AC <B)C)B-	-C0B-	1CCCc                    |                      ddg          5  |                     d           t          j                            d          sJ t          dd          5 }|                                }d|vsJ d|vsJ |                    d	          d
k    sJ 	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z3Check that the HTMLExporter embeds images if neededr   r   z=notebook5_embed_images --log-level 0 --to html --embed-imagesr   rE   rF   r   r   r      Nr   r   s      r   "test_embedding_images_htmlexporterz3TestNbConvertApp.test_embedding_images_htmlexporterT  s    !!+-MN
 
 		A 		A NNZ[[[7>>"?@@@@@3fEEE Avvxx9EEEE?tKKKKzz":;;q@@@@@	A A A A A A A A A A A A A A A		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		A 		Ar   c                    d}|                      | dg          5  |                     | d           t          j                            | d          sJ t          | dd          5 }|                                }d|v sJ d|v sJ 	 d	d	d	           n# 1 swxY w Y   d	d	d	           d	S # 1 swxY w Y   d	S )
zCheck jupyter widgets renderUnexecuted_widgetz.ipynbz(.ipynb --execute --log-level 0 --to html.htmlrE   rF   8<script type="application/vnd.jupyter.widget-view+json">9<script type="application/vnd.jupyter.widget-state+json">Nrw   )r   notebookNamerO   r[   s       r   #test_execute_widgets_from_nbconvertz4TestNbConvertApp.test_execute_widgets_from_nbconvertb  s   *!!l#:#:#:";<< 	[ 	[NNlTTTUUU7>>\"8"8"899999,,,v>>> [!vvxxQUYYYYYRVZZZZZZ[ [ [ [ [ [ [ [ [ [ [ [ [ [ [	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[ 	[s6   AB3-!BB3B	B3"B	#B33B7:B7c                    d}|                      | dg          5  |                     d           || dfD ]s}t          j                            | d          sJ t          | dd          5 }|                                }d|v sJ d	|v sJ 	 d
d
d
           n# 1 swxY w Y   t	 d
d
d
           d
S # 1 swxY w Y   d
S )z5Check jupyter widgets render in case of batch convertr   r7   z)*.ipynb --execute --log-level 0 --to html_2r   rE   rF   r   r   Nrw   )r   r   r   rO   r[   s        r   test_execute_multiple_notebooksz0TestNbConvertApp.test_execute_multiple_notebooksm  s   *!!l#;#;#;"<== 	_ 	_NNFGGG%,':':':; _ _w~~nnn55555T...6::: _a6688DUY]]]]]VZ^^^^^^_ _ _ _ _ _ _ _ _ _ _ _ _ _ __	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_s6   AB;3!B!B;!B%%B;(B%)B;;B?B?N)9r   r   r   __doc__r&   r)   r2   r;   r>   r@   rB   rR   r\   r`   r	   rf   r   marknetworkri   rl   rn   ru   ry   r|   r   r   r   r   r   r   r   skipifr/   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      s        **- - -+ + +2 2 2J J J2 2 2P P P2 2 22 2 2' ' '' ' ' x++> > ,+> [3 3 3 x++3 3 ,+35 5 5 x  ? ? ! ? x  B B ! B x  1 1 ! 1, , ,2 2 22 2 26 6 6	2 	2 	26 6 6 y(++7 7 ,+7 [40_``/ / a`/; ; ;8 8 8	4 	4 	4) ) )$
; 
; 
;( ( (T T  T  TDR R R$ $ $$	$ 	$ 	$( ( ( x++< < ,+< x  8 8 ! 8 x  % % ! % x  6 6 ! 6@    A A AA A A	[ 	[ 	[_ _ _ _ _r   r   )r   r/   tempfiler   rK   r   traitlets.tests.utilsr   nbconvert.exportersr   postprocessorsr   tests.utilsr	   baser   r   r   r   r   r   <module>r
     s    
 
			 ' ' ' ' ' '   7 7 7 7 7 7 , , , , , , . . . . . . + + + + + +      % % % % %! % % %
[	_ [	_ [	_ [	_ [	_y [	_ [	_ [	_ [	_ [	_r   