
    -Ph]                         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 ddlmZmZ d	d
lmZmZ  G d de          ZdS )    N)Path)dedent)mock)	CliRunner)TestCase   )DEFAULT_CONTENT_main   )setup_simple_projectwith_isolated_runnerc                   B   e Zd ZdZ	 	 	 	 	 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d Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Zedefd            Z edefd            Z!edefd             Z"ed!             Z#dS )#TestCliNTc                    t                      }|                                5  t          ||           dg}|t          g}||                    |           |                    t          |          }|                     dgt          j	        d                     |r|
                    d           t          d          5 }	|                     d                    |          |	                                           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     d|j                   d S )Nconfigmkdir_newsfragments123.feature.rstfoo/newsfragments z!foo/newsfragments/123.feature.rst
r   )r   isolated_filesystemr   r	   extendinvoker
   assertEqualoslistdirappendopenjoinread	exit_code)
selfcontentr   mkdiradditional_argseof_newlinerunnerargsresultfhs
             Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/towncrier/test/test_create.py_test_successzTestCli._test_success   s    '')) 	@ 	@ EJJJJ%&D*+*O,,,]]5$//F/0"*=P2Q2QRRR #r"""9:: @b  7!3!3RWWYY???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@" 	F,-----s6   B D"<D?D"D	D"D	D""D&)D&c                 2    |                      d           dS )z:Ensure file created where output directory already exists.Tr%   Nr-   r#   s    r,   test_basicszTestCli.test_basics2   s    &&&&&    c                 2    |                      d           dS )z;Ensure both file and output directory created if necessary.Fr/   Nr0   r1   s    r,   test_directory_createdzTestCli.test_directory_created6   s    '''''r3   c                     ddg}t          j        d          5 }d                    |          |_        |                     |dg           |                    dd	           d
d
d
           d
S # 1 swxY w Y   d
S )z!Create file with dynamic content.This is line 1This is line 2
click.editr   --editr$   r&   k
# Please write your news content. Lines starting with '#' will be ignored, and
# an empty message aborts.
.rst	extensionNr   patchr    return_valuer-   assert_called_once_with)r#   r$   	mock_edits      r,   test_edit_without_commentsz"TestCli.test_edit_without_comments:   s    #%56Z%% 	%)YYw%7%7I"w
KKK--N  .   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A
A00A47A4c                     ddg}d}t          j        d          5 }d                    |dd         |gz   |dd         z             |_        |                     |dg	           ddd           dS # 1 swxY w Y   dS )
z%Create file editly with ignored line.r7   r8   z# I am ignoredr9   r   Nr   r:   r;   )r   rA   r    rB   r-   )r#   r$   commentrD   s       r,   test_edit_with_commentzTestCli.test_edit_with_commentF   s    #%56"Z%% 	L%)YYwrr{gY/FQRQSQS/T%U%UI"w
KKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   A
A22A69A6c                    t          j        d          5 }d|_        t                      }|                                5  t          dd           |                    t          ddg          }|                     g t          j
        d                     |                     d|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Create file editly and abort.r9   NTr   r   r:   r   r   )r   rA   rB   r   r   r   r   r
   r   r   r   r"   )r#   rD   r(   r*   s       r,   test_edit_abortzTestCli.test_edit_abortN   sQ   Z%% 		6%)I"[[F++-- 6 6$DdKKKKu/@(.KLL  RZ0C%D%DEEE  F$4555	6 6 6 6 6 6 6 6 6 6 6 6 6 6 6		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6s5   *CA2B=1C=C	CC	CCCc                     t          j        d          5 }d|_        |                     dgt	          d          dg           |                    dd           d	d	d	           d	S # 1 swxY w Y   d	S )
z
        The temporary file extension used when editing is ``.md`` if the main filename
        also uses that extension.
        r9   r7   z                    [tool.towncrier]
                    package = "foo"
                    filename = "README.md"
                    r:   r$   r   r&   r<   z.mdr>   Nr   rA   rB   r-   r   rC   r#   rD   s     r,   test_edit_markdown_extensionz$TestCli.test_edit_markdown_extension[   s     Z%% 	%5I")*  "*
  
 
 
 --N .   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   AA((A,/A,c                     t          j        d          5 }d|_        |                     dgt	          d          dg           |                    dd           d	d	d	           d	S # 1 swxY w Y   d	S )
z
        The temporary file extension used when editing is ``.txt`` if it the main
        filename isn't ``.rst`` or ``.md``.
        r9   r7   z                    [tool.towncrier]
                    package = "foo"
                    filename = "README.FIRST"
                    r:   rL   r<   z.txtr>   NrM   rN   s     r,   test_edit_unknown_extensionz#TestCli.test_edit_unknown_extensiont   s     Z%% 	%5I")*  "*
  
 
 
 --N  .   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	rP   c                 >    d}|                      |gd|g           dS )z
        When creating a new fragment the content can be passed as a
        command line argument.
        The text editor is not invoked.
        This is a content-cr;   Nr0   )r#   content_lines     r,   test_contentzTestCli.test_content   s/     +L>D,CWXXXXXr3   c                 `    t          d          }d}|                     |gd|g|d           dS )z
        When creating a new fragment the content can be passed as a command line
        argument. The text editor is not invoked, and no eof newline is added if the
        config option is set.
        zl            [tool.towncrier]
            package = "foo"
            create_eof_newline = false
            rT   rU   F)r$   r&   r   r'   N)r   r-   )r#   r   rV   s      r,    test_content_without_eof_newlinez(TestCli.test_content_without_eof_newline   sY     
 
 +!N!<0	 	 	
 	
 	
 	
 	
