HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/python/test/__pycache__/test_release.cpython-38.pyc
U


W[V��	@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
ddlmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ej*dkr�d
Z+ndZ+dZ,zddl-Z.Wne/e0fk
�r.dZ1YnXe2e.dd�dk�rHdZ1ne+Z1e+�sbed��rbdZ3ndZ3e+�s�ed��r�e$ddg��4d�d�4d�Z5e6e5d�dk�r�e+Z7ndZ7ndZ7Gdd�de�Z8dd �Z9d!d"�Z:d#d$�Z;Gd%d&�d&e<�Z=Gd'd(�d(e8�Z>Gd)d*�d*e8�Z?d+d,�Z@Gd-d.�d.e�ZAGd/d0�d0e8�ZBGd1d2�d2e�ZCGd3d4�d4e�ZDGd5d6�d6e=�ZEGd7d8�d8eEe8�ZFGd9d:�d:e8�ZGGd;d<�d<e�ZHGd=d>�d>e8�ZIdS)?z�
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.
�)�print_functionN)�BytesIO�StringIO)�TestCase�FailTest�SkipTest)�which)�release)�FilePath)�Version)�CalledProcessError)
�findTwistedProjects�
replaceInFile�Project�
filePathDelta�
APIBuilder�BuildAPIDocsScript�CheckNewsfragmentScript�
runCommand�NotWorkingDirectory�
SphinxBuilder�
GitCommand�getRepositoryCommand�IVCSCommand�posixz*Release toolchain only supported on POSIX.zmaster_doc = 'index'
zPydoctor is not present.�version_info�r)r�zPydoctor is too old.zsphinx-buildzSphinx not available.�gitz	--version� ��.zold git is presentzgit is not present.c@seZdZdZdd�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.
    cCstjdd�}|�tj|�|S)z)
        Make our own directory.
        z/tmp/)�dir)�tempfileZmkdtempZ
addCleanup�shutilZrmtree)�selfZnewDir�r'�B/usr/lib/python3/dist-packages/twisted/python/test/test_release.py�mktempTszExternalTempdirTestCase.mktempN)�__name__�
__module__�__qualname__�__doc__r)r'r'r'r(r"Osr"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}
    rZconfigz--filez.gitz	user.namez	"someone"z
user.emailz"someone@someplace.com"N)r�child�path�r/r'r'r(�
_gitConfig^s��r1cCstdd|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}
    rZinitN)rr/r1r0r'r'r(�_gitInitosr2cOsd�t||��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(�
genVersion|s�r6c@s 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||t�r:|��|�|||�q|�||�dtj��	d��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}
        �
�utf-8N)
r.�
isinstance�dict�createDirectory�createStructure�
setContent�replace�os�linesep�encode)r&�root�dirDict�xr.r'r'r(r=�s
z'StructureAssertingMixin.createStructurecCs�dd�|��D�}|��D]�\}}|�|�}t|�rD|�||��nTt|t�rt|�|��d�|j	��|�
||�n$|���d��
tjd�}|�||�|�|�q|r�|�d|j	|f�dS)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)�.0Zeachr'r'r(�
<listcomp>�sz;StructureAssertingMixin.assertStructure.<locals>.<listcomp>z{} is not a dir!r9r8z#There were extra children in %s: %sN)�children�itemsr.�callable�
assertTruer:r;�isdirr3r/�assertStructure�
getContent�decoder?r@rA�assertEqual�removeZfail)r&rCrDrIZpathSegmentZexpectationr.Zactualr'r'r(rN�s"

��z'StructureAssertingMixin.assertStructureN)r*r+r,r-r=rNr'r'r'r(r7�sr7c@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�qBdS)zA
        Assert that two lists of L{Project}s are equal.
        �	directory)�keyN)rQ�len�sorted�operator�
attrgetter�ziprT)r&ZobservedProjectsZexpectedProjectsZobserved�expectedr'r'r(�assertProjectsEqual�s��z ProjectTests.assertProjectsEqualNcCs�|dkrt|���}|d�d�}|}|D].}|�|�}|��sH|��|�d��d�q*|�d���|�d��t|��d��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.pyr9)
r
r)�splitr.�existsr<r>r6rBr)r&�version�
baseDirectoryZsegmentsrTZsegmentr'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.
        )r
