ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ A[c@@s8ddlmZmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZmZmZddlmZmZmZerddlZndZdZdefd YZd efd YZd efd YZdejfdYZejedZdZ dZ!dZ"dZ#e$ejd rejj%ej_&ne'dZ(e$ejd re ejde(nde)fdYZ*de*fdYZ+e'dZ,e$ejd r4e ejde,ndS(i(tprint_functiontabsolute_importN(tdedent(t bind_methodtPY26tPY3tPY2tPY27(t check_outputtSTDOUTtCalledProcessErrorcC@s&|jdr|d}nt|S(s, Removes any leading and dedents. s i(t startswithR(tcode((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyt reformat_codes cC@sW|jd}gt|D]!\}}|jdr|^q}gt|D]0\}}|jdsz|jdrP|^qP}gt|D]!\}}|jdr|^q}|j|kstdd}d}||||kstd tg|D]}||^q} tt|| } tg|D]}||^qP} tt|| } tg|D]}||^q} tt|| }g}xtt |D]w}||kr|j | |q||kr|j | |q||kr5|j ||q|j ||qWdj |S( s Returns the code block with any ``__future__`` import lines sorted, and then any ``future`` import lines sorted, then any ``builtins`` import lines sorted. This only sorts the lines within the expected blocks. See test_order_future_lines() for an example. s sfrom __future__ import s from futures from pasts from builtinssIinternal usage error: dedent the code before calling order_future_lines()cS@s t|dkrt|SdS(Ni(tlentmax(tnumbers((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytmymax7scS@s&t|dkrt|StdS(Nitinf(Rtmintfloat(R((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytmymin:ss2the __future__ and future imports are out of order( tsplitt enumerateR tlstriptAssertionErrortsortedtdicttziptrangeRtappendtjoin(R tlinestitlinetuufuture_line_numberstfuture_line_numberstbuiltins_line_numbersRRtuultsorted_uufuture_linestfltsorted_future_linestbltsorted_builtins_linest new_lines((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytorder_future_liness:    ###   tVerboseCalledProcessErrorcB@s#eZdZddZdZRS(s Like CalledProcessError, but it displays more information (message and script output) for diagnosing test failures etc. cC@s(||_||_||_||_dS(N(tmsgt returncodetcmdtoutput(tselfR/R0R1R2((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyt__init__`s   cC@s d|j|j|j|jfS(Ns>Command '%s' failed with exit status %d Message: %s Output: %s(R1R0R/R2(R3((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyt__str__fsN(t__name__t __module__t__doc__tNoneR4R5(((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyR.[s t FuturizeErrorcB@seZRS((R6R7(((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyR:jstPasteurizeErrorcB@seZRS((R6R7(((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyR;mst CodeHandlercB@seZdZdZdeeeeedZedZdZdeeeeedZ dZ d d Z d d Z d deeed Z d ejd ZRS(st Handy mixin for test classes for writing / reading / futurizing / running .py files in the test suite. cC@std|_td|_tjg|_tjtj j |_ tj d}|ritj tj|d6|_nitj d6|_dS(si The outputs from the various futurize stages should have the following headers: s from __future__ import absolute_import from __future__ import division from __future__ import print_function s4 from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from future import standard_library standard_library.install_aliases() from builtins import * t PYTHONPATHN(R theaders1theaders2tsyst executablet interpretersttempfiletmkdtemptostpathtsepttempdirtgetenvtgetcwdtpathseptenv(R3tpypath((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytsetUpvs   $iic C@s|rt|}n|j||jd|d|d|d||j}|rx&|jD]} |jd| } q`Wn|S(s Converts the code block using ``futurize`` and returns the resulting code. Passing stages=[1] or stages=[2] passes the flag ``--stage1`` or ``stage2`` to ``futurize``. Passing both stages runs ``futurize`` with both stages by default. If from3 is False, runs ``futurize``, converting from Python 2 to both 2 and 3. If from3 is True, runs ``pasteurize`` to convert from Python 3 to both 2 and 3. Optionally reformats the code block first using the reformat() function. If run is True, runs the resulting code under all Python interpreters in self.interpreters. tstagest all_importstfrom3t conservativet interpreter(R t_write_test_scriptt_futurize_test_scriptt_read_test_scriptRBt_run_test_script( R3R RORPRQtreformattrunRRR2RSt_((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytconverts   cC@s|r'|j|}|j|}nt|trXt|t rX|jd}nt|trt|t r|jd}n|jt|j|jdS(s Compares whether the code blocks are equal. If not, raises an exception so the test fails. Ignores any trailing whitespace like blank lines. If ignore_imports is True, passes the code blocks into the strip_future_imports method. If one code block is a unicode string and the other a byte-string, it assumes the byte-string is encoded as utf-8. sutf-8N(tstrip_future_importst isinstancetbytestdecodet assertEqualR-trstrip(R3R2texpectedtignore_imports((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytcompares cC@sg}x{|jdD]j}|jdpm|jdpm|jdpmd|kpmd|kpm|jds|j|qqWdj|S(s Strips any of these import lines: from __future__ import from future from future. from builtins or any line containing: install_hooks() or: install_aliases() Limitation: doesn't handle imports split across multiple lines like this: from __future__ import (absolute_import, division, print_function, unicode_literals) s sfrom __future__ import s from future sfrom builtins sinstall_hooks()sinstall_aliases()s from future.(RR RR(R3R R2R"((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyR\s  c C@s~|j|d|d|d|d|d|} |rTd|krH|jn|j} nd} |j| | t|d|d S( s< Convenience method that calls convert() and compare(). Reformats the code blocks automatically using the reformat_code() function. If all_imports is passed, we add the appropriate import headers for the stage(s) selected to the ``expected`` code-block, so they needn't appear repeatedly in the test code. If ignore_imports is True, ignores the presence of any lines beginning: from __future__ import ... from future import ... for the purpose of the comparison. RORPRQRYRRitRcN(R[R?R>RdR ( R3tbeforeRbRORPRcRQRYRRR2theaders((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyt convert_checks!cK@s|j|||dS(se Convenience method to ensure the code is unchanged by the futurize process. N(Rh(R3R tkwargs((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyt unchangedssmytestscript.pycC@s`t|tr!|jd}ntj|j|ddd}|jt|WdQXdS(s Dedents the given code (a multiline string) and writes it out to a file in a temporary folder like /tmp/tmpUDCn7x/mytestscript.py. sutf-8twttencodingN(R]R^R_tiotopenRHtwriteR(R3R tfilenametf((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRTs"cC@s8tj|j|ddd}|j}WdQX|S(NtrtRlsutf-8(RmRnRHtread(R3RpRqt newsource((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRV(s"c C@sg}t|}|r(|jdn|r7d}nrd}|dgkr\|jdn7|dgkr{|jdn|ddgkst|r|jdn|j|}tj|g|d |g} yt| d td |j} Wnt k r} t |7} d d j | d|j|d| j f} WdQXd|kr[t nt}|| | j| jd| jnX| S(Ns --all-importss pasteurize.pys futurize.pyis--stage1is--stage2s--conservatives-wtstderrRLs8Error running the command %s %s Contents of file %s: %st senv=%ss ---- %s ----tfuturizeR2(tlistRRRHR@RARR RLR RnRRsR:R;R0R1R2(R3RpRORPRQRRtparamstscripttfnt call_argsR2teRqR/t ErrorClass((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRU-s8     %c C@s|j|}y%t||gd|jdt}Wntk r}t|=}ddj||gd|j|d|jf}WdQXt|dsd|_ nt ||j |j d|j nX|S(NRLRus8Error running the command %s %s Contents of file %s: %sRvsenv=%ss ---- %s ----R2(RHRRLR R RnRRsthasattrR9R2R.R0R1(R3RpRSR{R2R}RqR/((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRWXs   %(ii(ii(ii(R6R7R8RNtFalsetTrueR[RdR\RhRjRTRVRUR@RARW(((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyR<qs" +   "     )s#this test is known to fail on Py2.6cC@sts |Stj|S(N(RtunittesttexpectedFailure(tfunc((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytexpectedFailurePY3wscC@sts |Stj|S(N(RRR(R((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytexpectedFailurePY26|scC@sts |Stj|S(N(RRR(R((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytexpectedFailurePY27scC@sts |Stj|S(N(RRR(R((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytexpectedFailurePY2stassertRaisesRegexcC@st|ttfr9|s'tdtj|}n|j|s||pQd}d||j|f}|j|ndS(s=Fail the test unless the text matches the regular expression.s!expected_regex must not be empty.sRegex didn't matchs%s: %r not found in %rN( R]tstrtunicodeRtretcompiletsearchtpatterntfailureException(R3ttexttexpected_regexR/((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyt assertRegexs Rt_AssertRaisesBaseContextcB@s)eZdddZdZdZRS(cC@s||_||_|dk rTy|j|_Wq]tk rPt||_q]Xn d|_t|ttfrt j |}n||_ d|_ dS(N( Rbt test_caseR9R6tobj_nametAttributeErrorRR]R^RRRR/(R3RbRt callable_objR((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyR4s      cC@s.|jj|j|}|jj|dS(N(Rt_formatMessageR/R(R3t standardMsgR/((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyt _raiseFailurescC@sC|dkr%|jdd|_|S||||WdQXdS(s If callable_obj is None, assertRaises/Warns is being used as a context manager, so check for a 'msg' kwarg and return self. If callable_obj is not None, call it passing args and kwargs. R/N(R9tpopR/(R3tnameRtargsRi((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pythandles  N(R6R7R9R4RR(((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRs  t_AssertWarnsContextcB@s eZdZdZdZRS(sBA context manager used to implement TestCase.assertWarns* methods.cC@svx5tjjD]$}t|ddri|_qqWtjdt|_ |j j |_tj d|j |S(Nt__warningregistry__trecordtalways( R@tmodulestvaluestgetattrR9Rtwarningstcatch_warningsRtwarnings_managert __enter__t simplefilterRb(R3tv((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRscC@so|jj||||dk r&dSy|jj}Wn tk rXt|j}nXd}x|jD]}|j}t ||jsqin|dkr|}n|j dk r|j j t| rqin||_ |j |_ |j|_dSW|dk r-|jdj|j jt|n|jrU|jdj||jn|jdj|dS(Ns"{}" does not match "{}"s{} not triggered by {}s{} not triggered(Rt__exit__R9RbR6RRRtmessageR]RRtwarningRptlinenoRtformatRR(R3texc_typet exc_valuettbtexc_nametfirst_matchingtmtw((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRs8           (R6R7R8RR(((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRs cO@s(t|||}|jd|||S(sFail unless a warning of class warnClass is triggered by callable_obj when invoked with arguments args and keyword arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception. If called with callable_obj omitted or None, will return a context object used like this:: with self.assertWarns(SomeWarning): do_something() An optional keyword argument 'msg' can be provided when assertWarns is used as a context object. The context manager keeps a reference to the first matching warning as the 'warning' attribute; similarly, the 'filename' and 'lineno' attributes give you information about the line of Python code from which the warning was triggered. This allows you to inspect the warning after the assertion:: with self.assertWarns(SomeWarning) as cm: do_something() the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) t assertWarns(RR(R3texpected_warningRRRitcontext((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pyRsR(-t __future__RRRERCRR@RRRmttextwrapRt future.utilsRRRRRtfuture.moves.subprocessRR R t unittest2R R-R.R:R;tTestCaseR<tskipIftskip26RRRRRtassertRaisesRegexpRR9RtobjectRRR(((sB/opt/alt/python27/lib/python2.7/site-packages/future/tests/base.pytsD       ( @     "1