r3   c                    d}ddg}t          j        d          5 }d                    |          |_        |                     |d|dg           |                    | d	d
           ddd           dS # 1 swxY w Y   dS )z
        When creating a new message, a initial content can be passed via
        the command line and continue modifying the content by invoking the
        text editor.
        zThis is a content liner7   r8   r9   r   rU   r:   r;   zl

# Please write your news content. Lines starting with '#' will be ignored, and
# an empty message aborts.
r=   r>   Nr@   )r#   rV   edit_contentrD   s       r,   test_message_and_editzTestCli.test_message_and_edit   s     0(*:;Z%% 		%)YY|%<%<I"$t\86T     -- N N N  .   		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		s   AA77A;>A;c                    t                      }t          d          }|                                5  t          |d           t	          j        d           |                    t          dg          }|                     dgt	          j	        d                     ddd           n# 1 swxY w Y   |                     d|j
                   dS )z)Ensure non-standard directories are used.zP            [tool.towncrier]
            directory = "releasenotes"
            Fr   releasenotesr   Nr   )r   r   r   r   r   r%   r   r
   r   r   r"   )r#   r(   r   r*   s       r,   test_different_directoryz TestCli.test_different_directory   s   
 
 '')) 	N 	N EJJJJH^$$$]]5+<*=>>F/0"*^2L2LMMM	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	F,-----s   A+B))B-0B-c                 
   t                      }|                                5  t                       |                     g t	          j        d                     |                    t          dg          }|                     g t	          j        d                     ddd           n# 1 swxY w Y   |                     t          |j	                  t          |j	                   |                     d|j                   dS )z;Ensure creating a path without a valid section is rejected.r   z123.foobar.rstNz2Expected filename '123.foobar.rst' to be of format)r   r   r   r   r   r   r   r
   type	exception
SystemExitassertInoutputr#   r(   r*   s      r,   test_invalid_sectionzTestCli.test_invalid_section   s7   '')) 	B 	B """R,?!@!@AAA]]5+;*<==FR,?!@!@AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	f.//V=MNNN@&-	
 	
 	
 	
 	
s   A;B**B.1B.r(   c                 &   t                       t          dd          }|                    t          dg          }|                     |j        d|j                   d |                                D             }|                     |dg           dS )z<Ensure we can still create fragments with custom extensions.foonewsfragmentsz123.feature.txtr   c                     g | ]	}|j         
S  name.0fs     r,   
<listcomp>z1TestCli.test_custom_extension.<locals>.<listcomp>       999QV999r3   Nr   r   r   r
   r   r"   re   iterdirr#   r(   	frag_pathr*   	fragmentss        r,   test_custom_extensionzTestCli.test_custom_extension   s     	00	u'8&9::)1fm<<<99Y%6%6%8%8999	%6$788888r3   c                 *   t          d           t          dd          }|                    t          dg          }|                     |j        d|j                   d |                                D             }|                     |dg           d	S )