r)rf)r&Zversionsrerdr'r'r(�makeProjects�szProjectTests.makeProjectscCs&d}|�|�}|�|��t|��dS)z5
        Project objects know their version.
        )�twistedr rrN)rfrQZ
getVersionr)r&rdZprojectr'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)rr
rQ�reprrT)r&�foor'r'r(�	test_reprs
�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.
        )rlr �r)zfoo.barr��rlrjN)rgr
r\rr.)r&reZprojectsr'r'r(�test_findTwistedStyleProjectss���z*ProjectTests.test_findTwistedStyleProjects)N)
r*r+r,r-r\rfrgrirmrqr'r'r'r(rS�s
		rSc@s eZdZdZdd�Zdd�ZdS)�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)NZ	releaseChrr)r@�mkdir�chdirr'r'r'r(�
chAndBreak,s

z+UtilityTests.test_chdir.<locals>.chAndBreakN)r@�getcwd�assertRaises�ZeroDivisionErrorr	ZrunChdirSaferQ)r&�cwdrur'r'r(�
test_chdir$s�zUtilityTests.test_chdirc	Cs�d}tdd��}|�|�W5QRX|�dd�}tdddi�td��}|�|��|�W5QRX|�dd�}tdddi�td��}|�|��|�W5QRXdS)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�wz$VERz2.0.0z3.0.0N)�open�writer?rrQ�read)r&ZcontentZoutfr[�fr'r'r(�test_replaceInFile7s

zUtilityTests.test_replaceInFileN)r*r+r,r-rzr�r'r'r'r(rrsrrcst����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
sVz�||�WnBtk
rP}z$|jd�d�r>td�|����W5d}~XYnXdS)Nrz%'Failed to get object inventory from zWThis test is prone to intermittent network errors. See ticket 8753. Exception was: {!r})rr4�
startswithrr3)�a�kw�e��funcr'r(�wrapperYs��z(doNotFailOnNetworkError.<locals>.wrapper)�	functools�wraps)r�r�r'r�r(�doNotFailOnNetworkErrorNs	r�c@s eZdZdZdd�Zdd�ZdS)�DoNotFailTestsz/
    Tests for L{doNotFailOnNetworkError}.
    c
sNt�fdd��}z
|�Wn.tk
rH}z��|t�W5d}~XYnXdS)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.
        cs��dd�dS)Nz(Failed to get object inventory from blah��rQr'�r&r'r(�innerrsz8DoNotFailTests.test_skipsOnAssertionError.<locals>.innerN)r��	Exception�assertIsInstancer�r&r�r�r'r�r(�test_skipsOnAssertionErrorls
z)DoNotFailTests.test_skipsOnAssertionErrorc
sNt�fdd��}z
|�Wn.tk
rH}z��|t�W5d}~XYnXdS)zz
        If there is a L{FailTest} that is not the intersphinx fetching error,
        it will be passed through.
        cs��dd�dS)Nz	Error!!!!r�r�r'r�r'r(r��sz>DoNotFailTests.test_doesNotSkipOnDifferentError.<locals>.innerN)r�r�r�rr�r'r�r(� test_doesNotSkipOnDifferentError|s
z/DoNotFailTests.test_doesNotSkipOnDifferentErrorN)r*r+r,r-r�r�r'r'r'r(r�gsr�c@sHeZdZdZeZedd��Zedd��Zedd��Z	dd	�Z
d
d�ZdS)
�APIBuilderTestsz"
    Tests for L{APIBuilder}.
    c
