
    -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
mZ ddlmZ dd	lmZ d
e_         G d de          Z G d de          ZdS )    N)version)	CliRunner)TestCase   )get_project_nameget_version)cli   )write	towncrierc                   V    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d ZdS )VersionFetchingTestsc                    |                                  }t          j        t          j                            |d                     t          t          j                            |dd          d          5 }|                    d           ddd           n# 1 swxY w Y   t          |d          }|                     |d           dS )z6
        A str __version__ will be picked up.
        
mytestproj__init__.pywz__version__ = '1.2.3'Nz1.2.3	mktemposmakedirspathjoinopenr   r   assertEqualselftempfr   s       [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/towncrier/test/test_project.pytest_strzVersionFetchingTests.test_str   s     {{}}
BGLL|44555"',,t\=AA3GG 	-1GG+,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- dL11'*****   6BBBc                    |                                  }t          j        t          j                            |d                     t          t          j                            |dd          d          5 }|                    d           ddd           n# 1 swxY w Y   t          |d          }|                     |d           dS )z8
        A tuple __version__ will be picked up.
        mytestprojar   r   __version__ = (1, 3, 12)Nz1.3.12r   r   s       r   
test_tuplezVersionFetchingTests.test_tuple"   s     {{}}
BGLL}55666"',,t]MBBCHH 	0AGG.///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 dM22(+++++r!   c                 
   |                                  }t          j        |           t          j        t          j                            |d                     t          t          j                            |dd          d          5 }|                    d           ddd           n# 1 swxY w Y   t          |d          }|                     |d           t          |d          }|                     |d           dS )zH
        An incremental-like Version __version__  is picked up.
        mytestprojincr   r   aK  
class Version:
    '''
    This is emulating a Version object from incremental.
    '''

    def __init__(self, *version_parts):
        self.version = version_parts
        self.package = "mytestprojinc"

    def base(self):
        return '.'.join(map(str, self.version))

__version__ = Version(1, 3, 12, "rc1")
                Nz	1.3.12rc1)
r   r   r   r   r   r   r   r   r   r   )r   r   r   r   projects        r   test_incrementalz%VersionFetchingTests.test_incremental/   s"    {{}}
D
BGLL77888"',,t_mDDcJJ 	aGG  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	& dO44+..."499/22222s   
B,,B03B0c                    |                                  }t          j        t          j                            |d                     t          t          j                            |dd          d          5 }|                    d           ddd           n# 1 swxY w Y   |                     t                    5 }t          |d           ddd           n# 1 swxY w Y   | 
                    d|j        j                   dS )z
        An exception is raised when the version could not be detected.
        For this test we use an incremental-like object,
        that has the `base` method, but that method
        does not match the return type for `incremental`.
        mytestprojnotincr   r   zv
class WeirdVersion:
    def base(self, some_arg):
        return "shouldn't get here"


__version__ = WeirdVersion()
N)zVersion must be a string, tuple, or an Incremental Version. If you can't provide that, use the --version argument and specify one.)r   r   r   r   r   r   r   assertRaises	Exceptionr   r   	exceptionargs)r   r   r   es       r   test_not_incrementalz)VersionFetchingTests.test_not_incrementalP   so    {{}}
BGLL'9::;;;"',,t%7GGMM 
	QRGG	 	 	
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 y)) 	2Q0111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	
 K	
 	
 	
 	
 	
s$   6BBB=CC!Cc                 l    t          dd          }|                     t          d          |           dS )z?
        A version from package metadata is picked up.
        .r   N)r   r   metadata_version)r   r   s     r   test_version_from_metadataz/VersionFetchingTests.test_version_from_metadataq   s8     c;//)+66@@@@@    c                     |                                  }t          j                            |d          }t          j        |           t          j                            |d          }t          |d           |S )zg
        Create a minimalistic project with missing metadata in a temporary
        directory.
        missingr   z# nope
)r   r   r   r   r   r   )r   tmp_dirpkginits       r   _setup_missingz#VersionFetchingTests._setup_missingx   s`    
 ++--gll7I..
Cw||G]33dJr6   c                     |                                  }|                     t                    5 }t          |d           ddd           n# 1 swxY w Y   |                     d|j        j                   dS )zC
        Missing __version__ string leads to an exception.
        r8   N)zBNo __version__ or metadata version info for the 'missing' package.)r<   r,   r-   r   r   r.   r/   )r   r9   r0   s      r   test_missing_versionz)VersionFetchingTests.test_missing_version   s     %%''y)) 	,Q+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	SK	
 	
 	
 	
 	