z2Ensure changelog filename extension is used if .mdzfilename = "changes.md"extra_configri   rj   123.featurer   c                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z6TestCli.test_md_filename_extension.<locals>.<listcomp>   rs   r3   z123.feature.mdNrt   rv   s        r,   test_md_filename_extensionz"TestCli.test_md_filename_extension   s     	*CDDDD00	u}o66)1fm<<<99Y%6%6%8%8999	%5$677777r3   c                 *   t          d           t          dd          }|                    t          dg          }|                     |j        d|j                   d |                                D             }|                     |dg           dS )	zv
        When the NEWS filename has no extension, new fragments are will not have an
        extension added.
        zfilename = "RELEASE_NOTES"r{   ri   rj   r}   r   c                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z6TestCli.test_no_filename_extension.<locals>.<listcomp>  rs   r3   Nrt   rv   s        r,   test_no_filename_extensionz"TestCli.test_no_filename_extension   s     	*FGGGG00	u}o66)1fm<<<99Y%6%6%8%8999	]O44444r3   c                 f   t                       t          dd          }t          d          D ]?}|                    t          dg          }|                     |j        d|j                   @d |                                D             }|                     t          |          g d           dS )	z)Ensure we don't overwrite existing files.ri   rj      r}   r   c                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z,TestCli.test_file_exists.<locals>.<listcomp>  rs   r3   z123.feature.1.rstz123.feature.2.rstr   N
r   r   ranger   r
   r   r"   re   ru   sortedr#   r(   rw   _r*   rx   s         r,   test_file_existszTestCli.test_file_exists  s     	00	q 	A 	AA]]5=/::FV-q&-@@@@99Y%6%6%8%8999	9  	
 	
 	
 	
 	
r3   c                 j   t          d           t          dd          }t          d          D ]?}|                    t          dg          }|                     |j        d|j                   @d |                                D             }|                     t          |          g d	           d
S )zl
        Ensure we don't overwrite existing files with when not adding filename
        extensions.
        zcreate_add_extension = falser{   ri   rj   r   r}   r   c                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z3TestCli.test_file_exists_no_ext.<locals>.<listcomp>3  rs   r3   )r}   z123.feature.1z123.feature.2Nr   r   s         r,   test_file_exists_no_extzTestCli.test_file_exists_no_ext%  s     	*HIIII00	q 	A 	AA]]5=/::FV-q&-@@@@99Y%6%6%8%8999	9  	
 	
 	
 	
 	
r3   c                 f   t                       t          dd          }t          d          D ]?}|                    t          dg          }|                     |j        d|j                   @d |                                D             }|                     t          |          g d           dS )	zs
        Ensure we don't overwrite existing files when using an extension after the
        fragment type.
        ri   rj   r   r   r   c                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z5TestCli.test_file_exists_with_ext.<locals>.<listcomp>J  rs   r3   r   Nr   r   s         r,   test_file_exists_with_extz!TestCli.test_file_exists_with_ext=  s     	00	q 	A 	AA]]5+<*=>>FV-q&-@@@@99Y%6%6%8%8999	9  	
 	
 	
 	
 	
r3   c                 l   t                       t          j        d          5 }d|_        |                    t
          d          }|                     |j        |j                   |	                                 ddd           n# 1 swxY w Y   t          j                            t          j                    ddd          }|                     |j        d	| d
           t          |          5 }|                     |                                d           ddd           dS # 1 swxY w Y   dS )zM
        When no filename is provided, the user is prompted for one.
        r9   Edited content123
feature
inputNri   rj   r   vIssue number (`+` if none): 123
Fragment type (feature, bugfix, doc, removal, misc): feature
Created news fragment at r   Edited content
r   r   rA   rB   r   r
   assertFalserb   re   assert_called_oncer   pathr    getcwdr   r   r!   r#   r(   rD   r*   expectedrq   s         r,   test_without_filenamezTestCli.test_without_filenameT  s   
 	Z%% 	+%5I"]]50@]AAFV-v}===((***		+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+
 7<<	UOEVWWM"  	
 	
 	
 (^^ 	;qQVVXX'9:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s$   ABBB3)D))D-0D-c                    t                       t          j        d          5 }d|_        |                    t
          d          }|                     |j        |j                   |	                                 ddd           n# 1 swxY w Y   t          j                            t          j                    ddd          }|                     |j                            d	|           |j                   |j                                                            d