Cs`t�}|�td|�d}d}d}d}d}d}t|����|�}|��|�d��d	�||��	d
��t|���}	t
�}
|
�|||||	�|	�d�}|�|�
�d|	jf�|�d
||f|��d�|	�d�}|�|�
�d|jf�|�||��d�|�d||f|���|�d||f|���|�||���|�|�d��
��|�|��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 outputr^z(def foo():
    '{}'
def _bar():
    '{}'r9�
index.htmlzAPI index %r did not exist.z<a href="%s">%s</a>�+Project name/location not in file contents.�	quux.html�,Package documentation file %r did not exist.�,Docstring not in package documentation file.z<a href="%s/%s">View Source</a>z:<a class="functionSourceLink" href="%s/%s/__init__.py#L1">�
quux.foo.htmlr�N�r�patch�sysr
r)r.�makedirsr>r3rBr�buildrLrcr/�assertInrO�siblingrQ�getvalue)
r&r��projectName�packageName�
projectURL�	sourceURL�	docstring�privateDocstring�	inputPath�
outputPath�builder�	indexPath�quuxPathr'r'r(�
test_build�sr
����

�
�

��
���zAPIBuilderTests.test_buildc	Cst�}|�td|�d}t|���}|�d�}|��|�d��d�|��	d��|�d��t
ddd	d	��t|���}t�}|�||�|�d
�}|�
|��d�|j��|�d|��d
�|�d�}|�
|��d�|j��|�||��d�|�d|���|�|��d�dS)z�
        L{BuildAPIDocsScript.buildAPIDocs} builds the API docs with values
        appropriate for the Twisted project.
        r�r�rhr^zdef foo():
    '{}'
r9rarrr�zAPI index {} did not exist.s/<a href="http://twistedmatrix.com/">Twisted</a>r�ztwisted.htmlr�r�s[<a href="https://github.com/twisted/twisted/tree/twisted-1.0.0/src/twisted">View Source</a>r_N)rr�r�r
r)r.r�r>r3rBr6r�buildAPIDocsrLrcr/r�rOrQr�)	r&r�r�ZprojectRootZpackagePathr��scriptr�ZtwistedPathr'r'r(�test_buildWithPolicy�s\

���
�

��
����z$APIBuilderTests.test_buildWithPolicycCs@t�}|�td|�d}d}d}d}d}d}t|����|�}|��|�d��d	�||��	d
��t|���}	t
�}
|
�|||||	�|	�d�}|�|�
�d|jf�|�||��d
�|�d|���|�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�r^a|from 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(object):
    passr9r�r�r�z=foo was deprecated in Twisted 15.0.0; please use Baz instead.z&_bar was deprecated in Twisted 16.0.0.r�z?Baz was deprecated in Twisted 14.2.3; please use stuff instead.z
quux.Baz.htmlr�Nr�)r&r�r�r�r�r�r�r�r�r�r�r�r'r'r(�test_buildWithDeprecatedsh
����

������z(APIBuilderTests.test_buildWithDeprecatedcCsBt�}|�t|jg�|�t|jdg�|�t|jdddg�dS)z�
        SystemExit is raised when the incorrect number of command line
        arguments are passed to the API building script.
        rlrj�bazN)rrw�
SystemExit�main�r&r�r'r'r(�-test_apiBuilderScriptMainRequiresTwoArgumentsIsz=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�S�N)�append)r��b�Zcallsr'r(�<lambda>[r_z;APIBuilderTests.test_apiBuilderScriptMain.<locals>.<lambda>ZhelloZthereN)rr�r�rQr
r�r'r�r(�test_apiBuilderScriptMainTs
z)APIBuilderTests.test_apiBuilderScriptMainN)r*r+r,r-�pydoctorSkip�skipr�r�r�r�r�r�r'r'r'r(r��s
=
1
Fr�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�rQrr
r�r'r'r(�test_filePathDeltaSubdirfs
��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_filePathDeltaSiblingDiros
��z/FilePathDeltaTests.test_filePathDeltaSiblingDircCs&|�ttd�td��ddddg�dS)zx
        L{filePathDelta} can create relative paths to totally unrelated paths
        for maximum portability.
        r�z	/baz/quuxr�r�r�Nr�r�r'r'r(�test_filePathNoCommonElementsys
�
�z0FilePathDeltaTests.test_filePathNoCommonElementscCs&|�ttd�td��ddddg�dS)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/spamr�r�ZspamNr�r�r'r'r(�$test_filePathDeltaSimilarEndElements�s
�
�z7FilePathDeltaTests.test_filePathDeltaSimilarEndElementsN)r*r+r,r-r�r�r�r�r'r'r'r(r�as
	

r�c@speZdZdZeZdZe�e�ZdZ	e�e	�Z	dd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�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�r
r)ZtwistedRootDirr.�	sphinxDirr��	sourceDirr�r'r'r(�setUp�s

zSphinxBuilderTests.setUpcCs8|j�d��|j�d��|j�d��|j�d��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.pyr9�	index.rstN)r�r.r>�confContentrB�indexContentr�r'r'r(�createFakeSphinxProject�sz*SphinxBuilderTests.createFakeSphinxProjectcCsN|�|�}|�|���|��}|�t|�dk�|j�d�rJ|�d|�dS)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: L{FailTest <twisted.trial.unittest.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)r.rLrcrOrVr/�endswithr�)r&ZfileDirZfileNameZfpathZ	fcontentsr'r'r(�verifyFileExists�s
z#SphinxBuilderTests.verifyFileExistscCs"|��|j�|j�|��dS)zT
        Creates and builds a fake Sphinx project using a L{SphinxBuilder}.
        N)r�r�r�r��verifyBuiltr�r'r'r(r��szSphinxBuilderTests.test_buildcCs*|��|j�|j��jg�|��dS)zV
        Creates and builds a fake Sphinx project as if via the command line.
        N)r�r�r�r��parentr/r�r�r'r'r(�	test_main�szSphinxBuilderTests.test_mainc	Cs�t�}|�td|�|��|j�d��d��}|�d�W5QRX|�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
rzmalformed hyperlink targetN)rr�r�r�r�r.r|r}rwr�r�r�r�r/rQ�coder�r�r�)r&�outputr�	exceptionr'r'r(�test_warningsAreErrorss�z)SphinxBuilderTests.test_warningsAreErrorscCsr|j�d�}|�|���|�d�}|�|���|�|d�|�|d�|�|d�|�|d�|�|d�dS)	z>
        Verify that a sphinx project has been built.
        �docZdoctreesr�z
genindex.htmlzobjects.invzsearch.htmlzsearchindex.jsN)r�r�rLrMr.�assertFalsercr�)r&ZhtmlDirZ
doctreeDirr'r'r(r�s
zSphinxBuilderTests.verifyBuiltcCs|�t|jj|j�dS)zg
        Check that SphinxBuilder.build fails when run against a non-sphinx
        directory.
        N)rwrr�r�r�r�r'r'r(�test_failToBuild)s�z#SphinxBuilderTests.test_failToBuildN)r*r+r,r-�
sphinxSkipr�r��textwrap�dedentr�r�r�r�r�r�r�r�r�r'r'r'r(r��s



&		r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�CommandsTestMixinzF
    Test mixin for the VCS commands used by the release scripts.
    cCst|���|_dSr�)r
r)�tmpDirr�r'r'r(r�9szCommandsTestMixin.setUpcCs"|�|j�}|�|j�|��dS)z�
        Calling the C{ensureIsWorkingDirectory} VCS command's method on a valid
        working directory doesn't produce any error.
        N)�makeRepositoryr�ZassertIsNone�
createCommand�ensureIsWorkingDirectory�r&�reposDirr'r'r(�1test_ensureIsWorkingDirectoryWithWorkingDirectory=s
�zCCommandsTestMixin.test_ensureIsWorkingDirectoryWithWorkingDirectorycCs|�t|jj|j�dS)z�
        Calling the C{ensureIsWorkingDirectory} VCS command's method on an
        invalid working directory raises a L{NotWorkingDirectory} exception.
        N)rwrr�r�r�r�r'r'r(�4test_ensureIsWorkingDirectoryWithNonWorkingDirectoryGs�zFCommandsTestMixin.test_ensureIsWorkingDirectoryWithNonWorkingDirectorycCs"|�|j�}|�|j�|��dS)z�
        Calling the C{isStatusClean} VCS command's method on a repository with
        no pending modifications returns C{True}.
        N)r�r�rLr��
isStatusCleanr�r'r'r(�test_statusCleanQs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)r�r�r.r>r�r�r�r�r'r'r(�test_statusNotCleanZs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)r�r�r.r>�commitRepositoryrLrcr�rRZrestatr�)r&r�ZtestFiler'r'r(�test_removeds



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.ZREADMEzHi this is 1.0.0rhrrztwisted.web)r`ra)r`raZweb)z
README.rstrhZexportN)r6r�r�r=r�r
r)r.r�ZexportTorN)r&Z	structurer�Z	exportDirr'r'r(�test_exportts$�����

zCommandsTestMixin.test_exportN)r*r+r,r-r�r�r�r�r�r�r�r'r'r'r(r�5s

	
r�c@s(eZdZdZeZeZdd�Zdd�Z	dS)�GitCommandTestz^
    Specific L{CommandsTestMixin} related to Git repositories through
    L{GitCommand}.
    cCs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}
        )r2)r&rCr'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.
        rz-C�addz/*�commit�-mZhopN)rr/�glob)r&Z
repositoryr'r'r(r��s�zGitCommandTest.commitRepositoryN)
r*r+r,r-rr��gitSkipr�r�r�r'r'r'r(r��s
r�c@s,eZdZdZeZdd�Zdd�Zdd�ZdS)	�RepositoryCommandDetectionTestz
    Test the L{getRepositoryCommand} to access the right set of VCS commands
    depending on the repository manipulated.
    cCst|���|_dSr�)r
r)�reposr�r'r'r(r��sz$RepositoryCommandDetectionTest.setUpcCs$t|j�t|j�}|�|t�dS)zV
        L{getRepositoryCommand} from a Git repository returns L{GitCommand}.
        N)r2rrZassertIsr)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)rwrrrr�r'r'r(�test_unknownRepository�s�z5RepositoryCommandDetectionTest.test_unknownRepositoryN)	r*r+r,r-r�r�r�rrr'r'r'r(r��s
	r�c@seZdZdZdd�ZdS)�VCSCommandInterfaceTestszF
    Test that the VCS command classes implement their interface.
    cCs|�t�t��dS)z:
        L{GitCommand} implements L{IVCSCommand}.
        N)rLrZ
implementedByrr�r'r'r(r�sz!VCSCommandInterfaceTests.test_gitN)r*r+r,r-rr'r'r'r(r�src@sleZdZdZeZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�CheckNewsfragmentScriptTestsz%
    L{CheckNewsfragmentScript}.
    cCs�t|���|_t|j�tddddg|jjd�|j�d��d�tdd|j�d�jg|jjd�tdd	d
dg|jjd�t|���|_tdd|jj|jjg�t	|j�dS)
Nr�checkout�-bZtrunk�ryZteststest!r�r�r��initialZclone)
r
r)�originr2rr/r.r>�repor1r�r'r'r(r��s
���z"CheckNewsfragmentScriptTests.setUpc	Cs>g}|�t��}t|j��g�W5QRX|�|jjd�dS)z6
        Too few arguments returns a failure.
        )z/Must specify one argument: the Twisted checkoutN)rwr�rr�r�rQr�r4�r&�logsr�r'r'r(�test_noArgs�s
�z(CheckNewsfragmentScriptTests.test_noArgsc	Cs�tddddg|jjd�|j�d�}|�d�tdd|j|jg|jjd�tdd	d
dg|jjd�g}|�t��}t|j��	|jjg�W5QRX|�
|jjd�|�
|d
d�dS)zd
        If there are changes from trunk, then there should also be a
        newsfragment.
        rrr�mypatchr�somefile�changer�r�r��	some file�r����-No newsfragment found. Have you committed it?N�
rrr/r.r>rwr�rr�r�rQr�r4�r&rr
r�r'r'r(�!test_diffFromTrunkNoNewsfragments�s$�
�� 
�z>CheckNewsfragmentScriptTests.test_diffFromTrunkNoNewsfragmentsc	Csltddddg|jjd�g}|�t��}t|j��|jjg�W5QRX|�|j	j
d�|�|dd�d	S)
ze
        If there are no changes from trunk, then no need to check the
        newsfragments
        rrrrrrr�9On trunk or no diffs from trunk; no need to look at this.N)rrr/rwr�rr�r�rQr�r4rr'r'r(�test_noChangeFromTrunks� �z3CheckNewsfragmentScriptTests.test_noChangeFromTrunkc	CsTg}|�t��}t|j��|jjg�W5QRX|�|jj	d�|�|dd�dS)z9
        Running it on trunk always gives green.
        rrrN)
rwr�rr�r�rr/rQr�r4rr'r'r(�
test_trunk*s �z'CheckNewsfragmentScriptTests.test_trunkc	Cs�tddddg|jjd�|j�d�}|�d�tdd|j|jg|jjd�tdd	d
dg|jjd�g}|�t��}t|j��	|jjg�W5QRX|�
|jjd�|�
|d
d�dS)z~
        Running it on a release branch returns green if there is no
        newsfragments even if there are changes.
        rrr�release-16.11111-9001rrrr�r�r�rrrz/Release branch with no newsfragments, all good.Nrrr'r'r(�test_release9s$�
�� 
�z)CheckNewsfragmentScriptTests.test_releasec	Cs�tddddg|jjd�|j�d��d�}|��|�d�}|�d	�|j�d
�}|�d�tdd|j|jg|jjd�tdd
ddg|jjd�g}|�t��}t|j	��
|jjg�W5QRX|�|jj
d�|�|dd�dS)zd
        Running it on a release branch returns red if there are new
        newsfragments.
        rrrrrrhr`�	1234.miscr_r�Boor�r�r��fragmentrrz1No newsfragments should be on the release branch.N�rrr/r.r�r>rwr�rr�r�rQr�r4�r&r`r �	unrelatedr
r�r'r'r(�test_releaseWithNewsfragmentsSs,�


�� 
�z:CheckNewsfragmentScriptTests.test_releaseWithNewsfragmentsc	Cs�tddddg|jjd�|j�d��d�}|��|�d�}|�d	�tdd
|jg|jjd�tdddd
g|jjd�g}|�t��}t|j	��
|jjg�W5QRX|�|jj
d�|�|dd�dS)zR
        Running it on a branch with only a quotefile change gives green.
        rrr�	quotefilerr��funzTwisted.Quotess	Beep boopr�r�r��quotesrrz+Quotes change only; no newsfragment needed.Nr!)r&r&r'r
r�r'r'r(�test_onlyQuotesrs(�

�� 
�z,CheckNewsfragmentScriptTests.test_onlyQuotesc	Cs�tddddg|jjd�|j�d��d�}|��|�d�}|�d	�|j�d
�}|�d�tdd|j|jg|jjd�tdd
ddg|jjd�g}|�t��}t|j	��
|jjg�W5QRX|�|jj
d�|�|dd�dS)zn
        Running it on a branch with a fragment in the newsfragments dir added
        returns green.
        rrrr%rrhr`rr_rrr�r�r��newsfragmentrr�%Found twisted/newsfragments/1234.miscNr!r"r'r'r(�test_newsfragmentAdded�s(�


