Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/python/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyc


'Nc@sdZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZdefd	YZ
d
efdYZdefd
YZdefdYZeidd6Zeidd6ZeiZdefdYZeidd6Zeid d6ZdZdefdYZeiid6Zeiidd6d6ZdefdYZdS(!s3
Tests for parts of our release automation system.
iN(tDistribution(tTestCase(tdist(tget_setup_argstConditionalExtension(tFilePatht	SetupTestcBs eZdZdZdZRS(s&
    Tests for L{get_setup_args}.
    cCstddgdd}tddgdd}td||g}|j|d||g|d}|d	}|t}|j|j|j|gd
S(s
        Passing C{conditionalExtensions} as a list of L{ConditionalExtension}
        objects to get_setup_args inserts a custom build_ext into the result
        which knows how to check whether they should be built.
        twhatevers
whatever.ct	conditioncSstS(N(tTrue(tb((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt<lambda>scSstS(N(tFalse(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR!stconditionalExtensionstext_modulestcmdclasst	build_extN(RRtassertEqualRtprepare_extensionst
extensions(tselftgood_exttbad_exttargsRRtbuilder((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_conditionalExtensionss


cCs~tddgdd
g}td|g}|ddt}|jtdd	|j|j|jddgdS(sT
        When building on Windows NT, the WIN32 macro will be defined as 1.
        Rs
whatever.ct
define_macrosiR
RRtnametnttWIN32iN(swhateveri(swhateveri(Ri(RRRtpatchtosRRR(RtextRR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_win32Definition-s
(t__name__t
__module__t__doc__RR!(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRs	tGetVersionTestcBs)eZdZdZdZdZRS(s'
    Tests for L{dist.getVersion}.
    cCs#|j|_tj|jdS(N(tmktemptdirnameRtmkdir(R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pytsetUp@scCs^ttjj|jdd}|jd|j|jtj	dd|jddS(sg
        Test that getting the version of core reads from the
        [base]/_version.py file.
        s_version.pytwsT
from twisted.python import versions
version = versions.Version("twisted", 0, 1, 2)
tcoretbases0.1.2N(
topenRtpathtjoinR'twritetcloseRRt
getVersion(Rtf((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_getVersionCoreDs
!
cCstjtjj|jdttjj|jddd}|jd|j|jt	j
dd|jddS(s
        Test that getting the version of a non-core project reads from
        the [base]/[projname]/_version.py file.
        tblats_version.pyR*sZ
from twisted.python import versions
version = versions.Version("twisted.blat", 9, 8, 10)
R,s9.8.10N(RR(R.R/R'R-R0R1RRR2(RR3((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_getVersionOtherQs$
(R"R#R$R)R4R6(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR%;s		
tGetScriptsTestcBsDeZdZdZdZdZdZdZdZRS(s
    Tests for L{dist.getScripts} which returns the scripts which should be
    included in the distribution of a project.
    cCs|j}tj|tjtjj|dtjtjj|ddttjj|dddd}|jd|jtj	dd|}|j
t|d|j
tjj|ddd	S(
sw
        getScripts should return the scripts associated with a project
        in the context of Twisted SVN.
        tbintprojtexyR*tyaytbasediriiN(
R&RR(R.R/R-R0R1Rt
getScriptsRtlentbasename(RR<R3tscripts((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_scriptsInSVNfs
$

cCst|j}|jd}|j|jdjd|jdjd|jdjdtjdd	|j}|j||jdjgd
S(sg
        L{dist.getScripts} includes neither C{"_preamble.py"} nor
        C{"_preamble.pyc"}.
        R8s_preamble.pyssome preamble code
s
_preamble.pycssome preamble byte code
tprogramsgood program code
tR<N(	RR&tchildtmakedirst
setContentRR=R.R(RR<R8R@((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_excludedPreamblews
cCs|j}tj|tjtjj|dttjj|ddd}|jd|jtj	dd|}|j
t|d|j
tjj|ddd	S(
s
        getScripts should return the scripts associated with a project
        in the context of a released subproject tarball.
        R8R:R*R;R9R<iiN(
R&RR(R.R/R-R0R1RR=RR>R?(RR<R3R@((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_scriptsInReleases
!

cCs}|j}tj|tjtjj|dtjtjj|ddtjdd|}|j|gdS(s
        When calling getScripts for a project which doesn't actually
        have any scripts, in the context of an SVN checkout, an
        empty list should be returned.
        R8t	otherprojt	noscriptsR<N(R&RR(R.R/RR=R(RR<R@((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_noScriptsInSVNs
cCst|j}|j|jd}|j|jd}|jd|jd}|j|jdjdtjdd|j}|j||jgd	S(
s
        Passing the empty string to getScripts returns scripts that are (only)
        in the top level bin directory.
        R8tincludedsyay includedtsubdirsnot-includedsnot includedRCR<N(	RR&tcreateDirectoryRDRFRR=R.R(RR<tbindirRLRMR@((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_getScriptsTopLevels



cCsB|j}tj|tjdd|}|j|gdS(s
        When calling getScripts for a project which doesn't actually
        have any scripts in the context of that project's individual
        project structure, an empty list should be returned.
        RJR<N(R&RR(RR=R(RR<R@((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_noScriptsInSubprojects
(	R"R#R$RARGRHRKRPRQ(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR7`s					t
FakeModulecBs eZdZdZdZRS(sF
    A fake module, suitable for dependency injection in testing.
    cCs
||_dS(s
        Initializes a fake module.

        @param attrs: The attrs that will be accessible on the module.
        @type attrs: C{dict} of C{str} (Python names) to objects
        N(t_attrs(Rtattrs((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt__init__scCs0y|j|SWntk
r+tnXdS(s
        Gets an attribute of this fake module from its attrs.

        @raise AttributeError: When the requested attribute is missing.
        N(RStKeyErrortAttributeError(RR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt__getattr__s
(R"R#R$RURX(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRRs		cCsdS(NtCPython((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRstpython_implementationcCsdS(Ntlvhpy((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRstWithPlatformTestscBs eZdZdZdZRS(s[
    Tests for L{_checkCPython} when used with a (fake) recent C{platform}
    module.
    cCs|jtjdtdS(s
        L{_checkCPython} returns C{True} when C{platform.python_implementation}
        says we're running on CPython.
        tplatformN(t
assertTrueRt
_checkCPythontfakeCPythonPlatform(R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyttest_cpythonscCs|jtjdtdS(s
        L{_checkCPython} returns C{False} when C{platform.python_implementation}
        says we're not running on CPython.
        R]N(tassertFalseRR_tfakeOtherPlatform(R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt
test_others(R"R#R$RaRd(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR\s	RYt
subversionR[cCstjdtd|S(s
    A partially applied L{_checkCPython} that uses an empty C{platform}
    module (otherwise the code this test case is supposed to test won't
    even be called).
    R]tsys(RR_t
emptyPlatform(Rf((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt_checkCPythonWithEmptyPlatformstWithSubversionTestcBs eZdZdZdZRS(s
    Tests for L{_checkCPython} when used with a (fake) recent (2.5+)
    C{sys.subversion}. This is effectively only relevant for 2.5, since 2.6 and
    beyond have L{platform.python_implementation}, which is tried first.
    cCstt}|j|dS(s
        L{_checkCPython} returns C{True} when C{platform.python_implementation}
        is unavailable and C{sys.subversion} says we're running on CPython.
        N(RhtfakeCPythonSysR^(Rt	isCPython((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRascCstt}|j|dS(s
        L{_checkCPython} returns C{False} when C{platform.python_implementation}
        is unavailable and C{sys.subversion} says we're not running on CPython.
        N(RhtfakeOtherSysRb(RRk((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRds(R"R#R$RaRd(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRis		tmodulest__pypy__tOldPythonsFallbackTestcBs eZdZdZdZRS(s
    Tests for L{_checkCPython} when used on a Python 2.4-like platform, when
    neither C{platform.python_implementation} nor C{sys.subversion} is
    available.
    cCstt}|j|dS(s
        L{_checkCPython} returns C{True} when both
        C{platform.python_implementation} and C{sys.subversion} are unavailable
        and there is no C{__pypy__} module in C{sys.modules}.
        N(Rht
oldCPythonSysR^(RRk((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRa+scCstt}|j|dS(s
        L{_checkCPython} returns C{False} when both
        C{platform.python_implementation} and C{sys.subversion} are unavailable
        and there is a C{__pypy__} module in C{sys.modules}.
        N(Rht
oldPypySysRb(RRk((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt	test_pypy5s(R"R#R$RaRr(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyRo%s	
(sCPythonNN(slvhpyNN(R$Rtdistutils.coreRttwisted.trial.unittestRttwisted.pythonRttwisted.python.distRRttwisted.python.filepathRRR%R7tobjectRRR`RcRgR\tNoneRjRlRhRiRpRqRo(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt<module>s*'%d