d          d         }t          j        t          j                            t          j                    dd                    }|                    d          d         }|                     t+          |          j        |           t/          |          5 }|                     |                                d           ddd           dS # 1 swxY w Y   dS )zU
        The user can create an orphan fragment from the interactive prompt.
        r9   zOrphan content
+
feature
r   Nri   rj   +ztIssue number (`+` if none): +
Fragment type (feature, bugfix, doc, removal, misc): feature
Created news fragment at r   r    zOrphan content
)r   r   rA   rB   r   r
   r   rb   re   r   r   r   r    r   
assertTrue
startswithstriprsplitr   splitrd   r   rn   r   r   r!   )	r#   r(   rD   r*   r   created_linefilescreated_fragmentrq   s	            r,   test_without_filename_orphanz$TestCli.test_without_filename_orphank  s:   
 	Z%% 	+%5I"]]5]??FV-v}===((***		+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+
 7<<	UOSIIM$$'"' ' 
 M	
 	
 	
 }**,,33D!<<R@
27<<	UOLLMM'--c2226d+,,15999"## 	;qQVVXX'9:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s$   ABBB)G::G>G>c                 p   t          d           t          j        d          5 }d|_        |                    t
          d          }|                     |j        |j                   |	                                 ddd           n# 1 swxY w Y   t          j                            t          j                    dd	d
          }|                     |j        d| d           t          |          5 }|                     |                                d           ddd           dS # 1 swxY w Y   dS )zr
        If an empty orphan prefix is set, orphan creation is turned off from interactive
        prompt.
        zorphan_prefix = ""r{   r9   r   r   r   Nri   rj   z+.feature.rstzfIssue number: +
Fragment type (feature, bugfix, doc, removal, misc): feature
Created news fragment at r   r   r   r   s         r,   &test_without_filename_no_orphan_configz.TestCli.test_without_filename_no_orphan_config  s    	*>????Z%% 	+%5I"]]5]??FV-v}===((***		+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+
 7<<	UO_UUM"  	
 	
 	
 (^^ 	;qQVVXX'9:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s$   AB		BB5)D++D/2D/c                    t          d           |                    t          dg          }|                     |j        |j                   t          dd          }d |                                D             }|                     |dg           |                    t          g d          }| 	                    |j        |j                   | 
                    d|j                   |                    t          g d	          }|                     |j        |j                   t          dd
d          }d |                                D             }|                     |dg           dS )a6  
        When creating a new fragment, the user can specify the section from the command
        line (and if none is provided, the default section will be used).

        The default section is either the section with a blank path, or else the first
        section defined in the configuration file.
        zu
[[tool.towncrier.section]]
name = "Backend"
path = "backend"
[[tool.towncrier.section]]
name = "Frontend"
path = ""
r{   r   ri   rj   c                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z)TestCli.test_sections.<locals>.<listcomp>  rs   r3   )r   	--sectioninvalidzDInvalid value for '--section': expected one of 'Backend', 'Frontend')r   r   Backendbackendc                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z)TestCli.test_sections.<locals>.<listcomp>  rs   r3   N)r   r   r
   r   rb   re   r   ru   r   r   rd   r#   r(   r*   rw   rx   s        r,   test_sectionszTestCli.test_sections  st    			
 		
 		
 		
 u'8&9::)6=99900	99Y%6%6%8%8999	%6$7888u&Q&Q&QRR(&-888RM	
 	
 	

 u&Q&Q&QRR)6=999	?;;	99Y%6%6%8%8999	%6$788888r3   c                    t          d           t          j        d          5 }d|_        |                    t
          d          }|                     |j        |j                   |	                                 ddd           n# 1 swxY w Y   t          j                            t          j                    dd	d