�� z3CheckNewsfragmentScriptTests.test_newsfragmentAddedc	Cs�tddddg|jjd�|j�d��d�}|��|�d�}|�d	�|j�d
�}|�d�tdd|j|jg|jjd�tdd
ddg|jjd�g}|�t��}t|j	��
|jjg�W5QRX|�|jj
d�|�|dd�dS)zo
        Running it on a branch with a non-fragment in the topfiles dir does not
        return green.
        rrrr%rrh�topfilesz1234.txtr_rrr�r�r�znot topfilerrrNr!)r&r,ZnotFragmentr#r
r�r'r'r(�test_topfileButNotFragmentAdded�s,�


�� 
�z<CheckNewsfragmentScriptTests.test_topfileButNotFragmentAddedc	Cs�tddddg|jjd�|j�d��d�}|��|�d�}|�d	�|�d
�}|�d�tdd|j|jg|jjd�tdd
ddg|jjd�g}|�t��}t|j	��
|jjg�W5QRX|�|jj
d�|�|dd�dS)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.
        rrrr%rrhr`rr_rrr�r�r�r)rrr*Nr!r"r'r'r(�/test_newsfragmentAddedButWithOtherNewsfragments�s(�



�� zLCheckNewsfragmentScriptTests.test_newsfragmentAddedButWithOtherNewsfragmentsN)r*r+r,r-r�r�r�rrrrrr$r(r+r-r.r'r'r'r(r�sr)Jr-Z
__future__rr�r�rXr@r�r�r$r%�iorrZtwisted.trial.unittestrrrZtwisted.python.procutilsrZtwisted.pythonr	Ztwisted.python.filepathr
Zincrementalr�
subprocessrZtwisted.python._releaser
rrrrrrrrrrrr�namer�ZtestingSphinxConfZpydoctor.driverZpydoctor�ImportError�SyntaxErrorr��getattrr�rbZ
gitVersion�intr�r"r1r2r6�objectr7rSrrr�r�r�r�r�r�r�r�rrr'r'r'r(�<module>sp<


@W/%V-(X$