s   AAAc                 v    |                                  }|                     dt          |d                     dS )zi
        Missing __version__ string leads to the package name becoming the
        project name.
        Missingr8   N)r<   r   r   )r   r9   s     r   !test_missing_version_project_namez6VersionFetchingTests.test_missing_version_project_name   s<    
 %%''$4Wi$H$HIIIIIr6   c                    |                                  }t          j        t          j                            |d                     t          t          j                            |dd          d          5 }|                    d           ddd           n# 1 swxY w Y   |                     t          t          |d           | 
                    dt          |d                     dS )zJ
        A __version__ of unknown type will lead to an exception.
        mytestprojbr   r   z__version__ = object()NMytestprojb)r   r   r   r   r   r   r   r,   r-   r   r   r   )r   r   r   s      r   test_unknown_typez&VersionFetchingTests.test_unknown_type   s     {{}}
BGLL}55666"',,t]MBBCHH 	.AGG,---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	)[$FFF(8}(M(MNNNNNr!   c                     |                      t                    5  t          dd           ddd           dS # 1 swxY w Y   dS )zm
        An exception is raised when getting the version failed due to missing Python package files.
        r3   projectname_without_any_filesN)r,   ModuleNotFoundErrorr   )r   s    r   test_import_failsz&VersionFetchingTests.test_import_fails   s     233 	> 	><===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   9= =c                 h   d}|                                  }t          j        t          j                            ||                     t          t          j                            ||d          d          5 }|                    d           ddd           n# 1 swxY w Y   |                                  }t          j        t          j                            ||                     t          t          j                            ||d          d          5 }|                    d           ddd           n# 1 swxY w Y   t          j                            d|           | 	                    t          j        j
        d           t          ||          }|                     |d           dS )	zY
        An already installed package will be checked before cwd-found packages.
        #mytestproj_already_installed_importr   r   r$   Nz__version__ = (2, 1, 5)r   z2.1.5r   r   r   r   r   r   r   sysinsert
addCleanuppopr   r   )r   project_namer   r   sys_path_tempr   s         r   test_already_installed_importz2VersionFetchingTests.test_already_installed_import   s    ={{}}
BGLL|44555"',,t\=AA3GG 	01GG.///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 
BGLL==>>>"',,}lMJJCPP 	/TUGG-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	=)))a(((dL11'*****s$   8BB!BD<<E E c                 $   d}|                                  }t          j        t          j                            ||                     t          t          j                            ||d          d          5 }|                    d           ddd           n# 1 swxY w Y   t          j                            d|           | 	                    t          j        j
        d           t          d|          }|                     |d           dS )	z
        The version from the installed package is returned when there is no
        package present at the provided source directory.
        mytestproj_only_installedr   r   z__version__ = (3, 14)Nr   zsome non-existent directoryz3.14rL   )r   rQ   rR   r   r   s        r   3test_installed_package_found_when_no_source_presentzHVersionFetchingTests.test_installed_package_found_when_no_source_present   s   
 3
BGLL==>>>"',,}lMJJCPP 	-TUGG+,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	=)))a(((;\JJ&)))))s   8BB!BN)__name__
__module____qualname__r    r%   r)   r1   r5   r<   r>   rA   rE   rI   rS   rV    r6   r   r   r      s        + + +, , ,3 3 3B
 
 
BA A A  
 
 
J J JO O O> > >+ + +2* * * * *r6   r   c                       e Zd Zd Zd ZdS )InvocationTestsc                    t                      }|                                 }t          j                            |d          }t          j        |           t          j                    }	 t          j        |           t          dd          5 }|	                    d           ddd           n# 1 swxY w Y   t          j        d           |
                    t          dg          }|                     d|j                   |                     |j        d	           t          j        |           dS # t          j        |           w xY w)
zD
        `python -m towncrier` invokes the main entrypoint.
        dashmzpyproject.tomlr   z$[tool.towncrier]
directory = "news"
Nnewsz--helpz[OPTIONS] COMMAND [ARGS]...z&.*--help\s+Show this message and exit.)r   r   r   r   r   r   getcwdchdirr   r   invoketowncrier_cliassertInstdoutassertRegex)r   runnerr   new_dirorig_dirr   results          r   test_dash_mzInvocationTests.test_dash_m   sf    {{}}',,tW--
G9;;		HW&,, ECDDDE E E E E E E E E E E E E E EK]]=8*==FMM7GGGV],UVVVHXBHXs1   +$D8 B1%D8 1B55D8 8B59A)D8 8Ec                     t                      }|                    t          dg          }|                     |j                            d                     dS )zf
        `--version` command line option is available to show the current production version.
        z	--versionztowncrier, version 2N)r   rb   rc   
assertTrueoutput
startswith)r   rg   rj   s      r   test_versionzInvocationTests.test_version   sK     }{m<<001GHHIIIIIr6   N)rW   rX   rY   rk   rp   rZ   r6   r   r\   r\      s7          (J J J J Jr6   r\   )r   rM   importlib.metadatar   r4   click.testingr   twisted.trial.unittestr   _projectr   r   _shellr	   rc   helpersr   namer   r\   rZ   r6   r   <module>rx      s   
			 



 : : : : : : # # # # # # + + + + + + 4 4 4 4 4 4 4 4 ) ) ) ) ) )       ! J* J* J* J* J*8 J* J* J*ZJ J J J Jh J J J J Jr6   