d          }|                     |j        d| d           dS )z
        When multiple sections exist when the interactive prompt is used, the user is
        prompted to select a section.
        w
[[tool.towncrier.section]]
name = "Backend"
path = ""

[[tool.towncrier.section]]
name = "Frontend"
path = "frontend"
r{   r9   r   z2
123
feature
r   Nri   frontendrj   r   zPick a section:
 1: Backend
 2: Frontend
Section (1, 2) [1]: 2
Issue number (`+` if none): 123
Fragment type (feature, bugfix, doc, removal, misc): feature
Created news fragment at r   r   r   rA   rB   r   r
   r   rb   re   r   r   r   r    r   r   r#   r(   rD   r*   r   s        r,   test_sections_without_filenamez&TestCli.test_sections_without_filename  s:    	
	
 
	
 
	
 
	
 Z%% 	+%5I"]]50C]DDFV-v}===((***		+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+
 7<<IKK
O=N
 
 	M #  	
 	
 	
 	
 	
s   AB		BBc                    t          d           t          j        d          5 }d|_        |                    t
          ddgd          }|                     |j        |j                   |	                                 d	d	d	           n# 1 swxY w Y   t          j                            t          j                    d
ddd          }|                     |j        d| d           d	S )z
        When multiple sections exist and the section is provided via the command line,
        the user isn't prompted to select a section.
        r   r{   r9   r   r   Frontendr   r   Nri   r   rj   r   r   r   r   r   s        r,   2test_sections_without_filename_with_section_optionz:TestCli.test_sections_without_filename_with_section_option  sK    	
	
 
	
 
	
 
	
 Z%% 	+%5I"]]Z08H #  F V-v}===((***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 7<<IKK
O=N
 
 	M #  	
 	
 	
 	
 	
s   ABBBc                 *   t          d           |                    t          dg          }|                     |j        |j                   t          ddd          }d |                                D             }|                     |dg           dS )	zI
        When all sections have paths, the first is the default.
        z~
[[tool.towncrier.section]]
name = "Frontend"
path = "frontend"

[[tool.towncrier.section]]
name = "Backend"
path = "backend"
r{   r   ri   r   rj   c                     g | ]	}|j         
S rl   rm   ro   s     r,   rr   z8TestCli.test_sections_all_with_paths.<locals>.<listcomp>'  rs   r3   N)	r   r   r
   r   rb   re   r   ru   r   r   s        r,   test_sections_all_with_pathsz$TestCli.test_sections_all_with_paths  s    
 	
	
 
	
 
	
 
	
 u'8&9::)6=999
O<<	99Y%6%6%8%8999	%6$788888r3   c                 d   t                       t          j        d          5 }|                    t          ddgd          }|                     |j        |j                   |                                 ddd           n# 1 swxY w Y   t          j
                            t          j                    ddd	          }|                     |j        d
| d           t          |          5 }|                     |                                d           ddd           dS # 1 swxY w Y   dS )z
        When no filename is provided, the user is prompted for one. If a message is
        provided, the editor isn't opened and the message is used.
        r9   rU   z
Fixed thisr   r   Nri   rj   r   r   r   zFixed this
)r   r   rA   r   r
   r   rb   re   assert_not_calledr   r   r    r   r   r   r!   r   s         r,   "test_without_filename_with_messagez*TestCli.test_without_filename_with_message*  s    	Z%% 	*]]54*>FV]WWFV-v}==='')))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 7<<	UOEVWWM"  	
 	
 	
 (^^ 	7qQVVXX~666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s$   ABB
B/)D%%D),D)c           	         t                       t          dd          }|dz  }|                                 |                    t          dg          }|                     d|j                   |                    t          t          t          dd                    gd          }|                     d|j        |j                   d |	                    d	          D             }|                     d
t          |                     |\  }}|                     |j        d           |                     |j                            d                     |                     |j                            d                     |                     t          |j                  dt          d          z              |                     |j        d           |                     |j                            d                     |                     |j                            d                     |                     |j        |           |                     t          |j                  dt          d          z              dS )z
        When a fragment starts with the only the orphan prefix (``+`` by default), the
        create CLI automatically extends the new file's base name to contain a random
        value to avoid commit collisions.
        ri   rj   
subsectionz	+.featurer   F)catch_exceptionsc                 :    g | ]}|                                 |S rl   )is_file)rp   ps     r,   rr   z7TestCli.test_create_orphan_fragment.<locals>.<listcomp>U  s%    DDD1		DQDDDr3   *r   r=   r   .feature	   N)r   r   r%   r   r
   r   r"   strre   rgloblensuffixr   stemr   endswithparent)r#   r(   rw   sub_frag_pathr*   rx   change1change2s           r,   test_create_orphan_fragmentz#TestCli.test_create_orphan_fragmentA  s-    	00	!L0u{m44F,---C\;77889E  
 
 	F,fm<<<DD	 4 4DDD	C	NN+++$000//44555--j99:::W\**EC
OO,CDDD000//44555--j99:::777W\**EC
OO,CDDDDDr3   c           
         t          d           t          dd          }|                    t          dg          }|                     d|j        |j                   t          |                    d                    }|                     t          |          d           |d         }| 
                    |j                            d	                     |                     t          |j                  d
t          d          z              | 
                    t          d |j        dt          d                    D                                  dS )zA
        Check that the orphan prefix can be customized.
        zorphan_prefix = "$$$"r{   ri   rj   z$$$.featurer   r   r   z$$$   r   c              3   2   K   | ]}|t           j        v V  d S )N)string	hexdigits)rp   cs     r,   	<genexpr>zDTestCli.test_create_orphan_fragment_custom_prefix.<locals>.<genexpr>z  s*      QQ!V%%QQQQQQr3   r   N)r   r   r   r
   r   r"   re   listr   r   r   r   r   all)r#   r(   rw   r*   rx   changes         r,   )test_create_orphan_fragment_custom_prefixz1TestCli.test_create_orphan_fragment_custom_prefixf  s1   
 	*ABBBB00	u}o66F,fm<<<--..	Y+++1..u55666V[))53z??+BCCCQQv{1J?O;O/PQQQQQ	
 	
 	
 	
 	
r3   c                    t          d                              d           t          d                              d           t          d                              d           |                    t          d          }|                     d	|j                   |                     t          d
                                                     dS )z
        When the `--dir` CLI argument is passed,
        it will create a new file in directory that is
        created by combining the `--dir` value
        with the `directory` option from the configuration
        file.
        pyproject.tomlz+[tool.towncrier]
directory = "changelog.d"
zfoo/fooT)parentszfoo/foo/__init__.pyr   )z--configr   z--dirri   z	--contentzAdds levitation.r}   r   zfoo/changelog.d/123.feature.rstN)	r   
write_textr%   r   r
   r   r"   r   existsrf   s      r,   =test_in_different_dir_with_nondefault_newsfragments_directoryzETestCli.test_in_different_dir_with_nondefault_newsfragments_directory}  s     	)),	
 	
 	
 	Yd+++"##..r222
 
 	F,--->??FFHHIIIIIr3   )NNTNT)$__name__
__module____qualname__maxDiffr-   r2   r5   rE   rH   rJ   rO   rR   rW   rY   r\   r_   rg   r   r   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rl   r3   r,   r   r      s       G . . . .:' ' '( ( (
 
 
L L L6 6 6  2  2Y Y Y
 
 
*  &. . .(
 
 
$ 
9I 
9 
9 
9 
9 
8 
8 
8 
8 
8 5 5 5 5 5$ 
y 
 
 
 
& 
i 
 
 
 
. 
	 
 
 
 
, ;I ; ; ; ;, ;9 ; ; ; ;< ;Y ; ; ; ;. #9I #9 #9 #9 #9J $
Y $
 $
 $
 $
L "
 "
 "
 "
 "
H 99 9 9 9 9* 7 7 7 7 7, "E) "E "E "E "EH 
	 
 
 
 
, J J J J Jr3   r   )r   r   pathlibr   textwrapr   unittestr   click.testingr   twisted.trial.unittestr   creater	   r
   helpersr   r   r   rl   r3   r,   <module>r      s    
			                    # # # # # # + + + + + + + + + + + + + + ? ? ? ? ? ? ? ?K
J K
J K
J K
J K
Jh K
J K
J K
J K
J K
Jr3   