ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PK`]Buxx)__pycache__/__init__.cpython-36.opt-2.pycnu[3 \/@sdS)Nrrr%/usr/lib64/python3.6/test/__init__.pysPK`]2#__pycache__/__init__.cpython-36.pycnu[3 ʣ` @slddlmZddlmZddlZddlZejZejZejZej Z ej Z ej Z ej Z ej Z GdddeZdS))absolute_import) _hawkey_testNc@s&eZdZddZd ddZddZdS) TestSackMixincCs ||_dS)N)repo_dir)selfrr /usr/lib64/python3.6/__init__.py__init__&szTestSackMixin.__init__FcCs$tjj|j|}tj||||dS)N)ospathjoinrr load_repo)rnamefnsystemr rrr load_test_repo)szTestSackMixin.load_test_repocOs&tjj|jd}tj|tj|ddS)Nz @System.repoT)r r r rrrhawkeyZSYSTEM_REPO_NAME)rargskwargsr rrr load_system_repo-szTestSackMixin.load_system_repoN)F)__name__ __module__ __qualname__r rrrrrr r%s r)Z __future__rrrr ZEXPECT_SYSTEM_NSOLVABLESZEXPECT_MAIN_NSOLVABLESZEXPECT_UPDATES_NSOLVABLESZEXPECT_YUM_NSOLVABLESZ FIXED_ARCHZ UNITTEST_DIRZYUM_DIR_SUFFIXZglob_for_repofilesobjectrrrrr s  PK`]2)__pycache__/__init__.cpython-36.opt-1.pycnu[3 ʣ` @slddlmZddlmZddlZddlZejZejZejZej Z ej Z ej Z ej Z ej Z GdddeZdS))absolute_import) _hawkey_testNc@s&eZdZddZd ddZddZdS) TestSackMixincCs ||_dS)N)repo_dir)selfrr /usr/lib64/python3.6/__init__.py__init__&szTestSackMixin.__init__FcCs$tjj|j|}tj||||dS)N)ospathjoinrr load_repo)rnamefnsystemr rrr load_test_repo)szTestSackMixin.load_test_repocOs&tjj|jd}tj|tj|ddS)Nz @System.repoT)r r r rrrhawkeyZSYSTEM_REPO_NAME)rargskwargsr rrr load_system_repo-szTestSackMixin.load_system_repoN)F)__name__ __module__ __qualname__r rrrrrr r%s r)Z __future__rrrr ZEXPECT_SYSTEM_NSOLVABLESZEXPECT_MAIN_NSOLVABLESZEXPECT_UPDATES_NSOLVABLESZEXPECT_YUM_NSOLVABLESZ FIXED_ARCHZ UNITTEST_DIRZYUM_DIR_SUFFIXZglob_for_repofilesobjectrrrrr s  PK`]  support/testresult.pynu['''Test runner and result class for the regression test suite. ''' import functools import io import sys import time import traceback import unittest import xml.etree.ElementTree as ET from datetime import datetime class RegressionTestResult(unittest.TextTestResult): separator1 = '=' * 70 + '\n' separator2 = '-' * 70 + '\n' def __init__(self, stream, descriptions, verbosity): super().__init__(stream=stream, descriptions=descriptions, verbosity=0) self.buffer = True self.__suite = ET.Element('testsuite') self.__suite.set('start', datetime.utcnow().isoformat(' ')) self.__e = None self.__start_time = None self.__results = [] self.__verbose = bool(verbosity) @classmethod def __getId(cls, test): try: test_id = test.id except AttributeError: return str(test) try: return test_id() except TypeError: return str(test_id) return repr(test) def startTest(self, test): super().startTest(test) self.__e = e = ET.SubElement(self.__suite, 'testcase') self.__start_time = time.perf_counter() if self.__verbose: self.stream.write(f'{self.getDescription(test)} ... ') self.stream.flush() def _add_result(self, test, capture=False, **args): e = self.__e self.__e = None if e is None: return e.set('name', args.pop('name', self.__getId(test))) e.set('status', args.pop('status', 'run')) e.set('result', args.pop('result', 'completed')) if self.__start_time: e.set('time', f'{time.perf_counter() - self.__start_time:0.6f}') if capture: if self._stdout_buffer is not None: stdout = self._stdout_buffer.getvalue().rstrip() ET.SubElement(e, 'system-out').text = stdout if self._stderr_buffer is not None: stderr = self._stderr_buffer.getvalue().rstrip() ET.SubElement(e, 'system-err').text = stderr for k, v in args.items(): if not k or not v: continue e2 = ET.SubElement(e, k) if hasattr(v, 'items'): for k2, v2 in v.items(): if k2: e2.set(k2, str(v2)) else: e2.text = str(v2) else: e2.text = str(v) def __write(self, c, word): if self.__verbose: self.stream.write(f'{word}\n') @classmethod def __makeErrorDict(cls, err_type, err_value, err_tb): if isinstance(err_type, type): if err_type.__module__ == 'builtins': typename = err_type.__name__ else: typename = f'{err_type.__module__}.{err_type.__name__}' else: typename = repr(err_type) msg = traceback.format_exception(err_type, err_value, None) tb = traceback.format_exception(err_type, err_value, err_tb) return { 'type': typename, 'message': ''.join(msg), '': ''.join(tb), } def addError(self, test, err): self._add_result(test, True, error=self.__makeErrorDict(*err)) super().addError(test, err) self.__write('E', 'ERROR') def addExpectedFailure(self, test, err): self._add_result(test, True, output=self.__makeErrorDict(*err)) super().addExpectedFailure(test, err) self.__write('x', 'expected failure') def addFailure(self, test, err): self._add_result(test, True, failure=self.__makeErrorDict(*err)) super().addFailure(test, err) self.__write('F', 'FAIL') def addSkip(self, test, reason): self._add_result(test, skipped=reason) super().addSkip(test, reason) self.__write('S', f'skipped {reason!r}') def addSuccess(self, test): self._add_result(test) super().addSuccess(test) self.__write('.', 'ok') def addUnexpectedSuccess(self, test): self._add_result(test, outcome='UNEXPECTED_SUCCESS') super().addUnexpectedSuccess(test) self.__write('u', 'unexpected success') def printErrors(self): if self.__verbose: self.stream.write('\n') self.printErrorList('ERROR', self.errors) self.printErrorList('FAIL', self.failures) def printErrorList(self, flavor, errors): for test, err in errors: self.stream.write(self.separator1) self.stream.write(f'{flavor}: {self.getDescription(test)}\n') self.stream.write(self.separator2) self.stream.write('%s\n' % err) def get_xml_element(self): e = self.__suite e.set('tests', str(self.testsRun)) e.set('errors', str(len(self.errors))) e.set('failures', str(len(self.failures))) return e class QuietRegressionTestRunner: def __init__(self, stream, buffer=False): self.result = RegressionTestResult(stream, None, 0) self.result.buffer = buffer def run(self, test): test(self.result) return self.result def get_test_runner_class(verbosity, buffer=False): if verbosity: return functools.partial(unittest.TextTestRunner, resultclass=RegressionTestResult, buffer=buffer, verbosity=verbosity) return functools.partial(QuietRegressionTestRunner, buffer=buffer) def get_test_runner(stream, verbosity, capture_output=False): return get_test_runner_class(verbosity, capture_output)(stream) if __name__ == '__main__': class TestTests(unittest.TestCase): def test_pass(self): pass def test_pass_slow(self): time.sleep(1.0) def test_fail(self): print('stdout', file=sys.stdout) print('stderr', file=sys.stderr) self.fail('failure message') def test_error(self): print('stdout', file=sys.stdout) print('stderr', file=sys.stderr) raise RuntimeError('error message') suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestTests)) stream = io.StringIO() runner_cls = get_test_runner_class(sum(a == '-v' for a in sys.argv)) runner = runner_cls(sys.stdout) result = runner.run(suite) print('Output:', stream.getvalue()) print('XML: ', end='') for s in ET.tostringlist(result.get_xml_element()): print(s.decode(), end='') print() PK`]r&XX3support/__pycache__/testresult.cpython-36.opt-1.pycnu[3 \ @s6dZddlZddlZddlZddlZddlZddlZddljj Z ddl m Z Gdddej Z GdddZdd d Zdd d Zed kr2GdddejZejZejejeejZeeddejDZeejZejeZ e!dej"e!dddx(e j#e j$D]Z%e!e%j&ddqWe!dS)z=Test runner and result class for the regression test suite. N)datetimecseZdZdddZdddZfddZeddZfd d Zd$d d Z ddZ eddZ fddZ fddZ fddZfddZfddZfddZddZd d!Zd"d#ZZS)%RegressionTestResult=F -cs\tj||ddd|_tjd|_|jjdtjj dd|_ d|_ g|_ t ||_dS)Nr)stream descriptions verbosityTZ testsuitestart )super__init__bufferETZElement_RegressionTestResult__suitesetrZutcnowZ isoformat_RegressionTestResult__e!_RegressionTestResult__start_timeZ_RegressionTestResult__resultsbool_RegressionTestResult__verbose)selfrr r ) __class__//usr/lib64/python3.6/test/support/testresult.pyrs zRegressionTestResult.__init__cCsLy |j}Wntk r"t|SXy|Stk rBt|SXt|S)N)idAttributeErrorstr TypeErrorrepr)clstestZtest_idrrrZ__getIds   zRegressionTestResult.__getIdcsVtj|tj|jd|_}tj|_|j rR|j j |j |d|j j dS)NZtestcasez ... )r startTestr SubElementrrtime perf_counterrrrwritegetDescriptionflush)rr!e)rrrr"+s   zRegressionTestResult.startTestFc KsP|j}d|_|dkrdS|jd|jd|j||jd|jdd|jd|jdd|jrz|jdtj|jd|r|jdk r|jjj }|t j |d_ |j dk r|j jj }|t j |d _ x|jD]t\}}| s| rqt j ||} t|d r>xD|jD],\} } | r,| j| t| n t| | _ q Wqt|| _ qWdS) NnameZstatusrunresultZ completedr$z0.6fz system-outz system-erritems)rrpop_RegressionTestResult__getIdrr$r%Z_stdout_buffergetvaluerstriprr#textZ_stderr_bufferr-hasattrr) rr!Zcaptureargsr)stdoutstderrkvZe2Zk2Zv2rrr _add_result3s4     z RegressionTestResult._add_resultcCs|jr|jj|ddS)Nr)rrr&)rcZwordrrrZ__writeSszRegressionTestResult.__writecCslt|tr0|jdkr|j}q8|jd|j}nt|}tj||d}tj|||}|dj|dj|dS)Nbuiltins.)typemessager=) isinstancer> __module____name__r tracebackformat_exceptionjoin)r Zerr_typeZ err_valueZerr_tbtypenamemsgtbrrrZ__makeErrorDictWs  z$RegressionTestResult.__makeErrorDictcs4|j|d|j|dtj|||jdddS)NT)errorEERROR)r9$_RegressionTestResult__makeErrorDictr addError_RegressionTestResult__write)rr!err)rrrrMjszRegressionTestResult.addErrorcs4|j|d|j|dtj|||jdddS)NT)outputxzexpected failure)r9rLr addExpectedFailurerN)rr!rO)rrrrRosz'RegressionTestResult.addExpectedFailurecs4|j|d|j|dtj|||jdddS)NT)ZfailureFFAIL)r9rLr addFailurerN)rr!rO)rrrrUtszRegressionTestResult.addFailurecs2|j||dtj|||jdd|dS)N)ZskippedSzskipped )r9r addSkiprN)rr!reason)rrrrWyszRegressionTestResult.addSkipcs&|j|tj||jdddS)Nr<ok)r9r addSuccessrN)rr!)rrrrZ~s  zRegressionTestResult.addSuccesscs*|j|ddtj||jdddS)NZUNEXPECTED_SUCCESS)Zoutcomeuzunexpected success)r9r addUnexpectedSuccessrN)rr!)rrrr\s z)RegressionTestResult.addUnexpectedSuccesscCs2|jr|jjd|jd|j|jd|jdS)NrrKrT)rrr&printErrorListerrorsfailures)rrrr printErrorss z RegressionTestResult.printErrorscCs`xZ|D]R\}}|jj|j|jj|d|j|d|jj|j|jjd|qWdS)Nz: rz%s )rr& separator1r' separator2)rZflavorr^r!rOrrrr]s z#RegressionTestResult.printErrorListcCsH|j}|jdt|j|jdtt|j|jdtt|j|S)NZtestsr^r_)rrrZtestsRunlenr^r_)rr)rrrget_xml_elements z$RegressionTestResult.get_xml_element)F)rBrA __qualname__rarbr classmethodr/r"r9rNrLrMrRrUrWrZr\r`r]rd __classcell__rr)rrrs"           rc@seZdZdddZddZdS)QuietRegressionTestRunnerFcCst|dd|_||j_dS)Nr)rr,r)rrrrrrrsz"QuietRegressionTestRunner.__init__cCs||j|jS)N)r,)rr!rrrr+s zQuietRegressionTestRunner.runN)F)rBrArerr+rrrrrhs rhFcCs&|rtjtjt||dStjt|dS)N)Z resultclassrr )r) functoolspartialunittestZTextTestRunnerrrh)r rrrrget_test_runner_classs rlcCst|||S)N)rl)rr Zcapture_outputrrrget_test_runnersrm__main__c@s,eZdZddZddZddZddZd S) TestTestscCsdS)Nr)rrrr test_passszTestTests.test_passcCstjddS)Ng?)r$Zsleep)rrrrtest_pass_slowszTestTests.test_pass_slowcCs*tdtjdtdtjd|jddS)Nr5)filer6zfailure message)printsysr5r6Zfail)rrrr test_failszTestTests.test_failcCs(tdtjdtdtjdtddS)Nr5)rrr6z error message)rsrtr5r6 RuntimeError)rrrr test_errorszTestTests.test_errorN)rBrArerprqrurwrrrrrosroccs|]}|dkVqdS)z-vNr).0arrr srzzOutput:zXML: r=)end)F)F)'__doc__riiortr$rCrkZxml.etree.ElementTreeZetreeZ ElementTreerrZTextTestResultrrhrlrmrBZTestCaseroZ TestSuiteZsuiteZaddTestZ makeSuiteStringIOrsumargvZ runner_clsr5Zrunnerr+r,rsr0Z tostringlistrdsdecoderrrrs4         PK`]]1support/__pycache__/__init__.cpython-36.opt-2.pycnu[3 _Vj@sf edkredddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z!ddl"Z"ddl#m$Z$yddl%Z%ddl&Z&Wnek r>dZ%dZ&YnXy ddl'Z(Wnek rfdZ(YnXy ddl)Z)Wnek rdZ)YnXy ddl*Z*Wnek rdZ*YnXy ddl+Z+Wnek rdZ+YnXy ddl,Z,Wnek rdZ,YnXy ddl-Z-Wnek r.dZ-YnXy ddl.Z.Wnek rVdZ.YnXdddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dag\Z/Gdbd d e0Z1Gdcd d e1Z2Gddd d e1Z3Gdeddej4Z5ej6dgdgdhZ7dhfdjdkdZ8dldmZ9dndoZ:dpd<Z;dqd=ZdZ?dZ@daAdaBdZCdiZDdaEdtdZFdudZGdvdZHdwdxZIejjJdyr*didzd{ZKd|d}ZLd~dZMddZNddZOnejPZLejQZMddZNddZOddZPddZQddZRddZSddZTddZUdd"ZVdjdd#ZWddZXdd$ZYdd%ZZdd&Z[dkdd'Z\dZ]dZ^ej_ej`fddIZae]fddJZbddLZcddZdedZeddZfdnZgdqZhejiejjkdjJddZlejie)dZmejie*dZnejie+dZoejie,dZpejjJdZqejrdZsesdk otesdkZtejdkretrdndZundZuejvdkrdZwndZwdjxewejyZwdZzxLdrD]BZ{yej|ej}e{e{kre~Wne~k rYnXe{ZzPqWewdZejdkr6ddlZejdeZejZdZejvdkrejjdkrewdZyejeWnek rYnXedeefdZnBejdkrydjeWn&ek rewdjedƃZYnXdZxFdsD]d?Zejeed@dAZdBdCZdDdEZGdFdOdOejjZGdGdZdZeZdadHd ZdId1ZdadJdKZdLd:ZdMdNZdOd!ZfdPdQd>Z dfffdRd?Z GdSd\d\Z dTdUZ dVdWZ ffdXdYZgfdZd`Zdad[dFZej6d\d]Zd^daZGd_d`d`ZGdadbdbZej6dcddZdedfZdS(z test.supportz.support must be imported from the test packageN)get_test_runner PIPE_MAX_SIZEverbose max_memuse use_resourcesfailfastError TestFailed TestDidNotRunResourceDenied import_moduleimport_fresh_module CleanImportunloadforgetrecord_original_stdoutget_original_stdoutcaptured_stdoutcaptured_stdincaptured_stderrTESTFNSAVEDCWDunlinkrmtreetemp_cwdfindfilecreate_empty_file can_symlinkfs_is_case_insensitiveis_resource_enabledrequiresrequires_freebsd_versionrequires_linux_versionrequires_mac_verrequires_hashdigestcheck_syntax_errorTransientResourcetime_outsocket_peer_resetioerror_peer_resettransient_internetBasicTestRunner run_unittest run_doctestskip_unless_symlink requires_gzip requires_bz2 requires_lzma bigmemtestbigaddrspacetest cpython_only get_attributerequires_IEEE_754skip_unless_xattr requires_zlibanticipate_failureload_package_testsdetect_api_mismatch check__all__requires_android_levelrequires_multiprocessing_queue is_jython is_androidcheck_impl_detail unix_shellsetswitchintervalHOST IPV6_ENABLEDfind_unused_port bind_portopen_urlresourcebind_unix_socket temp_umask reap_children TestHandlerthreading_setupthreading_cleanup reap_threads start_threadscheck_warningscheck_no_resource_warningEnvironmentVarGuardrun_with_locale swap_item swap_attrMatcher set_memlimitSuppressCrashReportsortdict run_with_tzPGOmissing_compiler_executablefd_countc@s eZdZdS)r N)__name__ __module__ __qualname__rcrc-/usr/lib64/python3.6/test/support/__init__.pyr |sc@s eZdZdS)r N)r`rarbrcrcrcrdr sc@s eZdZdS)r N)r`rarbrcrcrcrdr sc@s eZdZdS)r N)r`rarbrcrcrcrdr sTc cs8|r.tjtjddtdVWdQRXndVdS)Nignorez.+ (module|package))warningscatch_warningsfilterwarningsDeprecationWarning)rercrcrd_ignore_deprecated_importss  rjF) required_oncCsft|Ty tj|Stk rV}z&tjjt|r8tj t |WYdd}~XnXWdQRXdS)N) rj importlibr ImportErrorsysplatform startswithtupleunittestSkipTeststr)name deprecatedrkmsgrcrcrdr s  cCs^|tjkrt|tj|=x>ttjD]0}||ks@|j|dr&tj|||<tj|=q&WdS)N.)rnmodules __import__listrp)ru orig_modulesmodnamercrcrd_save_and_remove_modules r~c Cs>d}ytj|||<Wntk r.d}YnXdtj|<|S)NTF)rnryKeyError)rur|Zsavedrcrcrd_save_and_block_modules  rcCs|r tjSddS)NcSs|S)Nrc)frcrcrdsz$anticipate_failure..)rrZexpectedFailure)Z conditionrcrcrdr:scCsF|dkr d}tjjtjjtjjt}|j|||d}|j||S)Nztest*)Z start_dirZ top_level_dirpattern)ospathdirname__file__ZdiscoverZaddTests)Zpkg_dirloaderZstandard_testsrZtop_dirZ package_testsrcrcrdr;s c Cst|i}g}t||zfyHx|D]}t||q&Wx |D]}t||s>|j|q>Wtj|}Wntk r~d}YnXWdx|jD]\} } | tj | <qWx|D] } tj | =qWX|SQRXdS)N) rjr~rappendrlr rmitemsrnry) ruZfreshZblockedrvr|Znames_to_removeZ fresh_nameZ blocked_nameZ fresh_moduleZ orig_namemoduleZname_to_removercrcrdrs$      c Cs>yt||}Wn&tk r4tjd||fYnX|SdS)Nzobject %r has no attribute %r)getattrAttributeErrorrrrs)objruZ attributercrcrdr6s cCs|adS)N)_original_stdout)stdoutrcrcrdr0scCs tptjS)N)rrnrrcrcrcrdr4sc Cs&y tj|=Wntk r YnXdS)N)rnryr)rurcrcrdr7s cGsny||Stk rh}zDtdkrHtd|jj|ftd|j|ftj|tj||Sd}~XnXdS)Nz%s: %sz re-run %s%r) OSErrorrprint __class__r`rchmodstatS_IRWXU)rfuncargserrrcrcrd _force_run=srwincCs|||r|}ntjj|\}}|p(d}d}x<|dkrjtj|}|rJ|n||ksVdStj||d9}q0Wtjd|tdddS)NrxgMbP?g?rz)tests may fail, delete still pending for ) stacklevel) rrsplitlistdirtimesleeprfwarnRuntimeWarning)rpathnamewaitallrrutimeoutLrcrcrd_waitforHs     rcCsttj|dS)N)rrr)filenamercrcrd_unlinkisrcCsttj|dS)N)rrrmdir)rrcrcrd_rmdirlsrcs,fddt|ddtdd|dS)Ncsxt|tj|D]}tjj||}ytj|j}Wn<tk rn}z td||ft j dd}WYdd}~XnXt j |rt |ddt|tj|qt|tj|qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s)filerT)r)rrrrjoinlstatst_moderrrn __stderr__rS_ISDIRrrr)rrufullnamemodeexc) _rmtree_innerrcrdrps   z_rmtree.._rmtree_innerT)rcSst|tj|S)N)rrr)prcrcrdrsz_rmtree..)r)rrc)rrd_rmtreeos rc Cs^y ddl}Wntk r Yn:X|jt|d}|jjj||t|}|rZ|d|S|S)Nrr)ctypesrmZcreate_unicode_bufferlenwindllkernel32ZGetLongPathNameW)rrbufferZlengthrcrcrd _longpaths    rc sFytj|dStk r"YnXfdd|tj|dS)Nc sx~t|tj|D]l}tjj||}ytj|j}Wntk rJd}YnXtj |rn|t|tj |qt|tj |qWdS)Nr) rrrrrrrrrrrr)rrurr)rrcrdrs  z_rmtree.._rmtree_inner)shutilrrrr)rrc)rrdrs  cCs|S)Nrc)rrcrcrdrsc Cs*y t|Wnttfk r$YnXdS)N)rFileNotFoundErrorNotADirectoryError)rrcrcrdrs c Cs&y t|Wntk r YnXdS)N)rr)rrcrcrdrs rc Cs&y t|Wntk r YnXdS)N)rr)rrcrcrdrs cCsBtjj|}tjjtjj|}tjj||d}tj|||S)Nc) rlutilcache_from_sourcerrrabspathrrename)sourceZpyc_fileZup_oneZ legacy_pycrcrcrdmake_legacy_pycs   rcCs\t|xNtjD]D}tjj||d}t|dx dD]}ttjj||dq8WqWdS)Nz.pyrrr) optimization)rrr) rrnrrrrrlrr)r}rroptrcrcrdrs    csttdrtjSd}tjjdrddlddld}d}Gfdddj}j j }|j }|sjj |}j j}|j||j|j|j|}|sj t|j|@sd}ntjdkrVdd lm} mm} m} dd lm} | j| d } | jdkrd }nFGfd dd| }|}| |}| j|dksR| j|dkrVd}|sy.ddlm}|}|j|j |j!Wn\t"k r}z>t#|}t$|dkr|ddd}dj%t&|j'|}WYdd}~XnX|t_(| t_tjS)Nresultrrrcs.eZdZdjjfdjjfdjjfgZdS)z*_is_gui_available..USEROBJECTFLAGSZfInheritZ fReserveddwFlagsN)r`rarbwintypesZBOOLDWORD_fields_rc)rrcrdUSEROBJECTFLAGSs  rz,gui not available (WSF_VISIBLE flag not set)darwin)cdllc_intpointer Structure) find_libraryZApplicationServicesz0gui tests cannot run without OS X window managercseZdZdfdfgZdS)z._is_gui_available..ProcessSerialNumberZ highLongOfPSNZ lowLongOfPSNN)r`rarbrrc)rrcrdProcessSerialNumbersrz#cannot run without OS X gui process)Tk2z [...]zTk unavailable due to {}: {}))hasattr_is_gui_availablerrnrorprZctypes.wintypesrrZuser32ZGetProcessWindowStationZWinErrorrrZGetUserObjectInformationWZbyrefZsizeofboolrrrrZ ctypes.utilrZ LoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterrZwithdrawupdateZdestroy Exceptionrtrformattyper`reason)rZ UOI_FLAGSZ WSF_VISIBLErZdllhZuofZneededresrrrrZ app_servicesrZpsnZpsn_prrooteZ err_stringrc)rrrdrsh         rcCstdkp|tkS)N)r)resourcercrcrdr $scCs>t|s |dkrd|}t||dkr:t r:ttjdS)Nz"Use of the %r resource not enabledgui)r r rr)rrwrcrcrdr!,s csfdd}|S)Ncs$tjfdd}|_|S)Nc stjkrztjjddd}yttt|jd}Wntk rLYn.X|krzdjtt }t j d||f||S)N-rrrxz(%s version %s or higher required, not %s) rosystemreleaserrqmapint ValueErrorrrtrrrs)rkw version_txtversionmin_version_txt)r min_versionsysnamercrdwrapper=s z:_requires_unix_version..decorator..wrapper) functoolswrapsr)rr)rr)rrd decorator<sz)_requires_unix_version..decoratorrc)rrrrc)rrrd_requires_unix_version5srcGs td|S)NZFreeBSD)r)rrcrcrdr"PscGs td|S)NZLinux)r)rrcrcrdr#Yscsfdd}|S)Ncs"tjfdd}|_|S)Nc sxtjdkrntjd}yttt|jd}Wntk rBYn,X|krndjtt }t j d||f||S)Nrrrxz&Mac OS X %s or higher required, not %s) rnroZmac_verrqrrrrrrtrrrs)rrrrr)rrrcrdrjs   z4requires_mac_ver..decorator..wrapper)rrr)rr)r)rrdrisz#requires_mac_ver..decoratorrc)rrrc)rrdr$bs csfdd}|S)Ncstjfdd}|S)Nc sXy&rtdk rtjn tjWn&tk rLtjddYnX||S)Nz hash digest 'z' is not available.)_hashlibnewhashlibrrrrs)rkwargs) digestnameropensslrcrdrs  z7requires_hashdigest..decorator..wrapper)rr)rr)rr)rrdrs z&requires_hashdigest..decoratorrc)rrrrc)rrrdr%}s z 127.0.0.1z::1cCs"tj||}t|}|j~|S)N)socketrHclose)familyZsocktypeZtempsockportrcrcrdrGs 8 c Cs|jtjkr|jtjkrttdr>|jtjtjdkr>t dttdr~y |jtjtj dkrft dWnt k r|YnXttdr|j tjtj d|j|df|jd}|S)N SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets! SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!SO_EXCLUSIVEADDRUSEr)rrAF_INETr SOCK_STREAMrZ getsockoptZ SOL_SOCKETrr rrZ setsockoptrbindZ getsockname)sockhostrrcrcrdrHs     c Cs:y|j|Wn&tk r4|jtjdYnXdS)Nzcannot bind AF_UNIX sockets)r PermissionErrorrrrrs)r ZaddrrcrcrdrJs cCsZtjrVd}z.dec)rr)rrrc)rrdsystem_must_validate_certs rriZdoubleZIEEEztest requires IEEE 754 doublesz requires zlibz requires gzipz requires bz2z requires lzmajavaANDROID_API_LEVELwin32z/system/bin/shz/bin/shz$testz@testz {}_{}_tmpæİŁφКא،تก €u -àòɘŁğrZNFDntru-共Ł♡ͣztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effectives-surrogateescapewrccsd}|dkr&tj}d}tjj|}nBytj|d}Wn.tk rf|sNtjd|t ddYnX|rttj }z |VWd|r|tj krt |XdS)NFTz+tests may fail, unable to create temp dir: )r) tempfilemkdtemprrrealpathmkdirrrfrrgetpidr)rquietZ dir_createdpidrcrcrdtemp_dirs&   r1ccsftj}ytj|Wn.tk rD|s,tjd|tddYnXztjVWdtj|XdS)Nz)tests may fail, unable to change CWD to: r))r)rgetcwdchdirrrfrr)rr/Z saved_dirrcrcrd change_cwd s  r4tempcwdccs:t||d$}t||d }|VWdQRXWdQRXdS)N)rr/)r/)r1r4)rur/Z temp_pathZcwd_dirrcrcrdr$sumaskc cs&tj|}z dVWdtj|XdS)N)rr6)r6ZoldmaskrcrcrdrK8s  datacCsbtjj|r|S|dk r&tjj||}tgtj}x*|D]"}tjj||}tjj|r8|Sq8W|S)N)rrisabsr TEST_HOME_DIRrnexists)rZsubdirrZdnfnrcrcrdrIs    cCs(tj|tjtjBtjB}tj|dS)N)ropenO_WRONLYO_CREATO_TRUNCr)rfdrcrcrdr[scCs,t|j}dd|D}dj|}d|S)NcSsg|] }d|qS)z%r: %rrc).0Zpairrcrcrd cszsortdict..z, z{%s})sortedrr)dictrZ reprpairsZ withcommasrcrcrdr[`s  c Cs*ttd}z|jS|jttXdS)Nwb)r<rfilenorr)rrcrcrd make_bad_fdgs  rG)linenooffsetc Csp|jt}t|ddWdQRX|j}|j|j|dk rJ|j|j||j|j|dk rl|j|j|dS)Nz exec) assertRaises SyntaxErrorcompileZ exceptionZassertIsNotNonerH assertEqualrI)testcaseZ statementrHrIcmrrcrcrdr&ss   c sVddl}ddl}jdd|jj|djdd}tjjt |}fdd}tjj |r|||}|dk rt|St |t dt rtd |td |jj}tr|jjd|j|d d}tr|jjdd krtj|d}zBt|d.} |j} x| r| j| |j} qWWdQRXWd|jX||}|dk rF|Std|dS)Nrcheckr/rcs>t|f}dkr|S|r2|jd|S|jdS)Nr)r<seekr)r;r)rrQrrcrdcheck_valid_files z*open_urlresource..check_valid_fileZurlfetchz fetching %s ...)rAccept-Encodinggzip)rzContent-Encoding)ZfileobjrEzinvalid resource %r)rUrV)Zurllib.requestZ urllib.parsepopparseZurlparserrrr TEST_DATA_DIRr:rr!rrrZrequestZ build_openerrVZ addheadersrr<ZheadersgetZGzipFilereadwriterr ) Zurlrrurllibrr;rTropeneroutsrc)rrQrrdrI~s<         c@s0eZdZddZddZeddZddZd S) WarningsRecordercCs||_d|_dS)Nr) _warnings_last)selfZ warnings_listrcrcrd__init__szWarningsRecorder.__init__cCsDt|j|jkr t|jd|S|tjjkr0dStd||fdS)Nrz%r has no attribute %rrX)rrdrerrfWarningMessage_WARNING_DETAILSr)rfattrrcrcrd __getattr__s  zWarningsRecorder.__getattr__cCs|j|jdS)N)rdre)rfrcrcrdrfszWarningsRecorder.warningscCst|j|_dS)N)rrdre)rfrcrcrdresetszWarningsRecorder.resetN)r`rarbrgrkpropertyrfrlrcrcrcrdrcs rcc cs tjd}|jjd}|r"|jtjdd }tjdjdt |VWdQRXt |}g}xz|D]r\}}d} xH|ddD]8}|j } t j |t| t jrt| j|rd} |j|qW| rf| rf|j||jfqfW|rtd|d |rtd |d dS) NrZ__warningregistry__T)recordrfalwaysFzunhandled warning %srz)filter (%r, %s) did not catch any warning)rn _getframe f_globalsr\clearrfrgry simplefilterrcr{messagerematchrtI issubclassrremoverr`AssertionError) filtersr/frameregistrywZreraiseZmissingrwcatseenZwarningrcrcrd_filterwarningss0    rcOs.|jd}|s$dtff}|dkr$d}t||S)Nr/rT)r\Warningr)r{rr/rcrcrdrRs   rc csHtjdd&}tjd||ddV|r.tWdQRX|j|gdS)NT)rnro)rtcategory)rfrgrh gc_collectrN)rOrtrZforce_gcwarnsrcrcrdcheck_no_warningssrc csBtjdd }tjdtddVtWdQRX|j|gdS)NT)rnro)r)rfrgrhResourceWarningrrN)rOrrcrcrdrSs c@s$eZdZddZddZddZdS)rcGsNtjj|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rnrycopyoriginal_modulesr`)rfZ module_namesZ module_namerrcrcrdrg?s      zCleanImport.__init__cCs|S)Nrc)rfrcrcrd __enter__LszCleanImport.__enter__cGstjj|jdS)N)rnryrr)rf ignore_excrcrcrd__exit__OszCleanImport.__exit__N)r`rarbrgrrrcrcrcrdr3s  c@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)rTcCstj|_i|_dS)N)renviron_environ_changed)rfrcrcrdrgXszEnvironmentVarGuard.__init__cCs |j|S)N)r)rfenvvarrcrcrd __getitem__\szEnvironmentVarGuard.__getitem__cCs*||jkr|jj||j|<||j|<dS)N)rrr\)rfrvaluercrcrd __setitem___s zEnvironmentVarGuard.__setitem__cCs2||jkr|jj||j|<||jkr.|j|=dS)N)rrr\)rfrrcrcrd __delitem__es  zEnvironmentVarGuard.__delitem__cCs |jjS)N)rkeys)rfrcrcrdrlszEnvironmentVarGuard.keyscCs t|jS)N)iterr)rfrcrcrd__iter__oszEnvironmentVarGuard.__iter__cCs t|jS)N)rr)rfrcrcrd__len__rszEnvironmentVarGuard.__len__cCs |||<dS)Nrc)rfrrrcrcrdsetuszEnvironmentVarGuard.setcCs ||=dS)Nrc)rfrrcrcrdunsetxszEnvironmentVarGuard.unsetcCs|S)Nrc)rfrcrcrdr{szEnvironmentVarGuard.__enter__cGsJx<|jjD].\}}|dkr0||jkr:|j|=q ||j|<q W|jt_dS)N)rrrrr)rfrkvrcrcrdr~s   zEnvironmentVarGuard.__exit__N)r`rarbrgrrrrrrrrrrrcrcrcrdrTSsc@s$eZdZddZddZddZdS) DirsOnSysPathcGs(tjdd|_tj|_tjj|dS)N)rnroriginal_valueoriginal_objectextend)rfpathsrcrcrdrgszDirsOnSysPath.__init__cCs|S)Nrc)rfrcrcrdrszDirsOnSysPath.__enter__cGs|jt_|jtjdd<dS)N)rrnrr)rfrrcrcrdrszDirsOnSysPath.__exit__N)r`rarbrgrrrcrcrcrdrs rc@s&eZdZddZddZdddZdS) r'cKs||_||_dS)N)rattrs)rfrrrcrcrdrgszTransientResource.__init__cCs|S)Nrc)rfrcrcrdrszTransientResource.__enter__NcCsT|dk rPt|j|rPx:|jjD]$\}}t||s4Pt|||kr Pq WtddS)Nz%an optional resource is not available)rxrrrrrr )rfZtype_r tracebackrjZ attr_valuercrcrdrs zTransientResource.__exit__)NNN)r`rarbrgrrrcrcrcrdr's)errnog>@)rerrnosc #spd d!d"d#d$d%g}d'd)d+d-d.g}td||gsRdd|Ddd|Dfdd}tj}zy|dk rtj|dVWntjk r}z&trtjj j dd|WYdd}~Xnt k rZ}zpx^|j }t |dkrt |dt r|d}n*t |dkr8t |dt r8|d}nPqW||WYdd}~XnXWdtj|XdS)/N ECONNREFUSEDo ECONNRESETh EHOSTUNREACHq ENETUNREACHe ETIMEDOUTn EADDRNOTAVAILc EAI_AGAINr)EAI_FAILr EAI_NONAMEr EAI_NODATA WSANO_DATA*zResource %r is not availablecSsg|]\}}tt||qSrc)rr)rArunumrcrcrdrBsz&transient_internet..cSsg|]\}}tt||qSrc)rr)rArurrcrcrdrBscst|dd}t|tjst|tjr,|kst|tjjrTd|jkoNdknst|tjj rd|j ksd|j ksd|j ks|krt st j jjdd|dS) NriiWConnectionRefusedError TimeoutErrorEOFErrorr )r isinstancerrZgaierrorr_errorZ HTTPErrorcodeZURLErrorrrrnstderrr^r)rn)captured_errnosdenied gai_errnosrcrd filter_errors     z(transient_internet..filter_errorrrr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)r rZgetdefaulttimeoutZsetdefaulttimeoutnntplibZNNTPTemporaryErrorrrnrr^rrrr) Z resource_namerrZdefault_errnosZdefault_gai_errnosrZ old_timeoutrarc)rrrrdr+sP     c csFddl}tt|}tt||jztt|VWdtt||XdS)Nr)iorrnsetattrStringIO)Z stream_namerZ orig_stdoutrcrcrdcaptured_outputs  rcCstdS)Nr)rrcrcrcrdrscCstdS)Nr)rrcrcrcrdr%scCstdS)Nstdin)rrcrcrcrdr.s cCs*tjtrtjdtjtjdS)Ng?)gcZcollectr@rrrcrcrcrdr;s  rc cs.tj}tjz dVWd|r(tjXdS)N)r isenableddisableenable)Zhave_gcrcrcrd disable_gcKs  rcCs:tjdp d}d}x|jD]}|jdr|}qW|dkS)N PY_CFLAGSrz-O-O0-Og)rrr) sysconfigget_config_varrrp)ZcflagsZ final_optrrcrcrdpython_is_optimizedVs  rZnPZ0ngettotalrefcountZ2PZ0PrcCstjt|tS)N)structcalcsize_header_align)fmtrcrcrd calcobjsizegsrcCstjt|tS)N)rr_vheaderr)rrcrcrd calcvobjsizejsr cCspddl}tj|}t|tkr(|jt@sBt|tkrLt|jt@rL||j7}dt|||f}|j|||dS)Nrz&wrong size for %s: got %d, expected %d) _testcapirn getsizeofr __flags___TPFLAGS_HEAPTYPE_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrN)testosizerrrwrcrcrd check_sizeofqs  rcsfdd}|S)Ncs$fdd}j|_j|_|S)Ncsy ddl}t|}|j|}Wn(tk r6YnBd}}Yn0Xx,D]$}y|j||PWqPYqPXqPWz ||S|r|r|j||XdS)Nr)localer setlocaler)rkwdsrrZ orig_localeloc)catstrrlocalesrcrdinners$     z1run_with_locale..decorator..inner)r`__doc__)rr)rr)rrdrsz"run_with_locale..decoratorrc)rrrrc)rrrdrUscsfdd}|S)Ncs"fdd}j|_j|_|S)Ncsy tj}Wntk r(tjdYnXdtjkr@tjd}nd}tjd<|z ||S|dkrrtjd=n |tjd<tjXdS)Nztzset requiredZTZ)rtzsetrrrrsrr)rrrZorig_tz)rtzrcrdrs       z-run_with_tz..decorator..inner)r`r)rr)r)rrdrszrun_with_tz..decoratorrc)rrrc)rrdr\s cCsdttdtd}tjd|tjtjB}|dkr>td|ftt|j d||j dj }|a |t krrt }|t dkrtd|f|adS)Ni)rmgtz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rrr)z$Memory limit %r too low to be useful)_1M_1Grurv IGNORECASEVERBOSErrfloatgrouplowerreal_max_memuseMAX_Py_ssize_t_2Gr)limitZsizesrZmemlimitrcrcrdrYs $ c@s$eZdZddZddZddZdS)_MemoryWatchdogcCsdjtjd|_d|_dS)Nz/proc/{pid}/statm)r0F)rrr.procfilestarted)rfrcrcrdrgsz_MemoryWatchdog.__init__cCsyt|jd}Wn<tk rL}z tjdj|ttjj dSd}~XnXt d}t j tj |g|t jd|_|jd|_dS)Nrz!/proc not available for stats: {}zmemory_watchdog.py)rrT)r<r rrfrrrrnrflushr subprocessPopen executableZDEVNULL mem_watchdogrr )rfrrZwatchdog_scriptrcrcrdstarts   z_MemoryWatchdog.startcCs|jr|jj|jjdS)N)r rZ terminatewait)rfrcrcrdstops z_MemoryWatchdog.stopN)r`rarbrgrrrcrcrcrdr sr csfdd}|S)Ncs fdd__S)Nc sj}j}tsd}n|}ts$ rFt||krFtjd||dtr|tr|ttdj||ddt}|j nd}z ||S|r|j XdS) Niz'not enough memory: %.1fG minimum neededir)z* ... expected peak memory use: {peak:.1f}G)Zpeaki@i@) rmemuserrrrsrrrr rr)rfrrmaxsizeZwatchdog)dry_runrrrcrdrs*    z.bigmemtest..decorator..wrapper)rr)r)rrr)rrrdrszbigmemtest..decoratorrc)rrrrrc)rrrrdr3s !csfdd}|S)NcsDttkr8td kr$td kr$tjdq@tjdtd n|SdS) Nr?rz-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir)llli@)rrrrrs)rf)rrcrdr3sz!bigaddrspacetest..wrapperrc)rrrc)rrdr41s c@seZdZddZdS)r,cCstj}|||S)N)rrZ TestResult)rfrrrcrcrdrunDszBasicTestRunner.runN)r`rarbrrcrcrcrdr,CscCs|S)Nrc)rrcrcrd_idIsrcCs<|dkrt rtjtjSt|r(tStjdj|SdS)Nrzresource {0!r} is not enabled)rrrskiprr rr)rrcrcrdrequires_resourceLs  rcCs&trt|krtjd|tfStSdS)Nz%s at Android API level %d)rA_ANDROID_API_LEVELrrrr)levelrrcrcrdr>Ts  cCstdd|S)NT)cpython) impl_detail)rrcrcrdr5[scKsVtf|rtS|dkrLt|\}}|r,d}nd}t|j}|jdj|}tj|S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or ) rBr _parse_guardsrCrrrrrr)rwguardsZ guardnamesdefaultrcrcrdr!as   r!c CsTtdkr:ddl}y|jdaWntk r8daYnXd}trF|Stj||S)NrTFz6requires a functioning shared semaphore implementation)_have_mp_queuemultiprocessingZQueuermrrr)rr&rwrcrcrdr?os cCs*|sddidfSt|jd}|| fS)Nr TFr)r{values)r#Zis_truercrcrdr"~s r"cKs t|\}}|jtjj|S)N)r"r\roZpython_implementationr)r#r$rcrcrdrBs cs,ttdsStjfdd}|SdS)Ngettracec s.tj}ztjd||Stj|XdS)N)rnr(settrace)rrZoriginal_trace)rrcrdrs   zno_tracing..wrapper)rrnrr)rrrc)rrd no_tracings r*cCs tt|S)N)r*r5)rrcrcrd refcount_testsr+cCsRg}xB|jD]8}t|tjr2t|||j|q ||r |j|q W||_dS)N)Z_testsrrr TestSuite _filter_suiter)suiteZpredZnewtestsrrcrcrdr-s    r-cCsttjttdk d}|j|}tdk r4tj|j|js>t |j st |j dkrl|j rl|j dd}n6t |j dkr|j r|j dd}nd}ts|d7}t|dS)N) verbosityZcapture_outputrrzmultiple errors occurredz!; run in verbose mode for details)rrnrrjunit_xml_listrrZget_xml_elementZtestsRunr Z wasSuccessfulrerrorsZfailuresr )r.Zrunnerrrrcrcrd _run_suites"  r2cCstdkr dSt|jSdS)NT)_match_test_funcid)rrcrcrd match_testsr5cCsd|kotjd| S)Nrxz[?*\[\]])rusearch)rrcrcrd_is_full_match_testsr7csr|tkr dS|sd}f}nHttt|r4t|j}n.djttj|}t j |j fdd}|}t |a|a dS)N|cs$|r dStt|jdSdS)NTrx)anyrr)Ztest_id) regex_matchrcrdmatch_test_regexsz)set_match_tests..match_test_regex)_match_test_patternsallrr7r __contains__rfnmatch translaterurMrvrqr3)ZpatternsrZregexr;rc)r:rdset_match_testss   rAcGstjtjf}tj}xh|D]`}t|trT|tjkrJ|jtjtj|qzt dqt||rj|j|q|jtj |qWt |t t |dS)Nz)str arguments must be keys in sys.modules)rrr,ZTestCaserrtrnryZaddTestZ findTestCasesrZ makeSuiter-r5r2)classesZ valid_typesr.clsrcrcrdr-s        cCsdS)Nrcrcrcrcrd_check_docstrings(srDWITH_DOC_STRINGSztest requires docstringscCs`ddl}|dkrt}nd}|j|||d\}}|rBtd||ftrXtd|j|f||fS)Nr)r optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)doctestrZtestmodr rr`)rr/rFrGrrrcrcrdr.9scCs tjjfS)N)rnryrrcrcrcrd modules_setupTsrHcCs:ddtjjD}tjjtjj|tjj|dS)NcSs"g|]\}}|jdr||fqS)z encodings.)rp)rArrrcrcrdrB[sz#modules_cleanup..)rnryrrrr)Z oldmodulesZ encodingsrcrcrdmodules_cleanupWs  rIcCs"trtjtjjfSdffSdS)Nr)_thread_count threading _danglingrrcrcrcrdrNzscGsJtsdSd}x8t|D],}tjtjf}||kr2PtjdtqWdS)Ndg{Gz?)rJrangerKrLrMrrr)Zoriginal_valuesZ _MAX_COUNTcountr'rcrcrdrOs cs"tsStjfdd}|S)Nc st}z|St|XdS)N)rNrO)rkey)rrcrdrszreap_threads..decorator)rJrr)rrrc)rrdrPsN@ccstj}z dVWdtj}||}xjtj}||kr8Ptj|kr|tj|}d||d|dd|d|d }t|tjdtq&WXdS)Nz!wait_threads() failed to cleanup z threads after z.1fz seconds (count: z , old count: )g{Gz?)rJrKrZ monotonicrzrr)rZ old_countZ start_timeZdeadlinerPZdtrwrcrcrdwait_threads_exits   $ rTc CsZttdrVd}xFy2tj|tj\}}|dkr.Ptd|tjdWqPYqXqWdS)Nwaitpidrrz2Warning -- reap_children() reaped child process %s)rrX)rrrUWNOHANGrrnr)Z any_processr0ZstatusrcrcrdrLs ccs*t|}g}zZy$x|D]}|j|j|qWWn*trVtdt|t|fYnXdVWdz|rt|tj}}xltddD]^}|d7}x$|D]}|jt |tjdqWdd|D}|sPtrtdt||fqWWdd d|D}|r"t j t j td t|XXdS) Nz/Can't start %d threads, only %d threads startedrr<g{Gz?cSsg|]}|jr|qSrc)isAlive)rArrcrcrdrBsz!start_threads..z7Unable to join %d threads during a period of %d minutescSsg|]}|jr|qSrc)rX)rArrcrcrdrBszUnable to join %d threads)r{rrrrrrrOrmax faulthandlerZdump_tracebackrnrrz)ZthreadsZunlockr rZendtimeZ starttimerrcrcrdrQs>     c csnt||rtt|tt|}|r(|t|8}tdd|D}|S)Ncss(|] }|jd s|jdr|VqdS)___N)rpendswith)rArrcrcrd sz&detect_api_mismatch..)rrx)Zref_apiZ other_apireZ missing_itemsrcrcrdr< s  cCs|dkr|jf}nt|tr"|f}t|}xbt|D]V}|jds4||krLq4t||}t|dd|kst|d r4t|tj  r4|j |q4W|j |j |dS)Nrra) r`rrtrrxrprrtypes ModuleTypeaddZassertCountEqual__all__)Z test_caserZname_of_moduleZextraZ blacklistZexpectedrurrcrcrdr= s)    c@s$eZdZdZdZddZddZdS)rZNc Csrtjjdrddl}|jj|_d}|jj||_|jj|j|Byddl }|j Wnt t fk rlYnLXi|_ x|j|j|jgD].}|j ||j}|j||j}||f|j |<qWntdk r y*tjtj|_tjtjd|jdfWnttfk rYnXtjdkrndddd g}tj|tjtjd }||jd} WdQRX| jd krntd d dd|S)Nrrrrrz/usr/bin/defaultsr]zcom.apple.CrashReporterZ DialogType)rrs developerz:this test triggers the Crash Reporter, that is intentionalrT)endr ) rnrorprrr_k32 SetErrorMode old_valuemsvcrtCrtSetReportModerrm old_modesCRT_WARN CRT_ERROR CRT_ASSERTZCRTDBG_MODE_FILECrtSetReportFileZCRTDBG_FILE_STDERRrZ getrlimit RLIMIT_CORE setrlimitrrrrPIPEZ communicaterar) rfrZSEM_NOGPFAULTERRORBOXr report_typeold_modeold_filecmdprocrrcrcrdr2 sN        zSuppressCrashReport.__enter__c Gs|jdkrdStjjdrl|jj|j|jrddl}xj|jjD]$\}\}}|j |||j ||qBWn6t dk ryt j t j |jWnttfk rYnXdS)Nrr)rrnrorprrrrrrrrrrrr)rfrrrrrrcrcrdrs s   zSuppressCrashReport.__exit__)r`rarbrrrrrcrcrcrdrZ) sAc srtdyjWn$ttfk r@tdYnXdfdd}|j|t|dS)NFTcs rtn tdS)N)rr[rc) attr_is_local attr_nameobject_to_patchrrcrdcleanup szpatch..cleanup)rrjrrZ addCleanupr)Z test_instancerrZ new_valuerrc)rrrrrdpatch s  rc CsFy ddl}Wntk r YnX|jr4tjdddl}|j|S)NrzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations) tracemallocrmZ is_tracingrrrsrrun_in_subinterp)rrrrcrcrdr s  rcsHGfddd|}d||||jttt|jdS)NcseZdZfddZdS)z%check_free_after_iterating..Ac s*dy tWntk r$YnXdS)NT)next StopIteration)rf)doneitrcrd__del__ s  z-check_free_after_iterating..A.__del__N)r`rarbrrc)rrrcrdA srF)rKrrrZ assertTrue)rrrCrrrc)rrrdcheck_free_after_iterating s   rcCs|ddlm}m}m}|j}|j|xP|jD]F}|r@||kr@q.t||}|rPn |dkrZq.|j|ddkr.|dSq.WdS)Nr) ccompilerrspawn) Z distutilsrrrZ new_compilerZcustomize_compilerZ executablesrZfind_executable)Z cmd_namesrrrZcompilerrurrcrcrdr^ s     cCs@d}tr6||kr6tdkr.tjddgjdkatr6|}tj|S)Ngh㈵>Zgetpropzro.kernel.qemu1)rA_is_android_emulatorrZ check_outputrarnrD)ZintervalZminimum_intervalrcrcrdrD s c cs>tjj}tj}ztjdVWd|r8tj|ddXdS)NT)rZ all_threads)rnrrFrZ is_enabledrr)r@rrcrcrddisable_faulthandler s  rc /Cstjjd r8ytjd}t|dStk r6YnXd}ttdrjytjd}Wnt k rhYnXd}tjdkryd dl }|j Wnt t fk rYn0Xi}x(|j|j|jfD]}|j |d ||<qWzpd }xft|D]Z}ytj|}Wn4t k r(}z|jtjkrWYdd}~XqXtj||d7}qWWd|dk rzx*|j|j|jfD]}|j |||q`WX|S) Nlinuxfreebsdz /proc/self/fdrsysconf SC_OPEN_MAXrr)rr)rnrorprrrrrrrrrrrmrrrrOduprZEBADFr) namesZMAXFDrrrrPr@Zfd2rrcrcrdr_ sP          c@s$eZdZddZddZddZdS) SaveSignalsc Csjddl}||_ttd|j|_x>dD]6}yt||}Wntk rNw&YnX|jj|q&Wi|_dS)NrrSIGKILLSIGSTOP)rr) signalr{rONSIGsignalsrrryrf)rfrZsignamesignumrcrcrdrgM s zSaveSignals.__init__cCs4x.|jD]$}|jj|}|dkr"q||j|<qWdS)N)rr getsignalrf)rfrhandlerrcrcrdsaveZ s   zSaveSignals.savecCs*x$|jjD]\}}|jj||q WdS)N)rfrr)rfrrrcrcrdrestoref szSaveSignals.restoreN)r`rarbrgrrrcrcrcrdrD s   rc@s$eZdZddZddZddZdS)FakePathcCs ||_dS)N)r)rfrrcrcrdrgn szFakePath.__init__cCsd|jdS)Nz )r)rfrcrcrd__repr__q szFakePath.__repr__cCs6t|jts$t|jtr,t|jtr,|jn|jSdS)N)rr BaseExceptionrrx)rfrcrcrd __fspath__t s    zFakePath.__fspath__N)r`rarbrgrrrcrcrcrdrk src cs.tj}ztj|dVWdtj|XdS)N)rnget_int_max_str_digitsset_int_max_str_digits)Z max_digitsZcurrentrcrcrdadjust_int_max_str_digits| s   rcCsddtddDdgS)NcSsg|] }t|qSrc)chr)rArrcrcrdrB sz)control_characters_c0..r )rOrcrcrcrdcontrol_characters_c0 sr)T)F)F)N)Nii@i@i@ii) rrrrrrrrrr r!)r%r#r&r'r()NF)F)r5F)N)Fi@ii)T)N)Nr)rR)N(r`rmcollections.abc collections contextlibZdatetimerrZr?rrrrlimportlib.utilrZlogging.handlersrerrrorurrrrrrnrr*rrrrZ urllib.errorr_rfZ testresultrrJrLZmultiprocessing.processr&zlibrVbz2Zlzmarrrrr r r rsr contextmanagerrjr r~rr:r;rr6rrrrr0rrrrrrrprrrrrrrrrrrr r!rr"r#r$r%rErrr rGrHrJrrFrrZ SOCK_MAX_SIZEZ skipUnlessr __getformat__r7r9r0r1r2r@rrrArCrurrr.Z FS_NONASCII characterfsdecodefsencode UnicodeErrorZTESTFN_UNICODEZ unicodedata normalizegetfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversionencodeUnicodeEncodeErrorrdecodeUnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr2rr]r}r1r4rrrKrrrrZTEST_SUPPORT_DIRr9rr[rrr[rGr&rIobjectrcrrRrrrSrabcMutableMappingrTrr'rrr(rr)r*r+rrrrrrrrrrrrrrrrUr\rrrZ_4GrrrYr r3r4r,rrr>r5r!r%r?r"rBr*r+r-r2r3r<r5r7rAr-rDZMISSING_C_DOCSTRINGSrZHAVE_DOCSTRINGSZrequires_docstringsr.rHrIZenvironment_alteredrNrOrPrTrLrQrWrVrbZskipIfZrequires_type_collectingrcrdrfrgrMrXrrrr/rzr|r8r~rr<r=rZrrrr^rrDrr_rrrrrcrcrcrds                      2   !  J    > %                 %      2 ' 5M           $ # 0           (        " #   "    :_"  ;' PK`] P  3support/__pycache__/testresult.cpython-36.opt-2.pycnu[3 \ @s2ddlZddlZddlZddlZddlZddlZddljjZ ddl m Z Gdddej Z GdddZ ddd Zdd d Zed kr.Gd ddejZejZejejeejZeeddejDZeejZejeZe dej!e dddx(e j"ej#D]Z$e e$j%ddqWe dS)N)datetimecseZdZdddZdddZfddZeddZfd d Zd$d d Z ddZ eddZ fddZ fddZ fddZfddZfddZfddZddZd d!Zd"d#ZZS)%RegressionTestResult=F -cs\tj||ddd|_tjd|_|jjdtjj dd|_ d|_ g|_ t ||_dS)Nr)stream descriptions verbosityTZ testsuitestart )super__init__bufferETZElement_RegressionTestResult__suitesetrZutcnowZ isoformat_RegressionTestResult__e!_RegressionTestResult__start_timeZ_RegressionTestResult__resultsbool_RegressionTestResult__verbose)selfrr r ) __class__//usr/lib64/python3.6/test/support/testresult.pyrs zRegressionTestResult.__init__cCsLy |j}Wntk r"t|SXy|Stk rBt|SXt|S)N)idAttributeErrorstr TypeErrorrepr)clstestZtest_idrrrZ__getIds   zRegressionTestResult.__getIdcsVtj|tj|jd|_}tj|_|j rR|j j |j |d|j j dS)NZtestcasez ... )r startTestr SubElementrrtime perf_counterrrrwritegetDescriptionflush)rr!e)rrrr"+s   zRegressionTestResult.startTestFc KsP|j}d|_|dkrdS|jd|jd|j||jd|jdd|jd|jdd|jrz|jdtj|jd|r|jdk r|jjj }|t j |d_ |j dk r|j jj }|t j |d _ x|jD]t\}}| s| rqt j ||} t|d r>xD|jD],\} } | r,| j| t| n t| | _ q Wqt|| _ qWdS) NnameZstatusrunresultZ completedr$z0.6fz system-outz system-erritems)rrpop_RegressionTestResult__getIdrr$r%Z_stdout_buffergetvaluerstriprr#textZ_stderr_bufferr-hasattrr) rr!Zcaptureargsr)stdoutstderrkvZe2Zk2Zv2rrr _add_result3s4     z RegressionTestResult._add_resultcCs|jr|jj|ddS)Nr)rrr&)rcZwordrrrZ__writeSszRegressionTestResult.__writecCslt|tr0|jdkr|j}q8|jd|j}nt|}tj||d}tj|||}|dj|dj|dS)Nbuiltins.)typemessager=) isinstancer> __module____name__r tracebackformat_exceptionjoin)r Zerr_typeZ err_valueZerr_tbtypenamemsgtbrrrZ__makeErrorDictWs  z$RegressionTestResult.__makeErrorDictcs4|j|d|j|dtj|||jdddS)NT)errorEERROR)r9$_RegressionTestResult__makeErrorDictr addError_RegressionTestResult__write)rr!err)rrrrMjszRegressionTestResult.addErrorcs4|j|d|j|dtj|||jdddS)NT)outputxzexpected failure)r9rLr addExpectedFailurerN)rr!rO)rrrrRosz'RegressionTestResult.addExpectedFailurecs4|j|d|j|dtj|||jdddS)NT)ZfailureFFAIL)r9rLr addFailurerN)rr!rO)rrrrUtszRegressionTestResult.addFailurecs2|j||dtj|||jdd|dS)N)ZskippedSzskipped )r9r addSkiprN)rr!reason)rrrrWyszRegressionTestResult.addSkipcs&|j|tj||jdddS)Nr<ok)r9r addSuccessrN)rr!)rrrrZ~s  zRegressionTestResult.addSuccesscs*|j|ddtj||jdddS)NZUNEXPECTED_SUCCESS)Zoutcomeuzunexpected success)r9r addUnexpectedSuccessrN)rr!)rrrr\s z)RegressionTestResult.addUnexpectedSuccesscCs2|jr|jjd|jd|j|jd|jdS)NrrKrT)rrr&printErrorListerrorsfailures)rrrr printErrorss z RegressionTestResult.printErrorscCs`xZ|D]R\}}|jj|j|jj|d|j|d|jj|j|jjd|qWdS)Nz: rz%s )rr& separator1r' separator2)rZflavorr^r!rOrrrr]s z#RegressionTestResult.printErrorListcCsH|j}|jdt|j|jdtt|j|jdtt|j|S)NZtestsr^r_)rrrZtestsRunlenr^r_)rr)rrrget_xml_elements z$RegressionTestResult.get_xml_element)F)rBrA __qualname__rarbr classmethodr/r"r9rNrLrMrRrUrWrZr\r`r]rd __classcell__rr)rrrs"           rc@seZdZdddZddZdS)QuietRegressionTestRunnerFcCst|dd|_||j_dS)Nr)rr,r)rrrrrrrsz"QuietRegressionTestRunner.__init__cCs||j|jS)N)r,)rr!rrrr+s zQuietRegressionTestRunner.runN)F)rBrArerr+rrrrrhs rhFcCs&|rtjtjt||dStjt|dS)N)Z resultclassrr )r) functoolspartialunittestZTextTestRunnerrrh)r rrrrget_test_runner_classs rlcCst|||S)N)rl)rr Zcapture_outputrrrget_test_runnersrm__main__c@s,eZdZddZddZddZddZd S) TestTestscCsdS)Nr)rrrr test_passszTestTests.test_passcCstjddS)Ng?)r$Zsleep)rrrrtest_pass_slowszTestTests.test_pass_slowcCs*tdtjdtdtjd|jddS)Nr5)filer6zfailure message)printsysr5r6Zfail)rrrr test_failszTestTests.test_failcCs(tdtjdtdtjdtddS)Nr5)rrr6z error message)rsrtr5r6 RuntimeError)rrrr test_errorszTestTests.test_errorN)rBrArerprqrurwrrrrrosroccs|]}|dkVqdS)z-vNr).0arrr srzzOutput:zXML: r=)end)F)F)&riiortr$rCrkZxml.etree.ElementTreeZetreeZ ElementTreerrZTextTestResultrrhrlrmrBZTestCaseroZ TestSuiteZsuiteZaddTestZ makeSuiteStringIOrsumargvZ runner_clsr5Zrunnerr+r,rsr0Z tostringlistrdsdecoderrrrs2         PK`]m6support/__pycache__/script_helper.cpython-36.opt-2.pycnu[3 _Vj)@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZmZdaddZGdddejdd#Zd d Zd dZddZddZejejdddZddZd$ddZd%ddZd&ddZd'd!d"ZdS)(N)source_from_cache)make_legacy_pycstrip_python_stderrc CsVtdkrRdtjkrdadSytjtjdddgWntjk rLdaYnXdatS)NZ PYTHONHOMETz-Ez-czimport sys; sys.exit(0)F)$__cached_interp_requires_environmentosenviron subprocessZ check_callsys executableZCalledProcessErrorr r 2/usr/lib64/python3.6/test/support/script_helper.py interpreter_requires_environments   r c@seZdZddZdS)_PythonRunResultcCsd}|j|j}}t||kr0d|| d}t||krNd|| d}|jddj}|jddj}td|j|||fdS) NPds(... truncated stdout ...)s(... truncated stderr ...)asciireplacezRProcess return code is %d command line: %r stdout: --- %s --- stderr: --- %s ---i@)outerrlendecoderstripAssertionErrorrc)selfcmd_linemaxlenrrr r r fail>s   z_PythonRunResult.failN)__name__ __module__ __qualname__rr r r r r;srrrrc Ost}d|kr|jd}n | o$| }tjddg}|rB|jdn| rX| rX|jd|jddri}tjdkrtjd|d<n tjj}d |krd |d <|j ||j |t j |t j t j t j |d }|*z|j\}}Wd|jt jXWdQRX|j} t|}t| |||fS) NZ __isolatedz-XZ faulthandlerz-Iz-EZ __cleanenvZwin32Z SYSTEMROOTTERM)stdinstdoutstderrenv)r popr r appendplatformrrcopyupdateextendrPopenPIPEZ communicatekill_cleanup returncoderr) argsenv_varsZ env_requiredisolatedrr&procrrrr r r run_python_until_end[s:            r6cOs4t||\}}|jr|s&|j r0| r0|j||S)N)r6rr)Zexpected_successr2r3resrr r r _assert_pythons r8cOstd||S)NT)T)r8)r2r3r r r assert_python_oks r9cOstd||S)NF)F)r8)r2r3r r r assert_python_failuresr:)r$r%cOsXtjg}ts|jd|j||jdttj}d|d<t j |ft j ||d|S)Nz-Er&Zvt100r!)r#r$r%) r r r r(r, setdefaultdictrrrr-r.)r$r%r2kwrr&r r r spawn_pythons   r>cCs2|jj|jj}|jj|jtj|S)N)r#closer$readwaitrr0)pdatar r r kill_pythons    rDFcCsP|}|s|tjd7}tjj||}t|ddd}|j||jtj|S)Npywzutf-8)encoding) rextseppathjoinopenwriter? importlibinvalidate_caches)Z script_dirscript_basenamesourceZ omit_suffixZscript_filename script_nameZ script_filer r r make_scripts rRc Cs|tjd}tjj||}tj|d}|dkr~|jtj}t|dkrr|ddkrrt t |}tjj |}|}n tjj |}|j |||j |tjj||fS)NziprF __pycache__)rrHrIrJzipfileZipFilesplitseprrrbasenamerLr?) zip_dir zip_basenamerQZ name_in_zip zip_filenamezip_namezip_filepartsZ legacy_pycr r r make_zip_scripts      rbr"cCstj|t|d|dS)N__init__)rmkdirrR)Zpkg_dirZ init_sourcer r r make_pkgs recs0g}t|dd}|j|tjj|} t|||} |j| |rjtj|dd}tj| dd} |j|| ffddtd|dD} tjj | d tjj| } |tj d} tjj || }t j |d }x&| D]}tjj || }|j ||qW|j | | |jx|D]}tj|q W|tjj || fS) Nrcr"T)doraisecsg|]}tjjg|qSr )rrZrJ).0i)pkg_namer r sz make_zip_pkg..rfrSrF)rRr(rrIr[ py_compilecompiler,rangerJrHrWrXrLr?unlink)r\r]rjrOrPZdepthZcompiledrpZ init_nameZ init_basenamerQZ pkg_namesZscript_name_in_zipr^r_r`nameZinit_name_in_zipr )rjr make_zip_pkgs.         rr)rrr)F)N)r")rfF) collectionsrMr rZos.pathZtempfilerrm contextlibZshutilrWimportlib.utilrZ test.supportrrrr namedtuplerr6r8r9r:r.ZSTDOUTr>rDrRrbrerrr r r r s4 $3    PK`]/J0support/__pycache__/script_helper.cpython-36.pycnu[3 _Vj)@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZmZdaddZGdddejdd#Zd d Zd dZddZddZejejdddZddZd$ddZd%ddZd&ddZd'd!d"ZdS)(N)source_from_cache)make_legacy_pycstrip_python_stderrc CsVtdkrRdtjkrdadSytjtjdddgWntjk rLdaYnXdatS)a  Returns True if our sys.executable interpreter requires environment variables in order to be able to run at all. This is designed to be used with @unittest.skipIf() to annotate tests that need to use an assert_python*() function to launch an isolated mode (-I) or no environment mode (-E) sub-interpreter process. A normal build & test does not run into this situation but it can happen when trying to run the standard library test suite from an interpreter that doesn't have an obvious home with Python's current home finding logic. Setting PYTHONHOME is one way to get most of the testsuite to run in that situation. PYTHONPATH or PYTHONUSERSITE are other common environment variables that might impact whether or not the interpreter can start. NZ PYTHONHOMETz-Ez-czimport sys; sys.exit(0)F)$__cached_interp_requires_environmentosenviron subprocessZ check_callsys executableZCalledProcessErrorr r 2/usr/lib64/python3.6/test/support/script_helper.py interpreter_requires_environments   r c@seZdZdZddZdS)_PythonRunResultz2Helper for reporting Python subprocess run resultscCsd }|j|j}}t||kr0d|| d}t||krNd|| d}|jddj}|jddj}td|j|||fdS) z4Provide helpful details about failed subcommand runsPds(... truncated stdout ...)Ns(... truncated stderr ...)asciireplacezRProcess return code is %d command line: %r stdout: --- %s --- stderr: --- %s ---i@)outerrlendecoderstripAssertionErrorrc)selfcmd_linemaxlenrrr r r fail>s   z_PythonRunResult.failN)__name__ __module__ __qualname____doc__rr r r r r;srrrrc Ost}d|kr|jd}n | o$| }tjddg}|rB|jdn| rX| rX|jd|jddri}tjdkrtjd|d<n tjj}d |krd |d <|j ||j |t j |t j t j t j |d }|*z|j\}}Wd|jt jXWdQRX|j} t|}t| |||fS) NZ __isolatedz-XZ faulthandlerz-Iz-EZ __cleanenvZwin32Z SYSTEMROOTTERM)stdinstdoutstderrenv)r popr r appendplatformrrcopyupdateextendrPopenPIPEZ communicatekill_cleanup returncoderr) argsenv_varsZ env_requiredisolatedrr'procrrrr r r run_python_until_end[s:            r7cOs4t||\}}|jr|s&|j r0| r0|j||S)N)r7rr)Zexpected_successr3r4resrr r r _assert_pythons r9cOstd||S)a| Assert that running the interpreter with `args` and optional environment variables `env_vars` succeeds (rc == 0) and return a (return code, stdout, stderr) tuple. If the __cleanenv keyword is set, env_vars is used as a fresh environment. Python is started in isolated mode (command line option -I), except if the __isolated keyword is set to False. T)T)r9)r3r4r r r assert_python_oks r:cOstd||S)z Assert that running the interpreter with `args` and optional environment variables `env_vars` fails (rc != 0) and return a (return code, stdout, stderr) tuple. See assert_python_ok() for more options. F)F)r9)r3r4r r r assert_python_failuresr;)r%r&cOsXtjg}ts|jd|j||jdttj}d|d<t j |ft j ||d|S)zRun a Python subprocess with the given arguments. kw is extra keyword args to pass to subprocess.Popen. Returns a Popen object. z-Er'Zvt100r")r$r%r&) r r r r)r- setdefaultdictrrrr.r/)r%r&r3kwrr'r r r spawn_pythons   r?cCs2|jj|jj}|jj|jtj|S)z?Run the given Popen process until completion and return stdout.)r$closer%readwaitrr1)pdatar r r kill_pythons    rEFcCsP|}|s|tjd7}tjj||}t|ddd}|j||jtj|S)Npywzutf-8)encoding) rextseppathjoinopenwriter@ importlibinvalidate_caches)Z script_dirscript_basenamesourceZ omit_suffixZscript_filename script_nameZ script_filer r r make_scripts rSc Cs|tjd}tjj||}tj|d}|dkr~|jtj}t|dkrr|ddkrrt t |}tjj |}|}n tjj |}|j |||j |tjj||fS)NziprG __pycache__)rrIrJrKzipfileZipFilesplitseprrrbasenamerMr@) zip_dir zip_basenamerRZ name_in_zip zip_filenamezip_namezip_filepartsZ legacy_pycr r r make_zip_scripts      rcr#cCstj|t|d|dS)N__init__)rmkdirrS)Zpkg_dirZ init_sourcer r r make_pkgs rfcs0g}t|dd}|j|tjj|} t|||} |j| |rjtj|dd}tj| dd} |j|| ffddtd|dD} tjj | d tjj| } |tj d} tjj || }t j |d }x&| D]}tjj || }|j ||qW|j | | |jx|D]}tj|q W|tjj || fS) Nrdr#T)doraisecsg|]}tjjg|qSr )rr[rK).0i)pkg_namer r sz make_zip_pkg..rgrTrG)rSr)rrJr\ py_compilecompiler-rangerKrIrXrYrMr@unlink)r]r^rkrPrQZdepthZcompiledrqZ init_nameZ init_basenamerRZ pkg_namesZscript_name_in_zipr_r`ranameZinit_name_in_zipr )rkr make_zip_pkgs.         rs)rrr)F)N)r#)rgF) collectionsrNr rZos.pathZtempfilerrn contextlibZshutilrXimportlib.utilrZ test.supportrrrr namedtuplerr7r9r:r;r/ZSTDOUTr?rErSrcrfrsr r r r s4 $3    PK`]8\p?p?+support/__pycache__/__init__.cpython-36.pycnu[3 _Vj@sl dZedkredddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZ ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl!Z"ddl#Z#ddl$m%Z%yddl&Z&ddl'Z'Wnek rBdZ&dZ'YnXy ddl(Z)Wnek rjdZ)YnXy ddl*Z*Wnek rdZ*YnXy ddl+Z+Wnek rdZ+YnXy ddl,Z,Wnek rdZ,YnXy ddl-Z-Wnek r dZ-YnXy ddl.Z.Wnek r2dZ.YnXy ddl/Z/Wnek rZdZ/YnXddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbg\Z0Gdcd d e1Z2Gddd d e2Z3Gdedde2Z4Gdfdde j5Z6ej7dhdhdiZ8difdkdldZ9dmdnZ:dodpZ;dqd=ZZ=ffdjfdsdZ>dtd9Z?dZ@dZAdaBdaCdZDdjZEdaFdudZGdvdZHdwdZIdxdyZJejjKdzr.djd{d|ZLd}d~ZMddZNddZOddZPnejQZMejRZNddZOddZPddZQddZRddZSddZTddZUddZVdd#ZWdkdd$ZXddZYdd%ZZdd&Z[dd'Z\dldd(Z]dZ^dZ_ej`ejafddJZbe^fddKZcddMZdddZeeeZfddZgdoZhdrZie jjekjldjKddZme jje*dZne jje+dZoe jje,dZpe jje-dZqejjKdZrejsdZtetdk oxetdkZuejdkreurdndZvndZvejwdkrdZxndZxdjyexejzZxdZ{xLdsD]BZ|yej}ej~e|e|kreWnek rYnXe|Z{PqWexdZejdkr:ddlZejdeZejZdZejwdkrejjdkrexdZyejeWnek rYnXedeefdZnBejdkrydjeWn&ek rexdjedǃZYnXdZxFdtD]dYZd?d@Ze jeedAdBZdCdDZdEdFZGdGdPdPejjZGdHd[d[eZdadId!ZdJd2ZdadKdLZdMd;ZdNdOZdPd"ZfdQdRd?Z dfffdSd@Z GdTd]d]Z dUdVZ dWdXZ ffdYdZZgfd[daZdad\dGZej7d]d^Zd_dbZGd`dadaZGdbdcdcZej7dddeZdfdgZdS(z7Supporting definitions for the Python regression tests.z test.supportz.support must be imported from the test packageN)get_test_runner PIPE_MAX_SIZEverbose max_memuse use_resourcesfailfastError TestFailed TestDidNotRunResourceDenied import_moduleimport_fresh_module CleanImportunloadforgetrecord_original_stdoutget_original_stdoutcaptured_stdoutcaptured_stdincaptured_stderrTESTFNSAVEDCWDunlinkrmtreetemp_cwdfindfilecreate_empty_file can_symlinkfs_is_case_insensitiveis_resource_enabledrequiresrequires_freebsd_versionrequires_linux_versionrequires_mac_verrequires_hashdigestcheck_syntax_errorTransientResourcetime_outsocket_peer_resetioerror_peer_resettransient_internetBasicTestRunner run_unittest run_doctestskip_unless_symlink requires_gzip requires_bz2 requires_lzma bigmemtestbigaddrspacetest cpython_only get_attributerequires_IEEE_754skip_unless_xattr requires_zlibanticipate_failureload_package_testsdetect_api_mismatch check__all__requires_android_levelrequires_multiprocessing_queue is_jython is_androidcheck_impl_detail unix_shellsetswitchintervalHOST IPV6_ENABLEDfind_unused_port bind_portopen_urlresourcebind_unix_socket temp_umask reap_children TestHandlerthreading_setupthreading_cleanup reap_threads start_threadscheck_warningscheck_no_resource_warningEnvironmentVarGuardrun_with_locale swap_item swap_attrMatcher set_memlimitSuppressCrashReportsortdict run_with_tzPGOmissing_compiler_executablefd_countc@seZdZdZdS)r z*Base class for regression test exceptions.N)__name__ __module__ __qualname____doc__rdrd-/usr/lib64/python3.6/test/support/__init__.pyr |sc@seZdZdZdS)r z Test failed.N)r`rarbrcrdrdrdrer sc@seZdZdZdS)r zTest did not run any subtests.N)r`rarbrcrdrdrdrer sc@seZdZdZdS)r zTest skipped because it requested a disallowed resource. This is raised when a test calls requires() for a resource that has not be enabled. It is used to distinguish between expected and unexpected skips. N)r`rarbrcrdrdrdrer sTc cs8|r.tjtjddtdVWdQRXndVdS)zContext manager to suppress package and module deprecation warnings when importing them. If ignore is False, this context manager has no effect. ignorez.+ (module|package)N)warningscatch_warningsfilterwarningsDeprecationWarning)rfrdrdre_ignore_deprecated_importss  rkF) required_oncCsft|Ty tj|Stk rV}z&tjjt|r8tj t |WYdd}~XnXWdQRXdS)acImport and return the module to be tested, raising SkipTest if it is not available. If deprecated is True, any module or package deprecation messages will be suppressed. If a module is required on a platform but optional for others, set required_on to an iterable of platform prefixes which will be compared against sys.platform. N) rk importlibr ImportErrorsysplatform startswithtupleunittestSkipTeststr)name deprecatedrlmsgrdrdrer s  cCs^|tjkrt|tj|=x>ttjD]0}||ks@|j|dr&tj|||<tj|=q&WdS)zyHelper function to save and remove a module from sys.modules Raise ImportError if the module can't be imported. .N)romodules __import__listrq)rv orig_modulesmodnamerdrdre_save_and_remove_modules rc Cs>d}ytj|||<Wntk r.d}YnXdtj|<|S)zHelper function to save and block a module in sys.modules Return True if the module was in sys.modules, False otherwise. TFN)rorzKeyError)rvr}Zsavedrdrdre_save_and_block_modules  rcCs|r tjSddS)zDecorator to mark a test that is known to be broken in some cases Any use of this decorator should have a comment identifying the associated tracker issue. cSs|S)Nrd)frdrdresz$anticipate_failure..)rsZexpectedFailure)Z conditionrdrdrer:scCsF|dkr d}tjjtjjtjjt}|j|||d}|j||S)zGeneric load_tests implementation for simple test packages. Most packages can implement load_tests using this function as follows: def load_tests(*args): return load_package_tests(os.path.dirname(__file__), *args) Nztest*)Z start_dirZ top_level_dirpattern)ospathdirname__file__ZdiscoverZaddTests)Zpkg_dirloaderZstandard_testsrZtop_dirZ package_testsrdrdrer;s c Cst|i}g}t||zfyHx|D]}t||q&Wx |D]}t||s>|j|q>Wtj|}Wntk r~d}YnXWdx|jD]\} } | tj | <qWx|D] } tj | =qWX|SQRXdS)aImport and return a module, deliberately bypassing sys.modules. This function imports and returns a fresh copy of the named Python module by removing the named module from sys.modules before doing the import. Note that unlike reload, the original module is not affected by this operation. *fresh* is an iterable of additional module names that are also removed from the sys.modules cache before doing the import. *blocked* is an iterable of module names that are replaced with None in the module cache during the import to ensure that attempts to import them raise ImportError. The named module and any modules named in the *fresh* and *blocked* parameters are saved before starting the import and then reinserted into sys.modules when the fresh import is complete. Module and package deprecation messages are suppressed during this import if *deprecated* is True. This function will raise ImportError if the named module cannot be imported. N) rkrrappendrmr rnitemsrorz) rvZfreshZblockedrwr}Znames_to_removeZ fresh_nameZ blocked_nameZ fresh_moduleZ orig_namemoduleZname_to_removerdrdrers$      c Cs>yt||}Wn&tk r4tjd||fYnX|SdS)z?Get an attribute, raising SkipTest if AttributeError is raised.zobject %r has no attribute %rN)getattrAttributeErrorrsrt)objrvZ attributerdrdrer6s cCs|adS)N)_original_stdout)stdoutrdrdrer0scCs tptjS)N)rrorrdrdrdrer4sc Cs&y tj|=Wntk r YnXdS)N)rorzr)rvrdrdrer7s cGsny||Stk rh}zDtdkrHtd|jj|ftd|j|ftj|tj||Sd}~XnXdS)Nz%s: %sz re-run %s%r) OSErrorrprint __class__r`rchmodstatS_IRWXU)rfuncargserrrdrdre _force_run=srwincCs|||r|}ntjj|\}}|p(d}d}x<|dkrjtj|}|rJ|n||ksVdStj||d9}q0Wtjd|tdddS)NrygMbP?g?rz)tests may fail, delete still pending for ) stacklevel) rrsplitlistdirtimesleeprgwarnRuntimeWarning)rpathnamewaitallrrvtimeoutLrdrdre_waitforHs     rcCsttj|dS)N)rrr)filenamerdrdre_unlinkisrcCsttj|dS)N)rrrmdir)rrdrdre_rmdirlsrcs,fddt|ddtdd|dS)Ncsxt|tj|D]}tjj||}ytj|j}Wn<tk rn}z td||ft j dd}WYdd}~XnXt j |rt |ddt|tj|qt|tj|qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s)filerT)r)rrrrjoinlstatst_moderrro __stderr__rS_ISDIRrrr)rrvfullnamemodeexc) _rmtree_innerrdrerps   z_rmtree.._rmtree_innerT)rcSst|tj|S)N)rrr)prdrdrersz_rmtree..)r)rrd)rre_rmtreeos rc Cs^y ddl}Wntk r Yn:X|jt|d}|jjj||t|}|rZ|d|S|S)Nrr)ctypesrnZcreate_unicode_bufferlenwindllkernel32ZGetLongPathNameW)rrbufferZlengthrdrdre _longpaths    rc sFytj|dStk r"YnXfdd|tj|dS)Nc sx~t|tj|D]l}tjj||}ytj|j}Wntk rJd}YnXtj |rn|t|tj |qt|tj |qWdS)Nr) rrrrrrrrrrrr)rrvrr)rrdrers  z_rmtree.._rmtree_inner)shutilrrrr)rrd)rrers  cCs|S)Nrd)rrdrdrersc Cs*y t|Wnttfk r$YnXdS)N)rFileNotFoundErrorNotADirectoryError)rrdrdrers c Cs&y t|Wntk r YnXdS)N)rr)rrdrdrers rc Cs&y t|Wntk r YnXdS)N)rr)rrdrdrers cCsBtjj|}tjjtjj|}tjj||d}tj|||S)aMove a PEP 3147/488 pyc file to its legacy pyc location. :param source: The file system path to the source file. The source file does not need to exist, however the PEP 3147/488 pyc file must exist. :return: The file system path to the legacy pyc file. c) rmutilcache_from_sourcerrrabspathrrename)sourceZpyc_fileZup_oneZ legacy_pycrdrdremake_legacy_pycs   rcCs\t|xNtjD]D}tjj||d}t|dx dD]}ttjj||dq8WqWdS) z'Forget' a module was ever imported. This removes the module from sys.modules and deletes any PEP 3147/488 or legacy .pyc files. z.pyrrr) optimizationN)rrr) rrorrrrrmrr)r~rroptrdrdrers    csttdrtjSd}tjjdrddlddld}d}Gfdddj}j j }|j }|sjj |}j j}|j||j|j|j|}|sj t|j|@sd}ntjdkrVdd lm} mm} m} dd lm} | j| d } | jdkrd }nFGfd dd| }|}| |}| j|dksR| j|dkrVd}|sy.ddlm}|}|j|j |j!Wn\t"k r}z>t#|}t$|dkr|ddd}dj%t&|j'|}WYdd}~XnX|t_(| t_tjS)Nresultrrrcs.eZdZdjjfdjjfdjjfgZdS)z*_is_gui_available..USEROBJECTFLAGSZfInheritZ fReserveddwFlagsN)r`rarbwintypesZBOOLDWORD_fields_rd)rrdreUSEROBJECTFLAGSs  rz,gui not available (WSF_VISIBLE flag not set)darwin)cdllc_intpointer Structure) find_libraryZApplicationServicesz0gui tests cannot run without OS X window managercseZdZdfdfgZdS)z._is_gui_available..ProcessSerialNumberZ highLongOfPSNZ lowLongOfPSNN)r`rarbrrd)rrdreProcessSerialNumbersrz#cannot run without OS X gui process)Tk2z [...]zTk unavailable due to {}: {}))hasattr_is_gui_availablerrorprqrZctypes.wintypesrrZuser32ZGetProcessWindowStationZWinErrorrrZGetUserObjectInformationWZbyrefZsizeofboolrrrrZ ctypes.utilrZ LoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterrZwithdrawupdateZdestroy Exceptionrurformattyper`reason)rZ UOI_FLAGSZ WSF_VISIBLErZdllhZuofZneededresrrrrZ app_servicesrZpsnZpsn_prrooteZ err_stringrd)rrrersh         rcCstdkp|tkS)zTest whether a resource is enabled. Known resources are set by regrtest.py. If not running under regrtest.py, all resources are assumed enabled unless use_resources has been set. N)r)resourcerdrdrer $scCs>t|s |dkrd|}t||dkr:t r:ttjdS)z@Raise ResourceDenied if the specified resource is not available.Nz"Use of the %r resource not enabledgui)r r rr)rrxrdrdrer!,s csfdd}|S)zDecorator raising SkipTest if the OS is `sysname` and the version is less than `min_version`. For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if the FreeBSD version is less than 7.2. cs$tjfdd}|_|S)Nc stjkrztjjddd}yttt|jd}Wntk rLYn.X|krzdjtt }t j d||f||S)N-rrryz(%s version %s or higher required, not %s) rpsystemreleaserrrmapint ValueErrorrrursrt)rkw version_txtversionmin_version_txt)r min_versionsysnamerdrewrapper=s z:_requires_unix_version..decorator..wrapper) functoolswrapsr)rr)rr)rre decorator<sz)_requires_unix_version..decoratorrd)rrrrd)rrre_requires_unix_version5srcGs td|S)zDecorator raising SkipTest if the OS is FreeBSD and the FreeBSD version is less than `min_version`. For example, @requires_freebsd_version(7, 2) raises SkipTest if the FreeBSD version is less than 7.2. ZFreeBSD)r)rrdrdrer"PscGs td|S)zDecorator raising SkipTest if the OS is Linux and the Linux version is less than `min_version`. For example, @requires_linux_version(2, 6, 32) raises SkipTest if the Linux version is less than 2.6.32. ZLinux)r)rrdrdrer#Yscsfdd}|S)zDecorator raising SkipTest if the OS is Mac OS X and the OS X version if less than min_version. For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version is lesser than 10.5. cs"tjfdd}|_|S)Nc sxtjdkrntjd}yttt|jd}Wntk rBYn,X|krndjtt }t j d||f||S)Nrrryz&Mac OS X %s or higher required, not %s) rorpZmac_verrrrrrrrrursrt)rrrrr)rrrdrerjs   z4requires_mac_ver..decorator..wrapper)rrr)rr)r)rrerisz#requires_mac_ver..decoratorrd)rrrd)rrer$bs csfdd}|S)aDecorator raising SkipTest if a hashing algorithm is not available The hashing algorithm could be missing or blocked by a strict crypto policy. If 'openssl' is True, then the decorator checks that OpenSSL provides the algorithm. Otherwise the check falls back to built-in implementations. ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS ValueError: unsupported hash type md4 cstjfdd}|S)Nc sXy&rtdk rtjn tjWn&tk rLtjddYnX||S)Nz hash digest 'z' is not available.)_hashlibnewhashlibrrsrt)rkwargs) digestnameropensslrdrers  z7requires_hashdigest..decorator..wrapper)rr)rr)rr)rrers z&requires_hashdigest..decoratorrd)rrrrd)rrrer%}s z 127.0.0.1z::1cCs"tj||}t|}|j~|S)a Returns an unused port that should be suitable for binding. This is achieved by creating a temporary socket with the same family and type as the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to the specified host address (defaults to 0.0.0.0) with the port set to 0, eliciting an unused ephemeral port from the OS. The temporary socket is then closed and deleted, and the ephemeral port is returned. Either this method or bind_port() should be used for any tests where a server socket needs to be bound to a particular port for the duration of the test. Which one to use depends on whether the calling code is creating a python socket, or if an unused port needs to be provided in a constructor or passed to an external program (i.e. the -accept argument to openssl's s_server mode). Always prefer bind_port() over find_unused_port() where possible. Hard coded ports should *NEVER* be used. As soon as a server socket is bound to a hard coded port, the ability to run multiple instances of the test simultaneously on the same host is compromised, which makes the test a ticking time bomb in a buildbot environment. On Unix buildbots, this may simply manifest as a failed test, which can be recovered from without intervention in most cases, but on Windows, the entire python process can completely and utterly wedge, requiring someone to log in to the buildbot and manually kill the affected process. (This is easy to reproduce on Windows, unfortunately, and can be traced to the SO_REUSEADDR socket option having different semantics on Windows versus Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind, listen and then accept connections on identical host/ports. An EADDRINUSE OSError will be raised at some point (depending on the platform and the order bind and listen were called on each socket). However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE will ever be raised when attempting to bind two identical host/ports. When accept() is called on each socket, the second caller's process will steal the port from the first caller, leaving them both in an awkwardly wedged state where they'll no longer respond to any signals or graceful kills, and must be forcibly killed via OpenProcess()/TerminateProcess(). The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option instead of SO_REUSEADDR, which effectively affords the same semantics as SO_REUSEADDR on Unix. Given the propensity of Unix developers in the Open Source world compared to Windows ones, this is a common mistake. A quick look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when openssl.exe is called with the 's_server' option, for example. See http://bugs.python.org/issue2550 for more info. The following site also has a very thorough description about the implications of both REUSEADDR and EXCLUSIVEADDRUSE on Windows: http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx) XXX: although this approach is a vast improvement on previous attempts to elicit unused ports, it rests heavily on the assumption that the ephemeral port returned to us by the OS won't immediately be dished back out to some other process when we close and delete our temporary socket but before our calling code has a chance to bind the returned port. We can deal with this issue if/when we come across it. )socketrHclose)familyZsocktypeZtempsockportrdrdrerGs 8 c Cs|jtjkr|jtjkrttdr>|jtjtjdkr>t dttdr~y |jtjtj dkrft dWnt k r|YnXttdr|j tjtj d|j|df|jd}|S)a%Bind the socket to a free port and return the port number. Relies on ephemeral ports in order to ensure we are using an unbound port. This is important as many tests may be running simultaneously, especially in a buildbot environment. This method raises an exception if the sock.family is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR or SO_REUSEPORT set on it. Tests should *never* set these socket options for TCP/IP sockets. The only case for setting these options is testing multicasting via multiple UDP sockets. Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e. on Windows), it will be set on the socket. This will prevent anyone else from bind()'ing to our host/port for the duration of the test. SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets! SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!SO_EXCLUSIVEADDRUSEr)rrAF_INETr SOCK_STREAMrZ getsockoptZ SOL_SOCKETrr rrZ setsockoptrbindZ getsockname)sockhostrrdrdrerHs     c CsJ|jtjksty|j|Wn&tk rD|jtjdYnXdS)zBBind a unix socket, raising SkipTest if PermissionError is raised.zcannot bind AF_UNIX socketsN) rrZAF_UNIXAssertionErrorr PermissionErrorrrsrt)r ZaddrrdrdrerJs cCsZtjrVd}z.dec)rr)rrrd)rresystem_must_validate_certs rriZdoubleZIEEEztest requires IEEE 754 doublesz requires zlibz requires gzipz requires bz2z requires lzmajavaANDROID_API_LEVELwin32z/system/bin/shz/bin/shz$testz@testz {}_{}_tmpæİŁφКא،تก €u -àòɘŁğrZNFDntru-共Ł♡ͣztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effectives-surrogateescapewrccsd}|dkr&tj}d}tjj|}nBytj|d}Wn.tk rf|sNtjd|t ddYnX|rttj }z |VWd|r|tj krt |XdS)aReturn a context manager that creates a temporary directory. Arguments: path: the directory to create temporarily. If omitted or None, defaults to creating a temporary directory using tempfile.mkdtemp. quiet: if False (the default), the context manager raises an exception on error. Otherwise, if the path is specified and cannot be created, only a warning is issued. FNTz+tests may fail, unable to create temp dir: )r) tempfilemkdtemprrrealpathmkdirrrgrrgetpidr)rquietZ dir_createdpidrdrdretemp_dirs&   r3ccsftj}ytj|Wn.tk rD|s,tjd|tddYnXztjVWdtj|XdS)agReturn a context manager that changes the current working directory. Arguments: path: the directory to use as the temporary current working directory. quiet: if False (the default), the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same. z)tests may fail, unable to change CWD to: r+)rN)rgetcwdchdirrrgrr)rr1Z saved_dirrdrdre change_cwd s  r6tempcwdccs:t||d$}t||d }|VWdQRXWdQRXdS)a Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkdtemp. If *quiet* is False (default) and it is not possible to create or change the CWD, an error is raised. If *quiet* is True, only a warning is raised and the original CWD is used. )rr1)r1N)r3r6)rvr1Z temp_pathZcwd_dirrdrdrer$sumaskc cs&tj|}z dVWdtj|XdS)z8Context manager that temporarily sets the process umask.N)rr8)r8ZoldmaskrdrdrerK8s  datacCsbtjj|r|S|dk r&tjj||}tgtj}x*|D]"}tjj||}tjj|r8|Sq8W|S)a[Try to find a file on sys.path or in the test directory. If it is not found the argument passed to the function is returned (this does not necessarily signal failure; could still be the legitimate path). Setting *subdir* indicates a relative path to use to find the file rather than looking directly in the path directories. N)rrisabsr TEST_HOME_DIRroexists)rZsubdirrZdnfnrdrdrerIs    cCs(tj|tjtjBtjB}tj|dS)z>Create an empty file. If the file already exists, truncate it.N)ropenO_WRONLYO_CREATO_TRUNCr)rfdrdrdrer[scCs,t|j}dd|D}dj|}d|S)z%Like repr(dict), but in sorted order.cSsg|] }d|qS)z%r: %rrd).0Zpairrdrdre cszsortdict..z, z{%s})sortedrr)dictrZ reprpairsZ withcommasrdrdrer[`s  c Cs*ttd}z|jS|jttXdS)z` Create an invalid file descriptor by opening and closing a file and return its fd. wbN)r>rfilenorr)rrdrdre make_bad_fdgs  rI)linenooffsetc Csp|jt}t|ddWdQRX|j}|j|j|dk rJ|j|j||j|j|dk rl|j|j|dS)Nz exec) assertRaises SyntaxErrorcompileZ exceptionZassertIsNotNonerJ assertEqualrK)testcaseZ statementrJrKcmrrdrdrer&ss   c sVddl}ddl}jdd|jj|djdd}tjjt |}fdd}tjj |r|||}|dk rt|St |t dt rtd |td |jj}tr|jjd|j|d d}tr|jjdd krtj|d}zBt|d.} |j} x| r| j| |j} qWWdQRXWd|jX||}|dk rF|Std|dS)Nrcheckr/rcs>t|f}dkr|S|r2|jd|S|jdS)Nr)r>seekr)r=r)rrSrrdrecheck_valid_files z*open_urlresource..check_valid_fileZurlfetchz fetching %s ...)rAccept-Encodinggzip)rzContent-Encoding)ZfileobjrGzinvalid resource %r)rWrX)Zurllib.requestZ urllib.parsepopparseZurlparserrrr TEST_DATA_DIRr<rr!rrrZrequestZ build_openerrXZ addheadersrr>ZheadersgetZGzipFilereadwriterr ) Zurlrrurllibrr=rVropeneroutsrd)rrSrrerI~s<         c@s4eZdZdZddZddZeddZdd Zd S) WarningsRecorderzyConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. cCs||_d|_dS)Nr) _warnings_last)selfZ warnings_listrdrdre__init__szWarningsRecorder.__init__cCsDt|j|jkr t|jd|S|tjjkr0dStd||fdS)Nrz%r has no attribute %rrZ)rrfrgrrgWarningMessage_WARNING_DETAILSr)rhattrrdrdre __getattr__s  zWarningsRecorder.__getattr__cCs|j|jdS)N)rfrg)rhrdrdrergszWarningsRecorder.warningscCst|j|_dS)N)rrfrg)rhrdrdreresetszWarningsRecorder.resetN) r`rarbrcrirmpropertyrgrnrdrdrdreres  rec cs tjd}|jjd}|r"|jtjdd }tjdjdt |VWdQRXt |}g}xz|D]r\}}d} xH|ddD]8}|j } t j |t| t jrt| j|rd} |j|qW| rf| rf|j||jfqfW|rtd |d |rtd |d dS) zCatch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. rZ__warningregistry__T)recordrgalwaysNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)ro _getframe f_globalsr^clearrgrhrz simplefilterrer|messagerematchruI issubclassrremoverr`r) filtersr1frameregistrywZreraiseZmissingrxcatseenZwarningrdrdre_filterwarningss0    rcOs.|jd}|s$dtff}|dkr$d}t||S)aContext manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filters are defined) Without argument, it defaults to: check_warnings(("", Warning), quiet=True) r1rNT)r^Warningr)r|rr1rdrdrerRs   rc csHtjdd&}tjd||ddV|r.tWdQRX|j|gdS)aContext manager to check that no warnings are emitted. This context manager enables a given warning within its scope and checks that no warnings are emitted even with that warning enabled. If force_gc is True, a garbage collection is attempted before checking for warnings. This may help to catch warnings emitted when objects are deleted, such as ResourceWarning. Other keyword arguments are passed to warnings.filterwarnings(). T)rprq)rvcategoryN)rgrhri gc_collectrP)rQrvrZforce_gcwarnsrdrdrecheck_no_warningssrc csBtjdd }tjdtddVtWdQRX|j|gdS)a"Context manager to check that no ResourceWarning is emitted. Usage: with check_no_resource_warning(self): f = open(...) ... del f You must remove the object which may emit ResourceWarning before the end of the context manager. T)rprq)rN)rgrhriResourceWarningrrP)rQrrdrdrerSs c@s(eZdZdZddZddZddZdS) ra,Context manager to force import to return a new module reference. This is useful for testing module-level behaviours, such as the emission of a DeprecationWarning on import. Use like this: with CleanImport("foo"): importlib.import_module("foo") # new reference cGsNtjj|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rorzcopyoriginal_modulesr`)rhZ module_namesZ module_namerrdrdreri?s      zCleanImport.__init__cCs|S)Nrd)rhrdrdre __enter__LszCleanImport.__enter__cGstjj|jdS)N)rorzrr)rh ignore_excrdrdre__exit__OszCleanImport.__exit__N)r`rarbrcrirrrdrdrdrer3s  c@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)rTz_Class to help protect the environment variable properly. Can be used as a context manager.cCstj|_i|_dS)N)renviron_environ_changed)rhrdrdreriXszEnvironmentVarGuard.__init__cCs |j|S)N)r)rhenvvarrdrdre __getitem__\szEnvironmentVarGuard.__getitem__cCs*||jkr|jj||j|<||j|<dS)N)rrr^)rhrvaluerdrdre __setitem___s zEnvironmentVarGuard.__setitem__cCs2||jkr|jj||j|<||jkr.|j|=dS)N)rrr^)rhrrdrdre __delitem__es  zEnvironmentVarGuard.__delitem__cCs |jjS)N)rkeys)rhrdrdrerlszEnvironmentVarGuard.keyscCs t|jS)N)iterr)rhrdrdre__iter__oszEnvironmentVarGuard.__iter__cCs t|jS)N)rr)rhrdrdre__len__rszEnvironmentVarGuard.__len__cCs |||<dS)Nrd)rhrrrdrdresetuszEnvironmentVarGuard.setcCs ||=dS)Nrd)rhrrdrdreunsetxszEnvironmentVarGuard.unsetcCs|S)Nrd)rhrdrdrer{szEnvironmentVarGuard.__enter__cGsJx<|jjD].\}}|dkr0||jkr:|j|=q ||j|<q W|jt_dS)N)rrrrr)rhrkvrdrdrer~s   zEnvironmentVarGuard.__exit__N)r`rarbrcrirrrrrrrrrrrdrdrdrerTSsc@s(eZdZdZddZddZddZdS) DirsOnSysPathaContext manager to temporarily add directories to sys.path. This makes a copy of sys.path, appends any directories given as positional arguments, then reverts sys.path to the copied settings when the context ends. Note that *all* sys.path modifications in the body of the context manager, including replacement of the object, will be reverted at the end of the block. cGs(tjdd|_tj|_tjj|dS)N)rororiginal_valueoriginal_objectextend)rhpathsrdrdreriszDirsOnSysPath.__init__cCs|S)Nrd)rhrdrdrerszDirsOnSysPath.__enter__cGs|jt_|jtjdd<dS)N)rrorr)rhrrdrdrerszDirsOnSysPath.__exit__N)r`rarbrcrirrrdrdrdrers rc@s*eZdZdZddZddZd ddZdS) r'zRaise ResourceDenied if an exception is raised while the context manager is in effect that matches the specified exception and attributes.cKs||_||_dS)N)rattrs)rhrrrdrdreriszTransientResource.__init__cCs|S)Nrd)rhrdrdrerszTransientResource.__enter__NcCsT|dk rPt|j|rPx:|jjD]$\}}t||s4Pt|||kr Pq WtddS)zIf type_ is a subclass of self.exc and value has attributes matching self.attrs, raise ResourceDenied. Otherwise let the exception propagate (if any).Nz%an optional resource is not available)rzrrrrrr )rhZtype_r tracebackrlZ attr_valuerdrdrers zTransientResource.__exit__)NNN)r`rarbrcrirrrdrdrdrer's)errnog>@)rerrnosc #spd!d"d#d$d%d&g}d(d*d,d.d/g}td||gsRdd|Ddd|Dfdd}tj}zy|dk rtj|dVWntjk r}z&trtjj j dd|WYdd}~Xnt k rZ}zpx^|j }t |d krt |dt r|d}n*t |dkr8t |d t r8|d }nPqW||WYdd}~XnXWdtj|XdS)0zReturn a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions. ECONNREFUSEDo ECONNRESETh EHOSTUNREACHq ENETUNREACHe ETIMEDOUTn EADDRNOTAVAILc EAI_AGAINr+EAI_FAILr EAI_NONAMEr EAI_NODATA WSANO_DATA*zResource %r is not availablecSsg|]\}}tt||qSrd)rr)rCrvnumrdrdrerDsz&transient_internet..cSsg|]\}}tt||qSrd)rr)rCrvrrdrdrerDscst|dd}t|tjst|tjr,|kst|tjjrTd|jkoNdknst|tjj rd|j ksd|j ksd|j ks|krt st j jjdd|dS) NriiWConnectionRefusedError TimeoutErrorEOFErrorr )r isinstancerrZgaierrorraerrorZ HTTPErrorcodeZURLErrorrrrostderrr`r)rn)captured_errnosdenied gai_errnosrdre filter_errors     z(transient_internet..filter_errorNrrr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)r rZgetdefaulttimeoutZsetdefaulttimeoutnntplibZNNTPTemporaryErrorrrorr`rrrr) Z resource_namerrZdefault_errnosZdefault_gai_errnosrZ old_timeoutrard)rrrrer+sP     c csFddl}tt|}tt||jztt|VWdtt||XdS)zReturn a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO.rN)iorrosetattrStringIO)Z stream_namerZ orig_stdoutrdrdrecaptured_outputs  rcCstdS)zCapture the output of sys.stdout: with captured_stdout() as stdout: print("hello") self.assertEqual(stdout.getvalue(), "hello\n") r)rrdrdrdrerscCstdS)zCapture the output of sys.stderr: with captured_stderr() as stderr: print("hello", file=sys.stderr) self.assertEqual(stderr.getvalue(), "hello\n") r)rrdrdrdrer%scCstdS)a Capture the input to sys.stdin: with captured_stdin() as stdin: stdin.write('hello\n') stdin.seek(0) # call test code that consumes from sys.stdin captured = input() self.assertEqual(captured, "hello") stdin)rrdrdrdrer.s cCs*tjtrtjdtjtjdS)aForce as many objects as possible to be collected. In non-CPython implementations of Python, this is needed because timely deallocation is not guaranteed by the garbage collector. (Even in CPython this can be the case in case of reference cycles.) This means that __del__ methods may be called later than expected and weakrefs may remain alive for longer than expected. This function tries its best to force all garbage objects to disappear. g?N)gcZcollectr@rrrdrdrdrer;s  rc cs.tj}tjz dVWd|r(tjXdS)N)r isenableddisableenable)Zhave_gcrdrdre disable_gcKs  rcCs:tjdp d}d}x|jD]}|jdr|}qW|dkS)z,Find if Python was built with optimizations. PY_CFLAGSrz-O-O0-Og)rrr) sysconfigget_config_varrrq)ZcflagsZ final_optrrdrdrepython_is_optimizedVs  rZnPZ0ngettotalrefcountZ2PZ0PrcCstjt|tS)N)structcalcsize_header_align)fmtrdrdre calcobjsizegsrcCstjt|tS)N)rr_vheaderr)rrdrdre calcvobjsizejsr cCspddl}tj|}t|tkr(|jt@sBt|tkrLt|jt@rL||j7}dt|||f}|j|||dS)Nrz&wrong size for %s: got %d, expected %d) _testcapiro getsizeofr __flags___TPFLAGS_HEAPTYPE_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrP)testosizerrrxrdrdre check_sizeofqs  rcsfdd}|S)Ncs$fdd}j|_j|_|S)Ncsy ddl}t|}|j|}Wn(tk r6YnBd}}Yn0Xx,D]$}y|j||PWqPYqPXqPWz ||S|r|r|j||XdS)Nr)localer setlocaler)rkwdsrrZ orig_localeloc)catstrrlocalesrdreinners$     z1run_with_locale..decorator..inner)r`rc)rr)rr)rrersz"run_with_locale..decoratorrd)rrrrd)rrrerUscsfdd}|S)Ncs"fdd}j|_j|_|S)Ncsy tj}Wntk r(tjdYnXdtjkr@tjd}nd}tjd<|z ||S|dkrrtjd=n |tjd<tjXdS)Nztzset requiredZTZ)rtzsetrrsrtrr)rrrZorig_tz)rtzrdrers       z-run_with_tz..decorator..inner)r`rc)rr)r)rrerszrun_with_tz..decoratorrd)rrrd)rrer\s cCsdttdtd}tjd|tjtjB}|dkr>td|ftt|j d||j dj }|a |t krrt }|t dkrtd|f|adS)Ni)rmgtz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rrr+z$Memory limit %r too low to be useful)_1M_1Grwrx IGNORECASEVERBOSErrfloatgrouplowerreal_max_memuseMAX_Py_ssize_t_2Gr)limitZsizesrZmemlimitrdrdrerYs $ c@s(eZdZdZddZddZddZdS) _MemoryWatchdogz`An object which periodically watches the process' memory consumption and prints it out. cCsdjtjd|_d|_dS)Nz/proc/{pid}/statm)r2F)rrr0procfilestarted)rhrdrdrerisz_MemoryWatchdog.__init__cCsyt|jd}Wn<tk rL}z tjdj|ttjj dSd}~XnXt d}t j tj |g|t jd|_|jd|_dS)Nrz!/proc not available for stats: {}zmemory_watchdog.py)rrT)r>r rrgrrrrorflushr subprocessPopen executableZDEVNULL mem_watchdogrr )rhrrZwatchdog_scriptrdrdrestarts   z_MemoryWatchdog.startcCs|jr|jj|jjdS)N)r rZ terminatewait)rhrdrdrestops z_MemoryWatchdog.stopN)r`rarbrcrirrrdrdrdrer sr csfdd}|S)atDecorator for bigmem tests. 'size' is a requested size for the test (in arbitrary, test-interpreted units.) 'memuse' is the number of bytes per unit for the test, or a good estimate of it. For example, a test that needs two byte buffers, of 4 GiB each, could be decorated with @bigmemtest(size=_4G, memuse=2). The 'size' argument is normally passed to the decorated test method as an extra argument. If 'dry_run' is true, the value passed to the test method may be less than the requested value. If 'dry_run' is false, it means the test doesn't support dummy runs when -M is not specified. cs fdd__S)Nc sj}j}tsd}n|}ts$ rFt||krFtjd||dtr|tr|ttdj||ddt}|j nd}z ||S|r|j XdS) Niz'not enough memory: %.1fG minimum neededir+z* ... expected peak memory use: {peak:.1f}G)Zpeaki@i@) rmemuserrsrtrrrr rr)rhrrmaxsizeZwatchdog)dry_runrrrdrers*    z.bigmemtest..decorator..wrapper)rr)r)rrr)rrrerszbigmemtest..decoratorrd)rrrrrd)rrrrer3s !csfdd}|S)z0Decorator for tests that fill the address space.csDttkr8td kr$td kr$tjdq@tjdtd n|SdS) Nr?rz-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir+llli@)rrrsrt)rh)rrdrer3sz!bigaddrspacetest..wrapperrd)rrrd)rrer41s c@seZdZddZdS)r,cCstj}|||S)N)rsZ TestResult)rhrrrdrdrerunDszBasicTestRunner.runN)r`rarbrrdrdrdrer,CscCs|S)Nrd)rrdrdre_idIsrcCs<|dkrt rtjtjSt|r(tStjdj|SdS)Nrzresource {0!r} is not enabled)rrsskiprr rr)rrdrdrerequires_resourceLs  rcCs&trt|krtjd|tfStSdS)Nz%s at Android API level %d)rA_ANDROID_API_LEVELrsrr)levelrrdrdrer>Ts  cCstdd|S)z9 Decorator for tests only applicable on CPython. T)cpython) impl_detail)rrdrdrer5[scKsVtf|rtS|dkrLt|\}}|r,d}nd}t|j}|jdj|}tj|S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or ) rBr _parse_guardsrErrrrsr)rxguardsZ guardnamesdefaultrdrdrer!as   r!c CsTtdkr:ddl}y|jdaWntk r8daYnXd}trF|Stj||S)z8Skip decorator for tests that use multiprocessing.Queue.NrTFz6requires a functioning shared semaphore implementation)_have_mp_queuemultiprocessingZQueuernrsr)rr&rxrdrdrer?os cCsH|sddidfSt|jd}t|j|gt|ks>t|| fS)Nr TFr)r|valuesrr)r#Zis_truerdrdrer"~s  r"cKs t|\}}|jtjj|S)a5This function returns True or False depending on the host platform. Examples: if check_impl_detail(): # only on CPython (default) if check_impl_detail(jython=True): # only on Jython if check_impl_detail(cpython=False): # everywhere except on CPython )r"r^rpZpython_implementationr)r#r$rdrdrerBs cs,ttdsStjfdd}|SdS)zEDecorator to temporarily turn off tracing for the duration of a test.gettracec s.tj}ztjd||Stj|XdS)N)ror(settrace)rrZoriginal_trace)rrdrers   zno_tracing..wrapperN)rrorr)rrrd)rre no_tracings r*cCs tt|S)aDecorator for tests which involve reference counting. To start, the decorator does not run the test if is not run by CPython. After that, any trace function is unset during the test to prevent unexpected refcounts caused by the trace function. )r*r5)rrdrdre refcount_testsr+cCsRg}xB|jD]8}t|tjr2t|||j|q ||r |j|q W||_dS)z>Recursively filter test cases in a suite based on a predicate.N)Z_testsrrs TestSuite _filter_suiter)suiteZpredZnewtestsrrdrdrer-s    r-cCsttjttdk d}|j|}tdk r4tj|j|js>t |j st |j dkrl|j rl|j dd}n6t |j dkr|j r|j dd}nd}ts|d7}t|dS)z2Run tests from a unittest.TestSuite-derived class.N) verbosityZcapture_outputrrzmultiple errors occurredz!; run in verbose mode for details)rrorrjunit_xml_listrrZget_xml_elementZtestsRunr Z wasSuccessfulrerrorsZfailuresr )r.Zrunnerrrrdrdre _run_suites"  r2cCstdkr dSt|jSdS)NT)_match_test_funcid)rrdrdre match_testsr5cCsd|kotjd| S)Nryz[?*\[\]])rwsearch)rrdrdre_is_full_match_testsr7csr|tkr dS|sd}f}nHttt|r4t|j}n.djttj|}t j |j fdd}|}t |a|a dS)N|cs$|r dStt|jdSdS)NTry)anyrr)Ztest_id) regex_matchrdrematch_test_regexsz)set_match_tests..match_test_regex)_match_test_patternsallrr7r __contains__rfnmatch translaterwrOrxrrr3)ZpatternsrZregexr;rd)r:reset_match_testss   rAcGstjtjf}tj}xh|D]`}t|trT|tjkrJ|jtjtj|qzt dqt||rj|j|q|jtj |qWt |t t |dS)z1Run tests from unittest.TestCase-derived classes.z)str arguments must be keys in sys.modulesN)rsr,ZTestCaserrurorzZaddTestZ findTestCasesrZ makeSuiter-r5r2)classesZ valid_typesr.clsrdrdrer-s        cCsdS)z,Just used to check if docstrings are enabledNrdrdrdrdre_check_docstrings(srDWITH_DOC_STRINGSztest requires docstringscCs`ddl}|dkrt}nd}|j|||d\}}|rBtd||ftrXtd|j|f||fS)aRun doctest on the given module. Return (#failures, #tests). If optional argument verbosity is not specified (or is None), pass support's belief about verbosity on to doctest. Else doctest's usual behavior is used (it searches sys.argv for -v). rN)r optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)doctestrZtestmodr rr`)rr/rFrGrrrdrdrer.9scCs tjjfS)N)rorzrrdrdrdre modules_setupTsrHcCs:ddtjjD}tjjtjj|tjj|dS)NcSs"g|]\}}|jdr||fqS)z encodings.)rq)rCrrrdrdrerD[sz#modules_cleanup..)rorzrrtr)Z oldmodulesZ encodingsrdrdremodules_cleanupWs  rIcCs"trtjtjjfSdffSdS)Nr)_thread_count threading _danglingrrdrdrdrerNzscGsJtsdSd}x8t|D],}tjtjf}||kr2PtjdtqWdS)Ndg{Gz?)rJrangerKrLrMrrr)Zoriginal_valuesZ _MAX_COUNTcountr'rdrdrerOs cs"tsStjfdd}|S)zUse this function when threads are being used. This will ensure that the threads are cleaned up even when the test fails. If threading is unavailable this function does nothing. c st}z|St|XdS)N)rNrO)rkey)rrdrerszreap_threads..decorator)rJrr)rrrd)rrerPsN@ccstj}z dVWdtj}||}xjtj}||kr8Ptj|kr|tj|}d||d|dd|d|d }t|tjdtq&WXdS) aH bpo-31234: Context manager to wait until all threads created in the with statement exit. Use _thread.count() to check if threads exited. Indirectly, wait until threads exit the internal t_bootstrap() C function of the _thread module. threading_setup() and threading_cleanup() are designed to emit a warning if a test leaves running threads in the background. This context manager is designed to cleanup threads started by the _thread.start_new_thread() which doesn't allow to wait for thread exit, whereas thread.Thread has a join() method. Nz!wait_threads() failed to cleanup z threads after z.1fz seconds (count: z , old count: )g{Gz?)rJrKrZ monotonicrrr)rZ old_countZ start_timeZdeadlinerPZdtrxrdrdrewait_threads_exits   $ rTc CsZttdrVd}xFy2tj|tj\}}|dkr.Ptd|tjdWqPYqXqWdS)zUse this function at the end of test_main() whenever sub-processes are started. This will help ensure that no extra children (zombies) stick around to hog resources and create problems when looking for refleaks. waitpidrrz2Warning -- reap_children() reaped child process %s)rNrZ)rrrUWNOHANGrror)Z any_processr2ZstatusrdrdrerLs ccs*t|}g}zZy$x|D]}|j|j|qWWn*trVtdt|t|fYnXdVWdz|rt|tj}}xltddD]^}|d7}x$|D]}|jt |tjdqWdd|D}|sPtrtdt||fqWWdd d|D}|r"t j t j td t|XXdS) Nz/Can't start %d threads, only %d threads startedrr<g{Gz?cSsg|]}|jr|qSrd)isAlive)rCrrdrdrerDsz!start_threads..z7Unable to join %d threads during a period of %d minutescSsg|]}|jr|qSrd)rX)rCrrdrdrerDszUnable to join %d threads)r|rrrrrrrOrmax faulthandlerZdump_tracebackrorr)ZthreadsZunlockr rZendtimeZ starttimerrdrdrerQs>     c csnt||rrrwrHrprrwrxrrrrr)ruZtmp_dirZtmp_fpZtmp_namefpZkernel_versionrrdrdre can_xattr s,    r|cCs t}d}|r|Stj||S)zDSkip decorator for tests that require functional extended attributesz(no non-broken extended attribute support)r|rsr)rrvrxrdrdrer8 scCs$t pt}d}|r|Stj||S)z;Skip decorator for tests not run in (non-extended) PGO taskz#Not run for (non-extended) PGO task)r] PGO_EXTENDEDrsr)rrvrxrdrdreskip_if_pgo_task s r~cCs^tj|dH}|j}|j}||kr,|j}ytjj||Stk rNdSXWdQRXdS)zKDetects if the file system for the specified directory is case-insensitive.)rxFN) r,ZNamedTemporaryFilervupperrrrsamefiler)Z directorybase base_pathZ case_pathrdrdrer s)rfcCs>tt|tt|}|r(|t|8}tdd|D}|S)a Returns the set of items in ref_api not in other_api, except for a defined list of items to be ignored in this check. By default this skips private attributes beginning with '_' but includes all magic methods, i.e. those starting and ending in '__'. css(|] }|jd s|jdr|VqdS)___N)rqendswith)rCrrdrdre sz&detect_api_mismatch..)rrx)Zref_apiZ other_apirfZ missing_itemsrdrdrer< s  cCs|dkr|jf}nt|tr"|f}t|}xbt|D]V}|jds4||krLq4t||}t|dd|kst|d r4t|tj  r4|j |q4W|j |j |dS)aAssert that the __all__ variable of 'module' contains all public names. The module's public names (its API) are detected automatically based on whether they match the public name convention and were defined in 'module'. The 'name_of_module' argument can specify (as a string or tuple thereof) what module(s) an API could be defined in in order to be detected as a public API. One case for this is when 'module' imports part of its public API from other modules, possibly a C backend (like 'csv' and its '_csv'). The 'extra' argument can be a set of names that wouldn't otherwise be automatically detected as "public", like objects without a proper '__module__' attribute. If provided, it will be added to the automatically detected ones. The 'blacklist' argument can be a set of names that must not be treated as part of the public API even though their names indicate otherwise. Usage: import bar import foo import unittest from test import support class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, foo) class OtherTestCase(unittest.TestCase): def test__all__(self): extra = {'BAR_CONST', 'FOO_CONST'} blacklist = {'baz'} # Undocumented name. # bar imports part of its API from _bar. support.check__all__(self, bar, ('bar', '_bar'), extra=extra, blacklist=blacklist) Nrra) r`rrurrxrqrrtypes ModuleTypeaddZassertCountEqual__all__)Z test_caserZname_of_moduleZextraZ blacklistZexpectedrvrrdrdrer= s)    c@s(eZdZdZdZdZddZddZdS)rZzTry to prevent a crash report from popping up. On Windows, don't display the Windows Error Reporting dialog. On UNIX, disable the creation of coredump file. Nc Csrtjjdrddl}|jj|_d}|jj||_|jj|j|Byddl }|j Wnt t fk rlYnLXi|_ x|j|j|jgD].}|j ||j}|j||j}||f|j |<qWntdk r y*tjtj|_tjtjd|jdfWnttfk rYnXtjdkrnddd d g}tj|tjtjd }||jd} WdQRX| jd krntd ddd|S)zOn Windows, disable Windows Error Reporting dialogs using SetErrorMode. On UNIX, try to save the previous core file size limit, then set soft limit to 0. rrNrrrz/usr/bin/defaultsr_zcom.apple.CrashReporterZ DialogType)rrs developerz:this test triggers the Crash Reporter, that is intentionalrT)endr ) rorprqrrr_k32 SetErrorMode old_valuemsvcrtCrtSetReportModerrn old_modesCRT_WARN CRT_ERROR CRT_ASSERTZCRTDBG_MODE_FILECrtSetReportFileZCRTDBG_FILE_STDERRrZ getrlimit RLIMIT_CORE setrlimitrrrrPIPEZ communicaterar) rhrZSEM_NOGPFAULTERRORBOXr report_typeold_modeold_filecmdprocrrdrdrer2 sN        zSuppressCrashReport.__enter__c Gs|jdkrdStjjdrl|jj|j|jrddl}xj|jjD]$\}\}}|j |||j ||qBWn6t dk ryt j t j |jWnttfk rYnXdS)zARestore Windows ErrorMode or core file behavior to initial value.Nrr)rrorprqrrrrrrrrrrrr)rhrrrrrrdrdrers s   zSuppressCrashReport.__exit__)r`rarbrcrrrrrdrdrdrerZ) s Ac srtdyjWn$ttfk r@tdYnXdfdd}|j|t|dS)zOverride 'object_to_patch'.'attr_name' with 'new_value'. Also, add a cleanup procedure to 'test_instance' to restore 'object_to_patch' value for 'attr_name'. The 'attr_name' should be a valid attribute for 'object_to_patch'. FNTcs rtn tdS)N)rr[rd) attr_is_local attr_nameobject_to_patchrrdrecleanup szpatch..cleanup)rrjrrZ addCleanupr)Z test_instancerrZ new_valuerrd)rrrrrepatch s  rc CsFy ddl}Wntk r YnX|jr4tjdddl}|j|S)zi Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc module is enabled. rNzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations) tracemallocrnZ is_tracingrsrtrrun_in_subinterp)rrrrdrdrer s  rcsHGfddd|}d||||jttt|jdS)NcseZdZfddZdS)z%check_free_after_iterating..Ac s*dy tWntk r$YnXdS)NT)next StopIteration)rh)doneitrdre__del__ s  z-check_free_after_iterating..A.__del__N)r`rarbrrd)rrrdreA srF)rMrrrZ assertTrue)rrrCrrrd)rrrecheck_free_after_iterating s   rcCsddlm}m}m}|j}|j|xd|jD]Z}|r@||kr@q.t||}|rd|dk sntd|n |dkrnq.|j |ddkr.|dSq.WdS)a<Check if the compiler components used to build the interpreter exist. Check for the existence of the compiler executables whose names are listed in 'cmd_names' or all the compiler executables when 'cmd_names' is empty and return the first missing executable or None when none is found missing. r) ccompilerrspawnNz%the '%s' executable is not configured) Z distutilsrrrZ new_compilerZcustomize_compilerZ executablesrrZfind_executable)Z cmd_namesrrrZcompilerrvrrdrdrer^ s       cCs@d}tr6||kr6tdkr.tjddgjdkatr6|}tj|S)Ngh㈵>Zgetpropzro.kernel.qemu1)rA_is_android_emulatorrZ check_outputrarorD)ZintervalZminimum_intervalrdrdrerD s c cs>tjj}tj}ztjdVWd|r8tj|ddXdS)NT)rZ all_threads)rorrHrZ is_enabledrr)rBrrdrdredisable_faulthandler s  rc /Cstjjd r8ytjd}t|dStk r6YnXd}ttdrjytjd}Wnt k rhYnXd}tjd kryd dl }|j Wnt t fk rYn0Xi}x(|j|j|jfD]}|j |d ||<qWzpd }xft|D]Z}ytj|}Wn4t k r(}z|jtjkrWYdd}~XqXtj||d7}qWWd|dk rzx*|j|j|jfD]}|j |||q`WX|S) z/Count the number of open file descriptors. linuxfreebsdz /proc/self/fdrsysconf SC_OPEN_MAXNrr)rr)rorprqrrrrrrrrrrrnrrrrOduprZEBADFr) namesZMAXFDrrrrPrBZfd2rrdrdrer_ sP          c@s(eZdZdZddZddZddZdS) SaveSignalsz Save an restore signal handlers. This class is only able to save/restore signal handlers registered by the Python signal module: see bpo-13285 for "external" signal handlers. c Csjddl}||_ttd|j|_x>dD]6}yt||}Wntk rNw&YnX|jj|q&Wi|_dS)NrrSIGKILLSIGSTOP)rr) signalr|rONSIGsignalsrrr{rf)rhrZsignamesignumrdrdreriM s zSaveSignals.__init__cCs4x.|jD]$}|jj|}|dkr"q||j|<qWdS)N)rr getsignalrf)rhrhandlerrdrdresaveZ s   zSaveSignals.savecCs*x$|jjD]\}}|jj||q WdS)N)rfrr)rhrrrdrdrerestoref szSaveSignals.restoreN)r`rarbrcrirrrdrdrdrerD s  rc@s(eZdZdZddZddZddZdS) FakePathz.Simple implementing of the path protocol. cCs ||_dS)N)r)rhrrdrdrerin szFakePath.__init__cCsd|jdS)Nz )r)rhrdrdre__repr__q szFakePath.__repr__cCs6t|jts$t|jtr,t|jtr,|jn|jSdS)N)rr BaseExceptionrrz)rhrdrdre __fspath__t s    zFakePath.__fspath__N)r`rarbrcrirrrdrdrdrerk src cs.tj}ztj|dVWdtj|XdS)z>Temporarily change the integer string conversion length limit.N)roget_int_max_str_digitsset_int_max_str_digits)Z max_digitsZcurrentrdrdreadjust_int_max_str_digits| s   rcCsddtddDdgS)zReturns a list of C0 control characters as strings. C0 control characters defined as the byte range 0x00-0x1F, and 0x7F. cSsg|] }t|qSrd)chr)rCrrdrdrerD sz)control_characters_c0..r )rOrdrdrdrecontrol_characters_c0 sr)T)F)F)N)Nii@i@i@ii) rrrrrrrr r!r"r#)r'r%r(r)r*)NF)F)r7F)N)Fi@ii)T)N)Nr)rR)N(rcr`rncollections.abc collections contextlibZdatetimerrZr?rrrrmimportlib.utilrZlogging.handlersrerrrprwrrrrrrorr,rrrsZ urllib.errorrargZ testresultrrJrLZmultiprocessing.processr&zlibrXbz2Zlzmarrrrr r r rtr contextmanagerrkr rrr:r;rr6rrrrr0rrrrrrrqrrrrrrrrrrrr r!rr"r#r$r%rErr r rGrHrJrrFrrZ SOCK_MAX_SIZEZ skipUnlessr __getformat__r7r9r0r1r2r@rrrArCrvrrr0Z FS_NONASCII characterfsdecodefsencode UnicodeErrorZTESTFN_UNICODEZ unicodedata normalizegetfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversionencodeUnicodeEncodeErrorrdecodeUnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr4rr]r}r3r6rrrKrrrrZTEST_SUPPORT_DIRr;rr]rrr[rIr&rIobjectrerrRrrrSrabcMutableMappingrTrr'rrr(rr)r*r+rrrrrrrrrrrrrrrrUr\rrrZ_4GrrrYr r3r4r,rrr>r5r!r%r?r"rBr*r+r-r2r3r<r5r7rAr-rDZMISSING_C_DOCSTRINGSZHAVE_DOCSTRINGSZrequires_docstringsr.rHrIZenvironment_alteredrNrOrPrTrLrQrWrVrbZskipIfZrequires_type_collectingrcrdrfrgrMrXrrrr/rzr|r8r~rr<r=rZrrrr^rrDrr_rrrrrdrdrdres                      2   !  J    > %                 %      2 ' 5M            $ # 0           (        " #   "    :_"  ;' PK`]/J6support/__pycache__/script_helper.cpython-36.opt-1.pycnu[3 _Vj)@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZmZdaddZGdddejdd#Zd d Zd dZddZddZejejdddZddZd$ddZd%ddZd&ddZd'd!d"ZdS)(N)source_from_cache)make_legacy_pycstrip_python_stderrc CsVtdkrRdtjkrdadSytjtjdddgWntjk rLdaYnXdatS)a  Returns True if our sys.executable interpreter requires environment variables in order to be able to run at all. This is designed to be used with @unittest.skipIf() to annotate tests that need to use an assert_python*() function to launch an isolated mode (-I) or no environment mode (-E) sub-interpreter process. A normal build & test does not run into this situation but it can happen when trying to run the standard library test suite from an interpreter that doesn't have an obvious home with Python's current home finding logic. Setting PYTHONHOME is one way to get most of the testsuite to run in that situation. PYTHONPATH or PYTHONUSERSITE are other common environment variables that might impact whether or not the interpreter can start. NZ PYTHONHOMETz-Ez-czimport sys; sys.exit(0)F)$__cached_interp_requires_environmentosenviron subprocessZ check_callsys executableZCalledProcessErrorr r 2/usr/lib64/python3.6/test/support/script_helper.py interpreter_requires_environments   r c@seZdZdZddZdS)_PythonRunResultz2Helper for reporting Python subprocess run resultscCsd }|j|j}}t||kr0d|| d}t||krNd|| d}|jddj}|jddj}td|j|||fdS) z4Provide helpful details about failed subcommand runsPds(... truncated stdout ...)Ns(... truncated stderr ...)asciireplacezRProcess return code is %d command line: %r stdout: --- %s --- stderr: --- %s ---i@)outerrlendecoderstripAssertionErrorrc)selfcmd_linemaxlenrrr r r fail>s   z_PythonRunResult.failN)__name__ __module__ __qualname____doc__rr r r r r;srrrrc Ost}d|kr|jd}n | o$| }tjddg}|rB|jdn| rX| rX|jd|jddri}tjdkrtjd|d<n tjj}d |krd |d <|j ||j |t j |t j t j t j |d }|*z|j\}}Wd|jt jXWdQRX|j} t|}t| |||fS) NZ __isolatedz-XZ faulthandlerz-Iz-EZ __cleanenvZwin32Z SYSTEMROOTTERM)stdinstdoutstderrenv)r popr r appendplatformrrcopyupdateextendrPopenPIPEZ communicatekill_cleanup returncoderr) argsenv_varsZ env_requiredisolatedrr'procrrrr r r run_python_until_end[s:            r7cOs4t||\}}|jr|s&|j r0| r0|j||S)N)r7rr)Zexpected_successr3r4resrr r r _assert_pythons r9cOstd||S)a| Assert that running the interpreter with `args` and optional environment variables `env_vars` succeeds (rc == 0) and return a (return code, stdout, stderr) tuple. If the __cleanenv keyword is set, env_vars is used as a fresh environment. Python is started in isolated mode (command line option -I), except if the __isolated keyword is set to False. T)T)r9)r3r4r r r assert_python_oks r:cOstd||S)z Assert that running the interpreter with `args` and optional environment variables `env_vars` fails (rc != 0) and return a (return code, stdout, stderr) tuple. See assert_python_ok() for more options. F)F)r9)r3r4r r r assert_python_failuresr;)r%r&cOsXtjg}ts|jd|j||jdttj}d|d<t j |ft j ||d|S)zRun a Python subprocess with the given arguments. kw is extra keyword args to pass to subprocess.Popen. Returns a Popen object. z-Er'Zvt100r")r$r%r&) r r r r)r- setdefaultdictrrrr.r/)r%r&r3kwrr'r r r spawn_pythons   r?cCs2|jj|jj}|jj|jtj|S)z?Run the given Popen process until completion and return stdout.)r$closer%readwaitrr1)pdatar r r kill_pythons    rEFcCsP|}|s|tjd7}tjj||}t|ddd}|j||jtj|S)Npywzutf-8)encoding) rextseppathjoinopenwriter@ importlibinvalidate_caches)Z script_dirscript_basenamesourceZ omit_suffixZscript_filename script_nameZ script_filer r r make_scripts rSc Cs|tjd}tjj||}tj|d}|dkr~|jtj}t|dkrr|ddkrrt t |}tjj |}|}n tjj |}|j |||j |tjj||fS)NziprG __pycache__)rrIrJrKzipfileZipFilesplitseprrrbasenamerMr@) zip_dir zip_basenamerRZ name_in_zip zip_filenamezip_namezip_filepartsZ legacy_pycr r r make_zip_scripts      rcr#cCstj|t|d|dS)N__init__)rmkdirrS)Zpkg_dirZ init_sourcer r r make_pkgs rfcs0g}t|dd}|j|tjj|} t|||} |j| |rjtj|dd}tj| dd} |j|| ffddtd|dD} tjj | d tjj| } |tj d} tjj || }t j |d }x&| D]}tjj || }|j ||qW|j | | |jx|D]}tj|q W|tjj || fS) Nrdr#T)doraisecsg|]}tjjg|qSr )rr[rK).0i)pkg_namer r sz make_zip_pkg..rgrTrG)rSr)rrJr\ py_compilecompiler-rangerKrIrXrYrMr@unlink)r]r^rkrPrQZdepthZcompiledrqZ init_nameZ init_basenamerRZ pkg_namesZscript_name_in_zipr_r`ranameZinit_name_in_zipr )rkr make_zip_pkgs.         rs)rrr)F)N)r#)rgF) collectionsrNr rZos.pathZtempfilerrn contextlibZshutilrXimportlib.utilrZ test.supportrrrr namedtuplerr7r9r:r;r/ZSTDOUTr?rErSrcrfrsr r r r s4 $3    PK`]>>1support/__pycache__/__init__.cpython-36.opt-1.pycnu[3 _Vj@sl dZedkredddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZ ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl!Z"ddl#Z#ddl$m%Z%yddl&Z&ddl'Z'Wnek rBdZ&dZ'YnXy ddl(Z)Wnek rjdZ)YnXy ddl*Z*Wnek rdZ*YnXy ddl+Z+Wnek rdZ+YnXy ddl,Z,Wnek rdZ,YnXy ddl-Z-Wnek r dZ-YnXy ddl.Z.Wnek r2dZ.YnXy ddl/Z/Wnek rZdZ/YnXddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbg\Z0Gdcd d e1Z2Gddd d e2Z3Gdedde2Z4Gdfdde j5Z6ej7dhdhdiZ8difdkdldZ9dmdnZ:dodpZ;dqd=ZZ=ffdjfdsdZ>dtd9Z?dZ@dZAdaBdaCdZDdjZEdaFdudZGdvdZHdwdZIdxdyZJejjKdzr.djd{d|ZLd}d~ZMddZNddZOddZPnejQZMejRZNddZOddZPddZQddZRddZSddZTddZUddZVdd#ZWdkdd$ZXddZYdd%ZZdd&Z[dd'Z\dldd(Z]dZ^dZ_ej`ejafddJZbe^fddKZcddMZdddZeeeZfddZgdoZhdrZie jjekjldjKddZme jje*dZne jje+dZoe jje,dZpe jje-dZqejjKdZrejsdZtetdk oxetdkZuejdkreurdndZvndZvejwdkrdZxndZxdjyexejzZxdZ{xLdsD]BZ|yej}ej~e|e|kreWnek rYnXe|Z{PqWexdZejdkr:ddlZejdeZejZdZejwdkrejjdkrexdZyejeWnek rYnXedeefdZnBejdkrydjeWn&ek rexdjedǃZYnXdZxFdtD]dYZd?d@Ze jeedAdBZdCdDZdEdFZGdGdPdPejjZGdHd[d[eZdadId!ZdJd2ZdadKdLZdMd;ZdNdOZdPd"ZfdQdRd?Z dfffdSd@Z GdTd]d]Z dUdVZ dWdXZ ffdYdZZgfd[daZdad\dGZej7d]d^Zd_dbZGd`dadaZGdbdcdcZej7dddeZdfdgZdS(z7Supporting definitions for the Python regression tests.z test.supportz.support must be imported from the test packageN)get_test_runner PIPE_MAX_SIZEverbose max_memuse use_resourcesfailfastError TestFailed TestDidNotRunResourceDenied import_moduleimport_fresh_module CleanImportunloadforgetrecord_original_stdoutget_original_stdoutcaptured_stdoutcaptured_stdincaptured_stderrTESTFNSAVEDCWDunlinkrmtreetemp_cwdfindfilecreate_empty_file can_symlinkfs_is_case_insensitiveis_resource_enabledrequiresrequires_freebsd_versionrequires_linux_versionrequires_mac_verrequires_hashdigestcheck_syntax_errorTransientResourcetime_outsocket_peer_resetioerror_peer_resettransient_internetBasicTestRunner run_unittest run_doctestskip_unless_symlink requires_gzip requires_bz2 requires_lzma bigmemtestbigaddrspacetest cpython_only get_attributerequires_IEEE_754skip_unless_xattr requires_zlibanticipate_failureload_package_testsdetect_api_mismatch check__all__requires_android_levelrequires_multiprocessing_queue is_jython is_androidcheck_impl_detail unix_shellsetswitchintervalHOST IPV6_ENABLEDfind_unused_port bind_portopen_urlresourcebind_unix_socket temp_umask reap_children TestHandlerthreading_setupthreading_cleanup reap_threads start_threadscheck_warningscheck_no_resource_warningEnvironmentVarGuardrun_with_locale swap_item swap_attrMatcher set_memlimitSuppressCrashReportsortdict run_with_tzPGOmissing_compiler_executablefd_countc@seZdZdZdS)r z*Base class for regression test exceptions.N)__name__ __module__ __qualname____doc__rdrd-/usr/lib64/python3.6/test/support/__init__.pyr |sc@seZdZdZdS)r z Test failed.N)r`rarbrcrdrdrdrer sc@seZdZdZdS)r zTest did not run any subtests.N)r`rarbrcrdrdrdrer sc@seZdZdZdS)r zTest skipped because it requested a disallowed resource. This is raised when a test calls requires() for a resource that has not be enabled. It is used to distinguish between expected and unexpected skips. N)r`rarbrcrdrdrdrer sTc cs8|r.tjtjddtdVWdQRXndVdS)zContext manager to suppress package and module deprecation warnings when importing them. If ignore is False, this context manager has no effect. ignorez.+ (module|package)N)warningscatch_warningsfilterwarningsDeprecationWarning)rfrdrdre_ignore_deprecated_importss  rkF) required_oncCsft|Ty tj|Stk rV}z&tjjt|r8tj t |WYdd}~XnXWdQRXdS)acImport and return the module to be tested, raising SkipTest if it is not available. If deprecated is True, any module or package deprecation messages will be suppressed. If a module is required on a platform but optional for others, set required_on to an iterable of platform prefixes which will be compared against sys.platform. N) rk importlibr ImportErrorsysplatform startswithtupleunittestSkipTeststr)name deprecatedrlmsgrdrdrer s  cCs^|tjkrt|tj|=x>ttjD]0}||ks@|j|dr&tj|||<tj|=q&WdS)zyHelper function to save and remove a module from sys.modules Raise ImportError if the module can't be imported. .N)romodules __import__listrq)rv orig_modulesmodnamerdrdre_save_and_remove_modules rc Cs>d}ytj|||<Wntk r.d}YnXdtj|<|S)zHelper function to save and block a module in sys.modules Return True if the module was in sys.modules, False otherwise. TFN)rorzKeyError)rvr}Zsavedrdrdre_save_and_block_modules  rcCs|r tjSddS)zDecorator to mark a test that is known to be broken in some cases Any use of this decorator should have a comment identifying the associated tracker issue. cSs|S)Nrd)frdrdresz$anticipate_failure..)rsZexpectedFailure)Z conditionrdrdrer:scCsF|dkr d}tjjtjjtjjt}|j|||d}|j||S)zGeneric load_tests implementation for simple test packages. Most packages can implement load_tests using this function as follows: def load_tests(*args): return load_package_tests(os.path.dirname(__file__), *args) Nztest*)Z start_dirZ top_level_dirpattern)ospathdirname__file__ZdiscoverZaddTests)Zpkg_dirloaderZstandard_testsrZtop_dirZ package_testsrdrdrer;s c Cst|i}g}t||zfyHx|D]}t||q&Wx |D]}t||s>|j|q>Wtj|}Wntk r~d}YnXWdx|jD]\} } | tj | <qWx|D] } tj | =qWX|SQRXdS)aImport and return a module, deliberately bypassing sys.modules. This function imports and returns a fresh copy of the named Python module by removing the named module from sys.modules before doing the import. Note that unlike reload, the original module is not affected by this operation. *fresh* is an iterable of additional module names that are also removed from the sys.modules cache before doing the import. *blocked* is an iterable of module names that are replaced with None in the module cache during the import to ensure that attempts to import them raise ImportError. The named module and any modules named in the *fresh* and *blocked* parameters are saved before starting the import and then reinserted into sys.modules when the fresh import is complete. Module and package deprecation messages are suppressed during this import if *deprecated* is True. This function will raise ImportError if the named module cannot be imported. N) rkrrappendrmr rnitemsrorz) rvZfreshZblockedrwr}Znames_to_removeZ fresh_nameZ blocked_nameZ fresh_moduleZ orig_namemoduleZname_to_removerdrdrers$      c Cs>yt||}Wn&tk r4tjd||fYnX|SdS)z?Get an attribute, raising SkipTest if AttributeError is raised.zobject %r has no attribute %rN)getattrAttributeErrorrsrt)objrvZ attributerdrdrer6s cCs|adS)N)_original_stdout)stdoutrdrdrer0scCs tptjS)N)rrorrdrdrdrer4sc Cs&y tj|=Wntk r YnXdS)N)rorzr)rvrdrdrer7s cGsny||Stk rh}zDtdkrHtd|jj|ftd|j|ftj|tj||Sd}~XnXdS)Nz%s: %sz re-run %s%r) OSErrorrprint __class__r`rchmodstatS_IRWXU)rfuncargserrrdrdre _force_run=srwincCs|||r|}ntjj|\}}|p(d}d}x<|dkrjtj|}|rJ|n||ksVdStj||d9}q0Wtjd|tdddS)NrygMbP?g?rz)tests may fail, delete still pending for ) stacklevel) rrsplitlistdirtimesleeprgwarnRuntimeWarning)rpathnamewaitallrrvtimeoutLrdrdre_waitforHs     rcCsttj|dS)N)rrr)filenamerdrdre_unlinkisrcCsttj|dS)N)rrrmdir)rrdrdre_rmdirlsrcs,fddt|ddtdd|dS)Ncsxt|tj|D]}tjj||}ytj|j}Wn<tk rn}z td||ft j dd}WYdd}~XnXt j |rt |ddt|tj|qt|tj|qWdS)Nz-support.rmtree(): os.lstat(%r) failed with %s)filerT)r)rrrrjoinlstatst_moderrro __stderr__rS_ISDIRrrr)rrvfullnamemodeexc) _rmtree_innerrdrerps   z_rmtree.._rmtree_innerT)rcSst|tj|S)N)rrr)prdrdrersz_rmtree..)r)rrd)rre_rmtreeos rc Cs^y ddl}Wntk r Yn:X|jt|d}|jjj||t|}|rZ|d|S|S)Nrr)ctypesrnZcreate_unicode_bufferlenwindllkernel32ZGetLongPathNameW)rrbufferZlengthrdrdre _longpaths    rc sFytj|dStk r"YnXfdd|tj|dS)Nc sx~t|tj|D]l}tjj||}ytj|j}Wntk rJd}YnXtj |rn|t|tj |qt|tj |qWdS)Nr) rrrrrrrrrrrr)rrvrr)rrdrers  z_rmtree.._rmtree_inner)shutilrrrr)rrd)rrers  cCs|S)Nrd)rrdrdrersc Cs*y t|Wnttfk r$YnXdS)N)rFileNotFoundErrorNotADirectoryError)rrdrdrers c Cs&y t|Wntk r YnXdS)N)rr)rrdrdrers rc Cs&y t|Wntk r YnXdS)N)rr)rrdrdrers cCsBtjj|}tjjtjj|}tjj||d}tj|||S)aMove a PEP 3147/488 pyc file to its legacy pyc location. :param source: The file system path to the source file. The source file does not need to exist, however the PEP 3147/488 pyc file must exist. :return: The file system path to the legacy pyc file. c) rmutilcache_from_sourcerrrabspathrrename)sourceZpyc_fileZup_oneZ legacy_pycrdrdremake_legacy_pycs   rcCs\t|xNtjD]D}tjj||d}t|dx dD]}ttjj||dq8WqWdS) z'Forget' a module was ever imported. This removes the module from sys.modules and deletes any PEP 3147/488 or legacy .pyc files. z.pyrrr) optimizationN)rrr) rrorrrrrmrr)r~rroptrdrdrers    csttdrtjSd}tjjdrddlddld}d}Gfdddj}j j }|j }|sjj |}j j}|j||j|j|j|}|sj t|j|@sd}ntjdkrVdd lm} mm} m} dd lm} | j| d } | jdkrd }nFGfd dd| }|}| |}| j|dksR| j|dkrVd}|sy.ddlm}|}|j|j |j!Wn\t"k r}z>t#|}t$|dkr|ddd}dj%t&|j'|}WYdd}~XnX|t_(| t_tjS)Nresultrrrcs.eZdZdjjfdjjfdjjfgZdS)z*_is_gui_available..USEROBJECTFLAGSZfInheritZ fReserveddwFlagsN)r`rarbwintypesZBOOLDWORD_fields_rd)rrdreUSEROBJECTFLAGSs  rz,gui not available (WSF_VISIBLE flag not set)darwin)cdllc_intpointer Structure) find_libraryZApplicationServicesz0gui tests cannot run without OS X window managercseZdZdfdfgZdS)z._is_gui_available..ProcessSerialNumberZ highLongOfPSNZ lowLongOfPSNN)r`rarbrrd)rrdreProcessSerialNumbersrz#cannot run without OS X gui process)Tk2z [...]zTk unavailable due to {}: {}))hasattr_is_gui_availablerrorprqrZctypes.wintypesrrZuser32ZGetProcessWindowStationZWinErrorrrZGetUserObjectInformationWZbyrefZsizeofboolrrrrZ ctypes.utilrZ LoadLibraryZCGMainDisplayIDZGetCurrentProcessZSetFrontProcessZtkinterrZwithdrawupdateZdestroy Exceptionrurformattyper`reason)rZ UOI_FLAGSZ WSF_VISIBLErZdllhZuofZneededresrrrrZ app_servicesrZpsnZpsn_prrooteZ err_stringrd)rrrersh         rcCstdkp|tkS)zTest whether a resource is enabled. Known resources are set by regrtest.py. If not running under regrtest.py, all resources are assumed enabled unless use_resources has been set. N)r)resourcerdrdrer $scCs>t|s |dkrd|}t||dkr:t r:ttjdS)z@Raise ResourceDenied if the specified resource is not available.Nz"Use of the %r resource not enabledgui)r r rr)rrxrdrdrer!,s csfdd}|S)zDecorator raising SkipTest if the OS is `sysname` and the version is less than `min_version`. For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if the FreeBSD version is less than 7.2. cs$tjfdd}|_|S)Nc stjkrztjjddd}yttt|jd}Wntk rLYn.X|krzdjtt }t j d||f||S)N-rrryz(%s version %s or higher required, not %s) rpsystemreleaserrrmapint ValueErrorrrursrt)rkw version_txtversionmin_version_txt)r min_versionsysnamerdrewrapper=s z:_requires_unix_version..decorator..wrapper) functoolswrapsr)rr)rr)rre decorator<sz)_requires_unix_version..decoratorrd)rrrrd)rrre_requires_unix_version5srcGs td|S)zDecorator raising SkipTest if the OS is FreeBSD and the FreeBSD version is less than `min_version`. For example, @requires_freebsd_version(7, 2) raises SkipTest if the FreeBSD version is less than 7.2. ZFreeBSD)r)rrdrdrer"PscGs td|S)zDecorator raising SkipTest if the OS is Linux and the Linux version is less than `min_version`. For example, @requires_linux_version(2, 6, 32) raises SkipTest if the Linux version is less than 2.6.32. ZLinux)r)rrdrdrer#Yscsfdd}|S)zDecorator raising SkipTest if the OS is Mac OS X and the OS X version if less than min_version. For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version is lesser than 10.5. cs"tjfdd}|_|S)Nc sxtjdkrntjd}yttt|jd}Wntk rBYn,X|krndjtt }t j d||f||S)Nrrryz&Mac OS X %s or higher required, not %s) rorpZmac_verrrrrrrrrursrt)rrrrr)rrrdrerjs   z4requires_mac_ver..decorator..wrapper)rrr)rr)r)rrerisz#requires_mac_ver..decoratorrd)rrrd)rrer$bs csfdd}|S)aDecorator raising SkipTest if a hashing algorithm is not available The hashing algorithm could be missing or blocked by a strict crypto policy. If 'openssl' is True, then the decorator checks that OpenSSL provides the algorithm. Otherwise the check falls back to built-in implementations. ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS ValueError: unsupported hash type md4 cstjfdd}|S)Nc sXy&rtdk rtjn tjWn&tk rLtjddYnX||S)Nz hash digest 'z' is not available.)_hashlibnewhashlibrrsrt)rkwargs) digestnameropensslrdrers  z7requires_hashdigest..decorator..wrapper)rr)rr)rr)rrers z&requires_hashdigest..decoratorrd)rrrrd)rrrer%}s z 127.0.0.1z::1cCs"tj||}t|}|j~|S)a Returns an unused port that should be suitable for binding. This is achieved by creating a temporary socket with the same family and type as the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to the specified host address (defaults to 0.0.0.0) with the port set to 0, eliciting an unused ephemeral port from the OS. The temporary socket is then closed and deleted, and the ephemeral port is returned. Either this method or bind_port() should be used for any tests where a server socket needs to be bound to a particular port for the duration of the test. Which one to use depends on whether the calling code is creating a python socket, or if an unused port needs to be provided in a constructor or passed to an external program (i.e. the -accept argument to openssl's s_server mode). Always prefer bind_port() over find_unused_port() where possible. Hard coded ports should *NEVER* be used. As soon as a server socket is bound to a hard coded port, the ability to run multiple instances of the test simultaneously on the same host is compromised, which makes the test a ticking time bomb in a buildbot environment. On Unix buildbots, this may simply manifest as a failed test, which can be recovered from without intervention in most cases, but on Windows, the entire python process can completely and utterly wedge, requiring someone to log in to the buildbot and manually kill the affected process. (This is easy to reproduce on Windows, unfortunately, and can be traced to the SO_REUSEADDR socket option having different semantics on Windows versus Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind, listen and then accept connections on identical host/ports. An EADDRINUSE OSError will be raised at some point (depending on the platform and the order bind and listen were called on each socket). However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE will ever be raised when attempting to bind two identical host/ports. When accept() is called on each socket, the second caller's process will steal the port from the first caller, leaving them both in an awkwardly wedged state where they'll no longer respond to any signals or graceful kills, and must be forcibly killed via OpenProcess()/TerminateProcess(). The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option instead of SO_REUSEADDR, which effectively affords the same semantics as SO_REUSEADDR on Unix. Given the propensity of Unix developers in the Open Source world compared to Windows ones, this is a common mistake. A quick look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when openssl.exe is called with the 's_server' option, for example. See http://bugs.python.org/issue2550 for more info. The following site also has a very thorough description about the implications of both REUSEADDR and EXCLUSIVEADDRUSE on Windows: http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx) XXX: although this approach is a vast improvement on previous attempts to elicit unused ports, it rests heavily on the assumption that the ephemeral port returned to us by the OS won't immediately be dished back out to some other process when we close and delete our temporary socket but before our calling code has a chance to bind the returned port. We can deal with this issue if/when we come across it. )socketrHclose)familyZsocktypeZtempsockportrdrdrerGs 8 c Cs|jtjkr|jtjkrttdr>|jtjtjdkr>t dttdr~y |jtjtj dkrft dWnt k r|YnXttdr|j tjtj d|j|df|jd}|S)a%Bind the socket to a free port and return the port number. Relies on ephemeral ports in order to ensure we are using an unbound port. This is important as many tests may be running simultaneously, especially in a buildbot environment. This method raises an exception if the sock.family is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR or SO_REUSEPORT set on it. Tests should *never* set these socket options for TCP/IP sockets. The only case for setting these options is testing multicasting via multiple UDP sockets. Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e. on Windows), it will be set on the socket. This will prevent anyone else from bind()'ing to our host/port for the duration of the test. SO_REUSEADDRrzHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets! SO_REUSEPORTzHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!SO_EXCLUSIVEADDRUSEr)rrAF_INETr SOCK_STREAMrZ getsockoptZ SOL_SOCKETrr rrZ setsockoptrbindZ getsockname)sockhostrrdrdrerHs     c Cs:y|j|Wn&tk r4|jtjdYnXdS)zBBind a unix socket, raising SkipTest if PermissionError is raised.zcannot bind AF_UNIX socketsN)r PermissionErrorrrsrt)r ZaddrrdrdrerJs cCsZtjrVd}z.dec)rr)rrrd)rresystem_must_validate_certs rriZdoubleZIEEEztest requires IEEE 754 doublesz requires zlibz requires gzipz requires bz2z requires lzmajavaANDROID_API_LEVELwin32z/system/bin/shz/bin/shz$testz@testz {}_{}_tmpæİŁφКא،تก €u -àòɘŁğrZNFDntru-共Ł♡ͣztWARNING: The filename %r CAN be encoded by the filesystem encoding (%s). Unicode filename tests may not be effectives-surrogateescapewrccsd}|dkr&tj}d}tjj|}nBytj|d}Wn.tk rf|sNtjd|t ddYnX|rttj }z |VWd|r|tj krt |XdS)aReturn a context manager that creates a temporary directory. Arguments: path: the directory to create temporarily. If omitted or None, defaults to creating a temporary directory using tempfile.mkdtemp. quiet: if False (the default), the context manager raises an exception on error. Otherwise, if the path is specified and cannot be created, only a warning is issued. FNTz+tests may fail, unable to create temp dir: )r) tempfilemkdtemprrrealpathmkdirrrgrrgetpidr)rquietZ dir_createdpidrdrdretemp_dirs&   r2ccsftj}ytj|Wn.tk rD|s,tjd|tddYnXztjVWdtj|XdS)agReturn a context manager that changes the current working directory. Arguments: path: the directory to use as the temporary current working directory. quiet: if False (the default), the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same. z)tests may fail, unable to change CWD to: r*)rN)rgetcwdchdirrrgrr)rr0Z saved_dirrdrdre change_cwd s  r5tempcwdccs:t||d$}t||d }|VWdQRXWdQRXdS)a Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkdtemp. If *quiet* is False (default) and it is not possible to create or change the CWD, an error is raised. If *quiet* is True, only a warning is raised and the original CWD is used. )rr0)r0N)r2r5)rvr0Z temp_pathZcwd_dirrdrdrer$sumaskc cs&tj|}z dVWdtj|XdS)z8Context manager that temporarily sets the process umask.N)rr7)r7ZoldmaskrdrdrerK8s  datacCsbtjj|r|S|dk r&tjj||}tgtj}x*|D]"}tjj||}tjj|r8|Sq8W|S)a[Try to find a file on sys.path or in the test directory. If it is not found the argument passed to the function is returned (this does not necessarily signal failure; could still be the legitimate path). Setting *subdir* indicates a relative path to use to find the file rather than looking directly in the path directories. N)rrisabsr TEST_HOME_DIRroexists)rZsubdirrZdnfnrdrdrerIs    cCs(tj|tjtjBtjB}tj|dS)z>Create an empty file. If the file already exists, truncate it.N)ropenO_WRONLYO_CREATO_TRUNCr)rfdrdrdrer[scCs,t|j}dd|D}dj|}d|S)z%Like repr(dict), but in sorted order.cSsg|] }d|qS)z%r: %rrd).0Zpairrdrdre cszsortdict..z, z{%s})sortedrr)dictrZ reprpairsZ withcommasrdrdrer[`s  c Cs*ttd}z|jS|jttXdS)z` Create an invalid file descriptor by opening and closing a file and return its fd. wbN)r=rfilenorr)rrdrdre make_bad_fdgs  rH)linenooffsetc Csp|jt}t|ddWdQRX|j}|j|j|dk rJ|j|j||j|j|dk rl|j|j|dS)Nz exec) assertRaises SyntaxErrorcompileZ exceptionZassertIsNotNonerI assertEqualrJ)testcaseZ statementrIrJcmrrdrdrer&ss   c sVddl}ddl}jdd|jj|djdd}tjjt |}fdd}tjj |r|||}|dk rt|St |t dt rtd |td |jj}tr|jjd|j|d d}tr|jjdd krtj|d}zBt|d.} |j} x| r| j| |j} qWWdQRXWd|jX||}|dk rF|Std|dS)Nrcheckr/rcs>t|f}dkr|S|r2|jd|S|jdS)Nr)r=seekr)r<r)rrRrrdrecheck_valid_files z*open_urlresource..check_valid_fileZurlfetchz fetching %s ...)rAccept-Encodinggzip)rzContent-Encoding)ZfileobjrFzinvalid resource %r)rVrW)Zurllib.requestZ urllib.parsepopparseZurlparserrrr TEST_DATA_DIRr;rr!rrrZrequestZ build_openerrWZ addheadersrr=ZheadersgetZGzipFilereadwriterr ) Zurlrrurllibrr<rUropeneroutsrd)rrRrrerI~s<         c@s4eZdZdZddZddZeddZdd Zd S) WarningsRecorderzyConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. cCs||_d|_dS)Nr) _warnings_last)selfZ warnings_listrdrdre__init__szWarningsRecorder.__init__cCsDt|j|jkr t|jd|S|tjjkr0dStd||fdS)Nrz%r has no attribute %rrY)rrerfrrgWarningMessage_WARNING_DETAILSr)rgattrrdrdre __getattr__s  zWarningsRecorder.__getattr__cCs|j|jdS)N)rerf)rgrdrdrergszWarningsRecorder.warningscCst|j|_dS)N)rrerf)rgrdrdreresetszWarningsRecorder.resetN) r`rarbrcrhrlpropertyrgrmrdrdrdrerds  rdc cs tjd}|jjd}|r"|jtjdd }tjdjdt |VWdQRXt |}g}xz|D]r\}}d} xH|ddD]8}|j } t j |t| t jrt| j|rd} |j|qW| rf| rf|j||jfqfW|rtd |d |rtd |d dS) zCatch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. rZ__warningregistry__T)recordrgalwaysNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)ro _getframe f_globalsr]clearrgrhrz simplefilterrdr|messagerematchruI issubclassrremoverr`AssertionError) filtersr0frameregistrywZreraiseZmissingrxcatseenZwarningrdrdre_filterwarningss0    rcOs.|jd}|s$dtff}|dkr$d}t||S)aContext manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filters are defined) Without argument, it defaults to: check_warnings(("", Warning), quiet=True) r0rNT)r]Warningr)r|rr0rdrdrerRs   rc csHtjdd&}tjd||ddV|r.tWdQRX|j|gdS)aContext manager to check that no warnings are emitted. This context manager enables a given warning within its scope and checks that no warnings are emitted even with that warning enabled. If force_gc is True, a garbage collection is attempted before checking for warnings. This may help to catch warnings emitted when objects are deleted, such as ResourceWarning. Other keyword arguments are passed to warnings.filterwarnings(). T)rorp)rucategoryN)rgrhri gc_collectrO)rPrurZforce_gcwarnsrdrdrecheck_no_warningssrc csBtjdd }tjdtddVtWdQRX|j|gdS)a"Context manager to check that no ResourceWarning is emitted. Usage: with check_no_resource_warning(self): f = open(...) ... del f You must remove the object which may emit ResourceWarning before the end of the context manager. T)rorp)rN)rgrhriResourceWarningrrO)rPrrdrdrerSs c@s(eZdZdZddZddZddZdS) ra,Context manager to force import to return a new module reference. This is useful for testing module-level behaviours, such as the emission of a DeprecationWarning on import. Use like this: with CleanImport("foo"): importlib.import_module("foo") # new reference cGsNtjj|_x<|D]4}|tjkrtj|}|j|kr>tj|j=tj|=qWdS)N)rorzcopyoriginal_modulesr`)rgZ module_namesZ module_namerrdrdrerh?s      zCleanImport.__init__cCs|S)Nrd)rgrdrdre __enter__LszCleanImport.__enter__cGstjj|jdS)N)rorzrr)rg ignore_excrdrdre__exit__OszCleanImport.__exit__N)r`rarbrcrhrrrdrdrdrer3s  c@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)rTz_Class to help protect the environment variable properly. Can be used as a context manager.cCstj|_i|_dS)N)renviron_environ_changed)rgrdrdrerhXszEnvironmentVarGuard.__init__cCs |j|S)N)r)rgenvvarrdrdre __getitem__\szEnvironmentVarGuard.__getitem__cCs*||jkr|jj||j|<||j|<dS)N)rrr])rgrvaluerdrdre __setitem___s zEnvironmentVarGuard.__setitem__cCs2||jkr|jj||j|<||jkr.|j|=dS)N)rrr])rgrrdrdre __delitem__es  zEnvironmentVarGuard.__delitem__cCs |jjS)N)rkeys)rgrdrdrerlszEnvironmentVarGuard.keyscCs t|jS)N)iterr)rgrdrdre__iter__oszEnvironmentVarGuard.__iter__cCs t|jS)N)rr)rgrdrdre__len__rszEnvironmentVarGuard.__len__cCs |||<dS)Nrd)rgrrrdrdresetuszEnvironmentVarGuard.setcCs ||=dS)Nrd)rgrrdrdreunsetxszEnvironmentVarGuard.unsetcCs|S)Nrd)rgrdrdrer{szEnvironmentVarGuard.__enter__cGsJx<|jjD].\}}|dkr0||jkr:|j|=q ||j|<q W|jt_dS)N)rrrrr)rgrkvrdrdrer~s   zEnvironmentVarGuard.__exit__N)r`rarbrcrhrrrrrrrrrrrdrdrdrerTSsc@s(eZdZdZddZddZddZdS) DirsOnSysPathaContext manager to temporarily add directories to sys.path. This makes a copy of sys.path, appends any directories given as positional arguments, then reverts sys.path to the copied settings when the context ends. Note that *all* sys.path modifications in the body of the context manager, including replacement of the object, will be reverted at the end of the block. cGs(tjdd|_tj|_tjj|dS)N)rororiginal_valueoriginal_objectextend)rgpathsrdrdrerhszDirsOnSysPath.__init__cCs|S)Nrd)rgrdrdrerszDirsOnSysPath.__enter__cGs|jt_|jtjdd<dS)N)rrorr)rgrrdrdrerszDirsOnSysPath.__exit__N)r`rarbrcrhrrrdrdrdrers rc@s*eZdZdZddZddZd ddZdS) r'zRaise ResourceDenied if an exception is raised while the context manager is in effect that matches the specified exception and attributes.cKs||_||_dS)N)rattrs)rgrrrdrdrerhszTransientResource.__init__cCs|S)Nrd)rgrdrdrerszTransientResource.__enter__NcCsT|dk rPt|j|rPx:|jjD]$\}}t||s4Pt|||kr Pq WtddS)zIf type_ is a subclass of self.exc and value has attributes matching self.attrs, raise ResourceDenied. Otherwise let the exception propagate (if any).Nz%an optional resource is not available)ryrrrrrr )rgZtype_r tracebackrkZ attr_valuerdrdrers zTransientResource.__exit__)NNN)r`rarbrcrhrrrdrdrdrer's)errnog>@)rerrnosc #spd!d"d#d$d%d&g}d(d*d,d.d/g}td||gsRdd|Ddd|Dfdd}tj}zy|dk rtj|dVWntjk r}z&trtjj j dd|WYdd}~Xnt k rZ}zpx^|j }t |d krt |dt r|d}n*t |dkr8t |d t r8|d }nPqW||WYdd}~XnXWdtj|XdS)0zReturn a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions. ECONNREFUSEDo ECONNRESETh EHOSTUNREACHq ENETUNREACHe ETIMEDOUTn EADDRNOTAVAILc EAI_AGAINr*EAI_FAILr EAI_NONAMEr EAI_NODATA WSANO_DATA*zResource %r is not availablecSsg|]\}}tt||qSrd)rr)rBrvnumrdrdrerCsz&transient_internet..cSsg|]\}}tt||qSrd)rr)rBrvrrdrdrerCscst|dd}t|tjst|tjr,|kst|tjjrTd|jkoNdknst|tjj rd|j ksd|j ksd|j ks|krt st j jjdd|dS) NriiWConnectionRefusedError TimeoutErrorEOFErrorr )r isinstancerrZgaierrorr`errorZ HTTPErrorcodeZURLErrorrrrostderrr_r)rn)captured_errnosdenied gai_errnosrdre filter_errors     z(transient_internet..filter_errorNrrr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)r rZgetdefaulttimeoutZsetdefaulttimeoutnntplibZNNTPTemporaryErrorrrorr_rrrr) Z resource_namerrZdefault_errnosZdefault_gai_errnosrZ old_timeoutrard)rrrrer+sP     c csFddl}tt|}tt||jztt|VWdtt||XdS)zReturn a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO.rN)iorrosetattrStringIO)Z stream_namerZ orig_stdoutrdrdrecaptured_outputs  rcCstdS)zCapture the output of sys.stdout: with captured_stdout() as stdout: print("hello") self.assertEqual(stdout.getvalue(), "hello\n") r)rrdrdrdrerscCstdS)zCapture the output of sys.stderr: with captured_stderr() as stderr: print("hello", file=sys.stderr) self.assertEqual(stderr.getvalue(), "hello\n") r)rrdrdrdrer%scCstdS)a Capture the input to sys.stdin: with captured_stdin() as stdin: stdin.write('hello\n') stdin.seek(0) # call test code that consumes from sys.stdin captured = input() self.assertEqual(captured, "hello") stdin)rrdrdrdrer.s cCs*tjtrtjdtjtjdS)aForce as many objects as possible to be collected. In non-CPython implementations of Python, this is needed because timely deallocation is not guaranteed by the garbage collector. (Even in CPython this can be the case in case of reference cycles.) This means that __del__ methods may be called later than expected and weakrefs may remain alive for longer than expected. This function tries its best to force all garbage objects to disappear. g?N)gcZcollectr@rrrdrdrdrer;s  rc cs.tj}tjz dVWd|r(tjXdS)N)r isenableddisableenable)Zhave_gcrdrdre disable_gcKs  rcCs:tjdp d}d}x|jD]}|jdr|}qW|dkS)z,Find if Python was built with optimizations. PY_CFLAGSrz-O-O0-Og)rrr) sysconfigget_config_varrrq)ZcflagsZ final_optrrdrdrepython_is_optimizedVs  rZnPZ0ngettotalrefcountZ2PZ0PrcCstjt|tS)N)structcalcsize_header_align)fmtrdrdre calcobjsizegsrcCstjt|tS)N)rr_vheaderr)rrdrdre calcvobjsizejsr cCspddl}tj|}t|tkr(|jt@sBt|tkrLt|jt@rL||j7}dt|||f}|j|||dS)Nrz&wrong size for %s: got %d, expected %d) _testcapiro getsizeofr __flags___TPFLAGS_HEAPTYPE_TPFLAGS_HAVE_GCZSIZEOF_PYGC_HEADrO)testosizerrrxrdrdre check_sizeofqs  rcsfdd}|S)Ncs$fdd}j|_j|_|S)Ncsy ddl}t|}|j|}Wn(tk r6YnBd}}Yn0Xx,D]$}y|j||PWqPYqPXqPWz ||S|r|r|j||XdS)Nr)localer setlocaler)rkwdsrrZ orig_localeloc)catstrrlocalesrdreinners$     z1run_with_locale..decorator..inner)r`rc)rr)rr)rrersz"run_with_locale..decoratorrd)rrrrd)rrrerUscsfdd}|S)Ncs"fdd}j|_j|_|S)Ncsy tj}Wntk r(tjdYnXdtjkr@tjd}nd}tjd<|z ||S|dkrrtjd=n |tjd<tjXdS)Nztzset requiredZTZ)rtzsetrrsrtrr)rrrZorig_tz)rtzrdrers       z-run_with_tz..decorator..inner)r`rc)rr)r)rrerszrun_with_tz..decoratorrd)rrrd)rrer\s cCsdttdtd}tjd|tjtjB}|dkr>td|ftt|j d||j dj }|a |t krrt }|t dkrtd|f|adS)Ni)rmgtz(\d+(\.\d+)?) (K|M|G|T)b?$zInvalid memory limit %rrr*z$Memory limit %r too low to be useful)_1M_1Grvrw IGNORECASEVERBOSErrfloatgrouplowerreal_max_memuseMAX_Py_ssize_t_2Gr)limitZsizesrZmemlimitrdrdrerYs $ c@s(eZdZdZddZddZddZdS) _MemoryWatchdogz`An object which periodically watches the process' memory consumption and prints it out. cCsdjtjd|_d|_dS)Nz/proc/{pid}/statm)r1F)rrr/procfilestarted)rgrdrdrerhsz_MemoryWatchdog.__init__cCsyt|jd}Wn<tk rL}z tjdj|ttjj dSd}~XnXt d}t j tj |g|t jd|_|jd|_dS)Nrz!/proc not available for stats: {}zmemory_watchdog.py)rrT)r=r rrgrrrrorflushr subprocessPopen executableZDEVNULL mem_watchdogrr )rgrrZwatchdog_scriptrdrdrestarts   z_MemoryWatchdog.startcCs|jr|jj|jjdS)N)r rZ terminatewait)rgrdrdrestops z_MemoryWatchdog.stopN)r`rarbrcrhrrrdrdrdrer sr csfdd}|S)atDecorator for bigmem tests. 'size' is a requested size for the test (in arbitrary, test-interpreted units.) 'memuse' is the number of bytes per unit for the test, or a good estimate of it. For example, a test that needs two byte buffers, of 4 GiB each, could be decorated with @bigmemtest(size=_4G, memuse=2). The 'size' argument is normally passed to the decorated test method as an extra argument. If 'dry_run' is true, the value passed to the test method may be less than the requested value. If 'dry_run' is false, it means the test doesn't support dummy runs when -M is not specified. cs fdd__S)Nc sj}j}tsd}n|}ts$ rFt||krFtjd||dtr|tr|ttdj||ddt}|j nd}z ||S|r|j XdS) Niz'not enough memory: %.1fG minimum neededir*z* ... expected peak memory use: {peak:.1f}G)Zpeaki@i@) rmemuserrsrtrrrr rr)rgrrmaxsizeZwatchdog)dry_runrrrdrers*    z.bigmemtest..decorator..wrapper)rr)r)rrr)rrrerszbigmemtest..decoratorrd)rrrrrd)rrrrer3s !csfdd}|S)z0Decorator for tests that fill the address space.csDttkr8td kr$td kr$tjdq@tjdtd n|SdS) Nr?rz-not enough memory: try a 32-bit build insteadz'not enough memory: %.1fG minimum neededir*llli@)rrrsrt)rg)rrdrer3sz!bigaddrspacetest..wrapperrd)rrrd)rrer41s c@seZdZddZdS)r,cCstj}|||S)N)rsZ TestResult)rgrrrdrdrerunDszBasicTestRunner.runN)r`rarbrrdrdrdrer,CscCs|S)Nrd)rrdrdre_idIsrcCs<|dkrt rtjtjSt|r(tStjdj|SdS)Nrzresource {0!r} is not enabled)rrsskiprr rr)rrdrdrerequires_resourceLs  rcCs&trt|krtjd|tfStSdS)Nz%s at Android API level %d)rA_ANDROID_API_LEVELrsrr)levelrrdrdrer>Ts  cCstdd|S)z9 Decorator for tests only applicable on CPython. T)cpython) impl_detail)rrdrdrer5[scKsVtf|rtS|dkrLt|\}}|r,d}nd}t|j}|jdj|}tj|S)Nz*implementation detail not available on {0}z%implementation detail specific to {0}z or ) rBr _parse_guardsrDrrrrsr)rxguardsZ guardnamesdefaultrdrdrer!as   r!c CsTtdkr:ddl}y|jdaWntk r8daYnXd}trF|Stj||S)z8Skip decorator for tests that use multiprocessing.Queue.NrTFz6requires a functioning shared semaphore implementation)_have_mp_queuemultiprocessingZQueuernrsr)rr&rxrdrdrer?os cCs*|sddidfSt|jd}|| fS)Nr TFr)r|values)r#Zis_truerdrdrer"~s r"cKs t|\}}|jtjj|S)a5This function returns True or False depending on the host platform. Examples: if check_impl_detail(): # only on CPython (default) if check_impl_detail(jython=True): # only on Jython if check_impl_detail(cpython=False): # everywhere except on CPython )r"r]rpZpython_implementationr)r#r$rdrdrerBs cs,ttdsStjfdd}|SdS)zEDecorator to temporarily turn off tracing for the duration of a test.gettracec s.tj}ztjd||Stj|XdS)N)ror(settrace)rrZoriginal_trace)rrdrers   zno_tracing..wrapperN)rrorr)rrrd)rre no_tracings r*cCs tt|S)aDecorator for tests which involve reference counting. To start, the decorator does not run the test if is not run by CPython. After that, any trace function is unset during the test to prevent unexpected refcounts caused by the trace function. )r*r5)rrdrdre refcount_testsr+cCsRg}xB|jD]8}t|tjr2t|||j|q ||r |j|q W||_dS)z>Recursively filter test cases in a suite based on a predicate.N)Z_testsrrs TestSuite _filter_suiter)suiteZpredZnewtestsrrdrdrer-s    r-cCsttjttdk d}|j|}tdk r4tj|j|js>t |j st |j dkrl|j rl|j dd}n6t |j dkr|j r|j dd}nd}ts|d7}t|dS)z2Run tests from a unittest.TestSuite-derived class.N) verbosityZcapture_outputrrzmultiple errors occurredz!; run in verbose mode for details)rrorrjunit_xml_listrrZget_xml_elementZtestsRunr Z wasSuccessfulrerrorsZfailuresr )r.Zrunnerrrrdrdre _run_suites"  r2cCstdkr dSt|jSdS)NT)_match_test_funcid)rrdrdre match_testsr5cCsd|kotjd| S)Nryz[?*\[\]])rvsearch)rrdrdre_is_full_match_testsr7csr|tkr dS|sd}f}nHttt|r4t|j}n.djttj|}t j |j fdd}|}t |a|a dS)N|cs$|r dStt|jdSdS)NTry)anyrr)Ztest_id) regex_matchrdrematch_test_regexsz)set_match_tests..match_test_regex)_match_test_patternsallrr7r __contains__rfnmatch translatervrNrwrrr3)ZpatternsrZregexr;rd)r:reset_match_testss   rAcGstjtjf}tj}xh|D]`}t|trT|tjkrJ|jtjtj|qzt dqt||rj|j|q|jtj |qWt |t t |dS)z1Run tests from unittest.TestCase-derived classes.z)str arguments must be keys in sys.modulesN)rsr,ZTestCaserrurorzZaddTestZ findTestCasesrZ makeSuiter-r5r2)classesZ valid_typesr.clsrdrdrer-s        cCsdS)z,Just used to check if docstrings are enabledNrdrdrdrdre_check_docstrings(srDWITH_DOC_STRINGSztest requires docstringscCs`ddl}|dkrt}nd}|j|||d\}}|rBtd||ftrXtd|j|f||fS)aRun doctest on the given module. Return (#failures, #tests). If optional argument verbosity is not specified (or is None), pass support's belief about verbosity on to doctest. Else doctest's usual behavior is used (it searches sys.argv for -v). rN)r optionflagsz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)doctestrZtestmodr rr`)rr/rFrGrrrdrdrer.9scCs tjjfS)N)rorzrrdrdrdre modules_setupTsrHcCs:ddtjjD}tjjtjj|tjj|dS)NcSs"g|]\}}|jdr||fqS)z encodings.)rq)rBrrrdrdrerC[sz#modules_cleanup..)rorzrrsr)Z oldmodulesZ encodingsrdrdremodules_cleanupWs  rIcCs"trtjtjjfSdffSdS)Nr)_thread_count threading _danglingrrdrdrdrerNzscGsJtsdSd}x8t|D],}tjtjf}||kr2PtjdtqWdS)Ndg{Gz?)rJrangerKrLrMrrr)Zoriginal_valuesZ _MAX_COUNTcountr'rdrdrerOs cs"tsStjfdd}|S)zUse this function when threads are being used. This will ensure that the threads are cleaned up even when the test fails. If threading is unavailable this function does nothing. c st}z|St|XdS)N)rNrO)rkey)rrdrerszreap_threads..decorator)rJrr)rrrd)rrerPsN@ccstj}z dVWdtj}||}xjtj}||kr8Ptj|kr|tj|}d||d|dd|d|d }t|tjdtq&WXdS) aH bpo-31234: Context manager to wait until all threads created in the with statement exit. Use _thread.count() to check if threads exited. Indirectly, wait until threads exit the internal t_bootstrap() C function of the _thread module. threading_setup() and threading_cleanup() are designed to emit a warning if a test leaves running threads in the background. This context manager is designed to cleanup threads started by the _thread.start_new_thread() which doesn't allow to wait for thread exit, whereas thread.Thread has a join() method. Nz!wait_threads() failed to cleanup z threads after z.1fz seconds (count: z , old count: )g{Gz?)rJrKrZ monotonicr{rr)rZ old_countZ start_timeZdeadlinerPZdtrxrdrdrewait_threads_exits   $ rTc CsZttdrVd}xFy2tj|tj\}}|dkr.Ptd|tjdWqPYqXqWdS)zUse this function at the end of test_main() whenever sub-processes are started. This will help ensure that no extra children (zombies) stick around to hog resources and create problems when looking for refleaks. waitpidrrz2Warning -- reap_children() reaped child process %s)rNrY)rrrUWNOHANGrror)Z any_processr1ZstatusrdrdrerLs ccs*t|}g}zZy$x|D]}|j|j|qWWn*trVtdt|t|fYnXdVWdz|rt|tj}}xltddD]^}|d7}x$|D]}|jt |tjdqWdd|D}|sPtrtdt||fqWWdd d|D}|r"t j t j td t|XXdS) Nz/Can't start %d threads, only %d threads startedrr<g{Gz?cSsg|]}|jr|qSrd)isAlive)rBrrdrdrerCsz!start_threads..z7Unable to join %d threads during a period of %d minutescSsg|]}|jr|qSrd)rX)rBrrdrdrerCszUnable to join %d threads)r|rrrrrrrOrmax faulthandlerZdump_tracebackrorr{)ZthreadsZunlockr rZendtimeZ starttimerrdrdrerQs>     c csnt||rtt|tt|}|r(|t|8}tdd|D}|S)a Returns the set of items in ref_api not in other_api, except for a defined list of items to be ignored in this check. By default this skips private attributes beginning with '_' but includes all magic methods, i.e. those starting and ending in '__'. css(|] }|jd s|jdr|VqdS)___N)rqendswith)rBrrdrdre sz&detect_api_mismatch..)rrx)Zref_apiZ other_apirfZ missing_itemsrdrdrer< s  cCs|dkr|jf}nt|tr"|f}t|}xbt|D]V}|jds4||krLq4t||}t|dd|kst|d r4t|tj  r4|j |q4W|j |j |dS)aAssert that the __all__ variable of 'module' contains all public names. The module's public names (its API) are detected automatically based on whether they match the public name convention and were defined in 'module'. The 'name_of_module' argument can specify (as a string or tuple thereof) what module(s) an API could be defined in in order to be detected as a public API. One case for this is when 'module' imports part of its public API from other modules, possibly a C backend (like 'csv' and its '_csv'). The 'extra' argument can be a set of names that wouldn't otherwise be automatically detected as "public", like objects without a proper '__module__' attribute. If provided, it will be added to the automatically detected ones. The 'blacklist' argument can be a set of names that must not be treated as part of the public API even though their names indicate otherwise. Usage: import bar import foo import unittest from test import support class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, foo) class OtherTestCase(unittest.TestCase): def test__all__(self): extra = {'BAR_CONST', 'FOO_CONST'} blacklist = {'baz'} # Undocumented name. # bar imports part of its API from _bar. support.check__all__(self, bar, ('bar', '_bar'), extra=extra, blacklist=blacklist) Nrra) r`rrurrxrqrrtypes ModuleTypeaddZassertCountEqual__all__)Z test_caserZname_of_moduleZextraZ blacklistZexpectedrvrrdrdrer= s)    c@s(eZdZdZdZdZddZddZdS)rZzTry to prevent a crash report from popping up. On Windows, don't display the Windows Error Reporting dialog. On UNIX, disable the creation of coredump file. Nc Csrtjjdrddl}|jj|_d}|jj||_|jj|j|Byddl }|j Wnt t fk rlYnLXi|_ x|j|j|jgD].}|j ||j}|j||j}||f|j |<qWntdk r y*tjtj|_tjtjd|jdfWnttfk rYnXtjdkrnddd d g}tj|tjtjd }||jd} WdQRX| jd krntd ddd|S)zOn Windows, disable Windows Error Reporting dialogs using SetErrorMode. On UNIX, try to save the previous core file size limit, then set soft limit to 0. rrNrrrz/usr/bin/defaultsr^zcom.apple.CrashReporterZ DialogType)rrs developerz:this test triggers the Crash Reporter, that is intentionalrT)endr ) rorprqrrr_k32 SetErrorMode old_valuemsvcrtCrtSetReportModerrn old_modesCRT_WARN CRT_ERROR CRT_ASSERTZCRTDBG_MODE_FILECrtSetReportFileZCRTDBG_FILE_STDERRrZ getrlimit RLIMIT_CORE setrlimitrrrrPIPEZ communicaterar) rgrZSEM_NOGPFAULTERRORBOXr report_typeold_modeold_filecmdprocrrdrdrer2 sN        zSuppressCrashReport.__enter__c Gs|jdkrdStjjdrl|jj|j|jrddl}xj|jjD]$\}\}}|j |||j ||qBWn6t dk ryt j t j |jWnttfk rYnXdS)zARestore Windows ErrorMode or core file behavior to initial value.Nrr)rrorprqrrrrrrrrrrrr)rgrrrrrrdrdrers s   zSuppressCrashReport.__exit__)r`rarbrcrrrrrdrdrdrerZ) s Ac srtdyjWn$ttfk r@tdYnXdfdd}|j|t|dS)zOverride 'object_to_patch'.'attr_name' with 'new_value'. Also, add a cleanup procedure to 'test_instance' to restore 'object_to_patch' value for 'attr_name'. The 'attr_name' should be a valid attribute for 'object_to_patch'. FNTcs rtn tdS)N)rr[rd) attr_is_local attr_nameobject_to_patchrrdrecleanup szpatch..cleanup)rrjrrZ addCleanupr)Z test_instancerrZ new_valuerrd)rrrrrepatch s  rc CsFy ddl}Wntk r YnX|jr4tjdddl}|j|S)zi Run code in a subinterpreter. Raise unittest.SkipTest if the tracemalloc module is enabled. rNzUrun_in_subinterp() cannot be used if tracemalloc module is tracing memory allocations) tracemallocrnZ is_tracingrsrtrrun_in_subinterp)rrrrdrdrer s  rcsHGfddd|}d||||jttt|jdS)NcseZdZfddZdS)z%check_free_after_iterating..Ac s*dy tWntk r$YnXdS)NT)next StopIteration)rg)doneitrdre__del__ s  z-check_free_after_iterating..A.__del__N)r`rarbrrd)rrrdreA srF)rLrrrZ assertTrue)rrrCrrrd)rrrecheck_free_after_iterating s   rcCs|ddlm}m}m}|j}|j|xP|jD]F}|r@||kr@q.t||}|rPn |dkrZq.|j|ddkr.|dSq.WdS)a<Check if the compiler components used to build the interpreter exist. Check for the existence of the compiler executables whose names are listed in 'cmd_names' or all the compiler executables when 'cmd_names' is empty and return the first missing executable or None when none is found missing. r) ccompilerrspawnN) Z distutilsrrrZ new_compilerZcustomize_compilerZ executablesrZfind_executable)Z cmd_namesrrrZcompilerrvrrdrdrer^ s     cCs@d}tr6||kr6tdkr.tjddgjdkatr6|}tj|S)Ngh㈵>Zgetpropzro.kernel.qemu1)rA_is_android_emulatorrZ check_outputrarorD)ZintervalZminimum_intervalrdrdrerD s c cs>tjj}tj}ztjdVWd|r8tj|ddXdS)NT)rZ all_threads)rorrGrZ is_enabledrr)rArrdrdredisable_faulthandler s  rc /Cstjjd r8ytjd}t|dStk r6YnXd}ttdrjytjd}Wnt k rhYnXd}tjd kryd dl }|j Wnt t fk rYn0Xi}x(|j|j|jfD]}|j |d ||<qWzpd }xft|D]Z}ytj|}Wn4t k r(}z|jtjkrWYdd}~XqXtj||d7}qWWd|dk rzx*|j|j|jfD]}|j |||q`WX|S) z/Count the number of open file descriptors. linuxfreebsdz /proc/self/fdrsysconf SC_OPEN_MAXNrr)rr)rorprqrrrrrrrrrrrnrrrrOduprZEBADFr) namesZMAXFDrrrrPrAZfd2rrdrdrer_ sP          c@s(eZdZdZddZddZddZdS) SaveSignalsz Save an restore signal handlers. This class is only able to save/restore signal handlers registered by the Python signal module: see bpo-13285 for "external" signal handlers. c Csjddl}||_ttd|j|_x>dD]6}yt||}Wntk rNw&YnX|jj|q&Wi|_dS)NrrSIGKILLSIGSTOP)rr) signalr|rONSIGsignalsrrrzrf)rgrZsignamesignumrdrdrerhM s zSaveSignals.__init__cCs4x.|jD]$}|jj|}|dkr"q||j|<qWdS)N)rr getsignalrf)rgrhandlerrdrdresaveZ s   zSaveSignals.savecCs*x$|jjD]\}}|jj||q WdS)N)rfrr)rgrrrdrdrerestoref szSaveSignals.restoreN)r`rarbrcrhrrrdrdrdrerD s  rc@s(eZdZdZddZddZddZdS) FakePathz.Simple implementing of the path protocol. cCs ||_dS)N)r)rgrrdrdrerhn szFakePath.__init__cCsd|jdS)Nz )r)rgrdrdre__repr__q szFakePath.__repr__cCs6t|jts$t|jtr,t|jtr,|jn|jSdS)N)rr BaseExceptionrry)rgrdrdre __fspath__t s    zFakePath.__fspath__N)r`rarbrcrhrrrdrdrdrerk src cs.tj}ztj|dVWdtj|XdS)z>Temporarily change the integer string conversion length limit.N)roget_int_max_str_digitsset_int_max_str_digits)Z max_digitsZcurrentrdrdreadjust_int_max_str_digits| s   rcCsddtddDdgS)zReturns a list of C0 control characters as strings. C0 control characters defined as the byte range 0x00-0x1F, and 0x7F. cSsg|] }t|qSrd)chr)rBrrdrdrerC sz)control_characters_c0..r )rOrdrdrdrecontrol_characters_c0 sr)T)F)F)N)Nii@i@i@ii) rrrrrrrrr r!r")r&r$r'r(r))NF)F)r6F)N)Fi@ii)T)N)Nr)rR)N(rcr`rncollections.abc collections contextlibZdatetimerrZr?rrrrmimportlib.utilrZlogging.handlersrerrrprvrrrrrrorr+rrrsZ urllib.errorr`rgZ testresultrrJrLZmultiprocessing.processr&zlibrWbz2Zlzmarrrrr r r rtr contextmanagerrkr rrr:r;rr6rrrrr0rrrrrrrqrrrrrrrrrrrr r!rr"r#r$r%rErr r rGrHrJrrFrrZ SOCK_MAX_SIZEZ skipUnlessr __getformat__r7r9r0r1r2r@rrrArCrvrrr/Z FS_NONASCII characterfsdecodefsencode UnicodeErrorZTESTFN_UNICODEZ unicodedata normalizegetfilesystemencodingZTESTFN_ENCODINGZTESTFN_UNENCODABLEZgetwindowsversionencodeUnicodeEncodeErrorrdecodeUnicodeDecodeErrorZTESTFN_UNDECODABLEZTESTFN_NONASCIIr3rr]r}r2r5rrrKrrrrZTEST_SUPPORT_DIRr:rr\rrr[rHr&rIobjectrdrrRrrrSrabcMutableMappingrTrr'rrr(rr)r*r+rrrrrrrrrrrrrrrrUr\rrrZ_4GrrrYr r3r4r,rrr>r5r!r%r?r"rBr*r+r-r2r3r<r5r7rAr-rDZMISSING_C_DOCSTRINGSZHAVE_DOCSTRINGSZrequires_docstringsr.rHrIZenvironment_alteredrNrOrPrTrLrQrWrVrbZskipIfZrequires_type_collectingrcrdrfrgrMrXrrrr/rzr|r8r~rr<r=rZrrrr^rrDrr_rrrrrdrdrdres                      2   !  J    > %                 %      2 ' 5M            $ # 0           (        " #   "    :_"  ;' PK`]r&XX-support/__pycache__/testresult.cpython-36.pycnu[3 \ @s6dZddlZddlZddlZddlZddlZddlZddljj Z ddl m Z Gdddej Z GdddZdd d Zdd d Zed kr2GdddejZejZejejeejZeeddejDZeejZejeZ e!dej"e!dddx(e j#e j$D]Z%e!e%j&ddqWe!dS)z=Test runner and result class for the regression test suite. N)datetimecseZdZdddZdddZfddZeddZfd d Zd$d d Z ddZ eddZ fddZ fddZ fddZfddZfddZfddZddZd d!Zd"d#ZZS)%RegressionTestResult=F -cs\tj||ddd|_tjd|_|jjdtjj dd|_ d|_ g|_ t ||_dS)Nr)stream descriptions verbosityTZ testsuitestart )super__init__bufferETZElement_RegressionTestResult__suitesetrZutcnowZ isoformat_RegressionTestResult__e!_RegressionTestResult__start_timeZ_RegressionTestResult__resultsbool_RegressionTestResult__verbose)selfrr r ) __class__//usr/lib64/python3.6/test/support/testresult.pyrs zRegressionTestResult.__init__cCsLy |j}Wntk r"t|SXy|Stk rBt|SXt|S)N)idAttributeErrorstr TypeErrorrepr)clstestZtest_idrrrZ__getIds   zRegressionTestResult.__getIdcsVtj|tj|jd|_}tj|_|j rR|j j |j |d|j j dS)NZtestcasez ... )r startTestr SubElementrrtime perf_counterrrrwritegetDescriptionflush)rr!e)rrrr"+s   zRegressionTestResult.startTestFc KsP|j}d|_|dkrdS|jd|jd|j||jd|jdd|jd|jdd|jrz|jdtj|jd|r|jdk r|jjj }|t j |d_ |j dk r|j jj }|t j |d _ x|jD]t\}}| s| rqt j ||} t|d r>xD|jD],\} } | r,| j| t| n t| | _ q Wqt|| _ qWdS) NnameZstatusrunresultZ completedr$z0.6fz system-outz system-erritems)rrpop_RegressionTestResult__getIdrr$r%Z_stdout_buffergetvaluerstriprr#textZ_stderr_bufferr-hasattrr) rr!Zcaptureargsr)stdoutstderrkvZe2Zk2Zv2rrr _add_result3s4     z RegressionTestResult._add_resultcCs|jr|jj|ddS)Nr)rrr&)rcZwordrrrZ__writeSszRegressionTestResult.__writecCslt|tr0|jdkr|j}q8|jd|j}nt|}tj||d}tj|||}|dj|dj|dS)Nbuiltins.)typemessager=) isinstancer> __module____name__r tracebackformat_exceptionjoin)r Zerr_typeZ err_valueZerr_tbtypenamemsgtbrrrZ__makeErrorDictWs  z$RegressionTestResult.__makeErrorDictcs4|j|d|j|dtj|||jdddS)NT)errorEERROR)r9$_RegressionTestResult__makeErrorDictr addError_RegressionTestResult__write)rr!err)rrrrMjszRegressionTestResult.addErrorcs4|j|d|j|dtj|||jdddS)NT)outputxzexpected failure)r9rLr addExpectedFailurerN)rr!rO)rrrrRosz'RegressionTestResult.addExpectedFailurecs4|j|d|j|dtj|||jdddS)NT)ZfailureFFAIL)r9rLr addFailurerN)rr!rO)rrrrUtszRegressionTestResult.addFailurecs2|j||dtj|||jdd|dS)N)ZskippedSzskipped )r9r addSkiprN)rr!reason)rrrrWyszRegressionTestResult.addSkipcs&|j|tj||jdddS)Nr<ok)r9r addSuccessrN)rr!)rrrrZ~s  zRegressionTestResult.addSuccesscs*|j|ddtj||jdddS)NZUNEXPECTED_SUCCESS)Zoutcomeuzunexpected success)r9r addUnexpectedSuccessrN)rr!)rrrr\s z)RegressionTestResult.addUnexpectedSuccesscCs2|jr|jjd|jd|j|jd|jdS)NrrKrT)rrr&printErrorListerrorsfailures)rrrr printErrorss z RegressionTestResult.printErrorscCs`xZ|D]R\}}|jj|j|jj|d|j|d|jj|j|jjd|qWdS)Nz: rz%s )rr& separator1r' separator2)rZflavorr^r!rOrrrr]s z#RegressionTestResult.printErrorListcCsH|j}|jdt|j|jdtt|j|jdtt|j|S)NZtestsr^r_)rrrZtestsRunlenr^r_)rr)rrrget_xml_elements z$RegressionTestResult.get_xml_element)F)rBrA __qualname__rarbr classmethodr/r"r9rNrLrMrRrUrWrZr\r`r]rd __classcell__rr)rrrs"           rc@seZdZdddZddZdS)QuietRegressionTestRunnerFcCst|dd|_||j_dS)Nr)rr,r)rrrrrrrsz"QuietRegressionTestRunner.__init__cCs||j|jS)N)r,)rr!rrrr+s zQuietRegressionTestRunner.runN)F)rBrArerr+rrrrrhs rhFcCs&|rtjtjt||dStjt|dS)N)Z resultclassrr )r) functoolspartialunittestZTextTestRunnerrrh)r rrrrget_test_runner_classs rlcCst|||S)N)rl)rr Zcapture_outputrrrget_test_runnersrm__main__c@s,eZdZddZddZddZddZd S) TestTestscCsdS)Nr)rrrr test_passszTestTests.test_passcCstjddS)Ng?)r$Zsleep)rrrrtest_pass_slowszTestTests.test_pass_slowcCs*tdtjdtdtjd|jddS)Nr5)filer6zfailure message)printsysr5r6Zfail)rrrr test_failszTestTests.test_failcCs(tdtjdtdtjdtddS)Nr5)rrr6z error message)rsrtr5r6 RuntimeError)rrrr test_errorszTestTests.test_errorN)rBrArerprqrurwrrrrrosroccs|]}|dkVqdS)z-vNr).0arrr srzzOutput:zXML: r=)end)F)F)'__doc__riiortr$rCrkZxml.etree.ElementTreeZetreeZ ElementTreerrZTextTestResultrrhrlrmrBZTestCaseroZ TestSuiteZsuiteZaddTestZ makeSuiteStringIOrsumargvZ runner_clsr5Zrunnerr+r,rsr0Z tostringlistrdsdecoderrrrs4         PK`] ~support/script_helper.pynu[# Common utility functions used by various script execution tests # e.g. test_cmd_line, test_cmd_line_script and test_runpy import sys import os import re import os.path import tempfile import subprocess import py_compile import contextlib import shutil try: import zipfile except ImportError: # If Python is build without Unicode support, importing _io will # fail, which, in turn, means that zipfile cannot be imported # Most of this module can then still be used. pass from test.support import strip_python_stderr # Executing the interpreter in a subprocess def _assert_python(expected_success, *args, **env_vars): cmd_line = [sys.executable] if not env_vars: cmd_line.append('-E') cmd_line.extend(args) # Need to preserve the original environment, for in-place testing of # shared library builds. env = os.environ.copy() env.update(env_vars) p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) try: out, err = p.communicate() finally: subprocess._cleanup() p.stdout.close() p.stderr.close() rc = p.returncode err = strip_python_stderr(err) if (rc and expected_success) or (not rc and not expected_success): raise AssertionError( "Process return code is %d, " "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore'))) return rc, out, err def assert_python_ok(*args, **env_vars): """ Assert that running the interpreter with `args` and optional environment variables `env_vars` is ok and return a (return code, stdout, stderr) tuple. """ return _assert_python(True, *args, **env_vars) def assert_python_failure(*args, **env_vars): """ Assert that running the interpreter with `args` and optional environment variables `env_vars` fails and return a (return code, stdout, stderr) tuple. """ return _assert_python(False, *args, **env_vars) def python_exit_code(*args): cmd_line = [sys.executable, '-E'] cmd_line.extend(args) with open(os.devnull, 'w') as devnull: return subprocess.call(cmd_line, stdout=devnull, stderr=subprocess.STDOUT) def spawn_python(*args, **kwargs): cmd_line = [sys.executable, '-E'] cmd_line.extend(args) return subprocess.Popen(cmd_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs) def kill_python(p): p.stdin.close() data = p.stdout.read() p.stdout.close() # try to cleanup the child so we don't appear to leak when running # with regrtest -R. p.wait() subprocess._cleanup() return data def run_python(*args, **kwargs): if __debug__: p = spawn_python(*args, **kwargs) else: p = spawn_python('-O', *args, **kwargs) stdout_data = kill_python(p) return p.wait(), stdout_data # Script creation utilities @contextlib.contextmanager def temp_dir(): dirname = tempfile.mkdtemp() dirname = os.path.realpath(dirname) try: yield dirname finally: shutil.rmtree(dirname) def make_script(script_dir, script_basename, source): script_filename = script_basename+os.extsep+'py' script_name = os.path.join(script_dir, script_filename) script_file = open(script_name, 'w') script_file.write(source) script_file.close() return script_name def compile_script(script_name): py_compile.compile(script_name, doraise=True) if __debug__: compiled_name = script_name + 'c' else: compiled_name = script_name + 'o' return compiled_name def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None): zip_filename = zip_basename+os.extsep+'zip' zip_name = os.path.join(zip_dir, zip_filename) zip_file = zipfile.ZipFile(zip_name, 'w') if name_in_zip is None: name_in_zip = os.path.basename(script_name) zip_file.write(script_name, name_in_zip) zip_file.close() #if test.test_support.verbose: # zip_file = zipfile.ZipFile(zip_name, 'r') # print 'Contents of %r:' % zip_name # zip_file.printdir() # zip_file.close() return zip_name, os.path.join(zip_name, name_in_zip) def make_pkg(pkg_dir, init_source=''): os.mkdir(pkg_dir) make_script(pkg_dir, '__init__', init_source) def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename, source, depth=1, compiled=False): unlink = [] init_name = make_script(zip_dir, '__init__', '') unlink.append(init_name) init_basename = os.path.basename(init_name) script_name = make_script(zip_dir, script_basename, source) unlink.append(script_name) if compiled: init_name = compile_script(init_name) script_name = compile_script(script_name) unlink.extend((init_name, script_name)) pkg_names = [os.sep.join([pkg_name]*i) for i in range(1, depth+1)] script_name_in_zip = os.path.join(pkg_names[-1], os.path.basename(script_name)) zip_filename = zip_basename+os.extsep+'zip' zip_name = os.path.join(zip_dir, zip_filename) zip_file = zipfile.ZipFile(zip_name, 'w') for name in pkg_names: init_name_in_zip = os.path.join(name, init_basename) zip_file.write(init_name, init_name_in_zip) zip_file.write(script_name, script_name_in_zip) zip_file.close() for name in unlink: os.unlink(name) #if test.test_support.verbose: # zip_file = zipfile.ZipFile(zip_name, 'r') # print 'Contents of %r:' % zip_name # zip_file.printdir() # zip_file.close() return zip_name, os.path.join(zip_name, script_name_in_zip) PK`]C敏..support/__init__.pynu["""Supporting definitions for the Python regression tests.""" if __name__ != 'test.support': raise ImportError('test.support must be imported from the test package') import contextlib import errno import fnmatch import functools import gc import socket import stat import sys import os import platform import shutil import warnings import unittest import importlib import UserDict import re import time import struct import sysconfig import types try: import thread except ImportError: thread = None __all__ = ["Error", "TestFailed", "TestDidNotRun", "ResourceDenied", "import_module", "verbose", "use_resources", "max_memuse", "record_original_stdout", "get_original_stdout", "unload", "unlink", "rmtree", "forget", "is_resource_enabled", "requires", "requires_mac_ver", "find_unused_port", "bind_port", "fcmp", "have_unicode", "is_jython", "TESTFN", "HOST", "FUZZ", "SAVEDCWD", "temp_cwd", "findfile", "sortdict", "check_syntax_error", "open_urlresource", "check_warnings", "check_py3k_warnings", "CleanImport", "EnvironmentVarGuard", "captured_output", "captured_stdout", "TransientResource", "transient_internet", "run_with_locale", "set_memlimit", "bigmemtest", "bigaddrspacetest", "BasicTestRunner", "run_unittest", "run_doctest", "threading_setup", "threading_cleanup", "reap_threads", "start_threads", "cpython_only", "check_impl_detail", "get_attribute", "py3k_bytes", "import_fresh_module", "threading_cleanup", "reap_children", "strip_python_stderr", "IPV6_ENABLED", "run_with_tz", "SuppressCrashReport"] SHORT_TIMEOUT = 30.0 # Added to make backporting from 3.x easier class Error(Exception): """Base class for regression test exceptions.""" class TestFailed(Error): """Test failed.""" class TestDidNotRun(Error): """Test did not run any subtests.""" class ResourceDenied(unittest.SkipTest): """Test skipped because it requested a disallowed resource. This is raised when a test calls requires() for a resource that has not been enabled. It is used to distinguish between expected and unexpected skips. """ @contextlib.contextmanager def _ignore_deprecated_imports(ignore=True): """Context manager to suppress package and module deprecation warnings when importing them. If ignore is False, this context manager has no effect.""" if ignore: with warnings.catch_warnings(): warnings.filterwarnings("ignore", ".+ (module|package)", DeprecationWarning) yield else: yield def import_module(name, deprecated=False): """Import and return the module to be tested, raising SkipTest if it is not available. If deprecated is True, any module or package deprecation messages will be suppressed.""" with _ignore_deprecated_imports(deprecated): try: return importlib.import_module(name) except ImportError, msg: raise unittest.SkipTest(str(msg)) def _save_and_remove_module(name, orig_modules): """Helper function to save and remove a module from sys.modules Raise ImportError if the module can't be imported.""" # try to import the module and raise an error if it can't be imported if name not in sys.modules: __import__(name) del sys.modules[name] for modname in list(sys.modules): if modname == name or modname.startswith(name + '.'): orig_modules[modname] = sys.modules[modname] del sys.modules[modname] def _save_and_block_module(name, orig_modules): """Helper function to save and block a module in sys.modules Return True if the module was in sys.modules, False otherwise.""" saved = True try: orig_modules[name] = sys.modules[name] except KeyError: saved = False sys.modules[name] = None return saved def import_fresh_module(name, fresh=(), blocked=(), deprecated=False): """Imports and returns a module, deliberately bypassing the sys.modules cache and importing a fresh copy of the module. Once the import is complete, the sys.modules cache is restored to its original state. Modules named in fresh are also imported anew if needed by the import. If one of these modules can't be imported, None is returned. Importing of modules named in blocked is prevented while the fresh import takes place. If deprecated is True, any module or package deprecation messages will be suppressed.""" # NOTE: test_heapq, test_json, and test_warnings include extra sanity # checks to make sure that this utility function is working as expected with _ignore_deprecated_imports(deprecated): # Keep track of modules saved for later restoration as well # as those which just need a blocking entry removed orig_modules = {} names_to_remove = [] _save_and_remove_module(name, orig_modules) try: for fresh_name in fresh: _save_and_remove_module(fresh_name, orig_modules) for blocked_name in blocked: if not _save_and_block_module(blocked_name, orig_modules): names_to_remove.append(blocked_name) fresh_module = importlib.import_module(name) except ImportError: fresh_module = None finally: for orig_name, module in orig_modules.items(): sys.modules[orig_name] = module for name_to_remove in names_to_remove: del sys.modules[name_to_remove] return fresh_module def get_attribute(obj, name): """Get an attribute, raising SkipTest if AttributeError is raised.""" try: attribute = getattr(obj, name) except AttributeError: if isinstance(obj, types.ModuleType): msg = "module %r has no attribute %r" % (obj.__name__, name) elif isinstance(obj, types.ClassType): msg = "class %s has no attribute %r" % (obj.__name__, name) elif isinstance(obj, types.InstanceType): msg = "%s instance has no attribute %r" % (obj.__class__.__name__, name) elif isinstance(obj, type): msg = "type object %r has no attribute %r" % (obj.__name__, name) else: msg = "%r object has no attribute %r" % (type(obj).__name__, name) raise unittest.SkipTest(msg) else: return attribute verbose = 1 # Flag set to 0 by regrtest.py use_resources = None # Flag set to [] by regrtest.py max_memuse = 0 # Disable bigmem tests (they will still be run with # small sizes, to make sure they work.) real_max_memuse = 0 failfast = False # _original_stdout is meant to hold stdout at the time regrtest began. # This may be "the real" stdout, or IDLE's emulation of stdout, or whatever. # The point is to have some flavor of stdout the user can actually see. _original_stdout = None def record_original_stdout(stdout): global _original_stdout _original_stdout = stdout def get_original_stdout(): return _original_stdout or sys.stdout def unload(name): try: del sys.modules[name] except KeyError: pass def _force_run(path, func, *args): try: return func(*args) except EnvironmentError as err: if verbose >= 2: print('%s: %s' % (err.__class__.__name__, err)) print('re-run %s%r' % (func.__name__, args)) os.chmod(path, stat.S_IRWXU) return func(*args) if sys.platform.startswith("win"): def _waitfor(func, pathname, waitall=False): # Perform the operation func(pathname) # Now setup the wait loop if waitall: dirname = pathname else: dirname, name = os.path.split(pathname) dirname = dirname or '.' # Check for `pathname` to be removed from the filesystem. # The exponential backoff of the timeout amounts to a total # of ~1 second after which the deletion is probably an error # anyway. # Testing on an i7@4.3GHz shows that usually only 1 iteration is # required when contention occurs. timeout = 0.001 while timeout < 1.0: # Note we are only testing for the existence of the file(s) in # the contents of the directory regardless of any security or # access rights. If we have made it this far, we have sufficient # permissions to do that much using Python's equivalent of the # Windows API FindFirstFile. # Other Windows APIs can fail or give incorrect results when # dealing with files that are pending deletion. L = os.listdir(dirname) if not (L if waitall else name in L): return # Increase the timeout and try again time.sleep(timeout) timeout *= 2 warnings.warn('tests may fail, delete still pending for ' + pathname, RuntimeWarning, stacklevel=4) def _unlink(filename): _waitfor(os.unlink, filename) def _rmdir(dirname): _waitfor(os.rmdir, dirname) def _rmtree(path): def _rmtree_inner(path): for name in _force_run(path, os.listdir, path): fullname = os.path.join(path, name) if os.path.isdir(fullname): _waitfor(_rmtree_inner, fullname, waitall=True) _force_run(fullname, os.rmdir, fullname) else: _force_run(fullname, os.unlink, fullname) _waitfor(_rmtree_inner, path, waitall=True) _waitfor(lambda p: _force_run(p, os.rmdir, p), path) else: _unlink = os.unlink _rmdir = os.rmdir def _rmtree(path): try: shutil.rmtree(path) return except EnvironmentError: pass def _rmtree_inner(path): for name in _force_run(path, os.listdir, path): fullname = os.path.join(path, name) try: mode = os.lstat(fullname).st_mode except EnvironmentError: mode = 0 if stat.S_ISDIR(mode): _rmtree_inner(fullname) _force_run(path, os.rmdir, fullname) else: _force_run(path, os.unlink, fullname) _rmtree_inner(path) os.rmdir(path) def unlink(filename): try: _unlink(filename) except OSError as exc: if exc.errno not in (errno.ENOENT, errno.ENOTDIR): raise def rmdir(dirname): try: _rmdir(dirname) except OSError as error: # The directory need not exist. if error.errno != errno.ENOENT: raise def rmtree(path): try: _rmtree(path) except OSError, e: # Unix returns ENOENT, Windows returns ESRCH. if e.errno not in (errno.ENOENT, errno.ESRCH): raise def forget(modname): '''"Forget" a module was ever imported by removing it from sys.modules and deleting any .pyc and .pyo files.''' unload(modname) for dirname in sys.path: unlink(os.path.join(dirname, modname + os.extsep + 'pyc')) # Deleting the .pyo file cannot be within the 'try' for the .pyc since # the chance exists that there is no .pyc (and thus the 'try' statement # is exited) but there is a .pyo file. unlink(os.path.join(dirname, modname + os.extsep + 'pyo')) # Check whether a gui is actually available def _is_gui_available(): if hasattr(_is_gui_available, 'result'): return _is_gui_available.result reason = None if sys.platform.startswith('win'): # if Python is running as a service (such as the buildbot service), # gui interaction may be disallowed import ctypes import ctypes.wintypes UOI_FLAGS = 1 WSF_VISIBLE = 0x0001 class USEROBJECTFLAGS(ctypes.Structure): _fields_ = [("fInherit", ctypes.wintypes.BOOL), ("fReserved", ctypes.wintypes.BOOL), ("dwFlags", ctypes.wintypes.DWORD)] dll = ctypes.windll.user32 h = dll.GetProcessWindowStation() if not h: raise ctypes.WinError() uof = USEROBJECTFLAGS() needed = ctypes.wintypes.DWORD() res = dll.GetUserObjectInformationW(h, UOI_FLAGS, ctypes.byref(uof), ctypes.sizeof(uof), ctypes.byref(needed)) if not res: raise ctypes.WinError() if not bool(uof.dwFlags & WSF_VISIBLE): reason = "gui not available (WSF_VISIBLE flag not set)" elif sys.platform == 'darwin': # The Aqua Tk implementations on OS X can abort the process if # being called in an environment where a window server connection # cannot be made, for instance when invoked by a buildbot or ssh # process not running under the same user id as the current console # user. To avoid that, raise an exception if the window manager # connection is not available. from ctypes import cdll, c_int, pointer, Structure from ctypes.util import find_library app_services = cdll.LoadLibrary(find_library("ApplicationServices")) if app_services.CGMainDisplayID() == 0: reason = "gui tests cannot run without OS X window manager" else: class ProcessSerialNumber(Structure): _fields_ = [("highLongOfPSN", c_int), ("lowLongOfPSN", c_int)] psn = ProcessSerialNumber() psn_p = pointer(psn) if ( (app_services.GetCurrentProcess(psn_p) < 0) or (app_services.SetFrontProcess(psn_p) < 0) ): reason = "cannot run without OS X gui process" # check on every platform whether tkinter can actually do anything if not reason: try: from Tkinter import Tk root = Tk() root.withdraw() root.update() root.destroy() except Exception as e: err_string = str(e) if len(err_string) > 50: err_string = err_string[:50] + ' [...]' reason = 'Tk unavailable due to {}: {}'.format(type(e).__name__, err_string) _is_gui_available.reason = reason _is_gui_available.result = not reason return _is_gui_available.result def is_resource_enabled(resource): """Test whether a resource is enabled. Known resources are set by regrtest.py. If not running under regrtest.py, all resources are assumed enabled unless use_resources has been set. """ return use_resources is None or resource in use_resources def requires(resource, msg=None): """Raise ResourceDenied if the specified resource is not available.""" if not is_resource_enabled(resource): if msg is None: msg = "Use of the `%s' resource not enabled" % resource raise ResourceDenied(msg) if resource == 'gui' and not _is_gui_available(): raise ResourceDenied(_is_gui_available.reason) def requires_mac_ver(*min_version): """Decorator raising SkipTest if the OS is Mac OS X and the OS X version if less than min_version. For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version is lesser than 10.5. """ def decorator(func): @functools.wraps(func) def wrapper(*args, **kw): if sys.platform == 'darwin': version_txt = platform.mac_ver()[0] try: version = tuple(map(int, version_txt.split('.'))) except ValueError: pass else: if version < min_version: min_version_txt = '.'.join(map(str, min_version)) raise unittest.SkipTest( "Mac OS X %s or higher required, not %s" % (min_version_txt, version_txt)) return func(*args, **kw) wrapper.min_version = min_version return wrapper return decorator # Don't use "localhost", since resolving it uses the DNS under recent # Windows versions (see issue #18792). HOST = "127.0.0.1" HOSTv6 = "::1" def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM): """Returns an unused port that should be suitable for binding. This is achieved by creating a temporary socket with the same family and type as the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to the specified host address (defaults to 0.0.0.0) with the port set to 0, eliciting an unused ephemeral port from the OS. The temporary socket is then closed and deleted, and the ephemeral port is returned. Either this method or bind_port() should be used for any tests where a server socket needs to be bound to a particular port for the duration of the test. Which one to use depends on whether the calling code is creating a python socket, or if an unused port needs to be provided in a constructor or passed to an external program (i.e. the -accept argument to openssl's s_server mode). Always prefer bind_port() over find_unused_port() where possible. Hard coded ports should *NEVER* be used. As soon as a server socket is bound to a hard coded port, the ability to run multiple instances of the test simultaneously on the same host is compromised, which makes the test a ticking time bomb in a buildbot environment. On Unix buildbots, this may simply manifest as a failed test, which can be recovered from without intervention in most cases, but on Windows, the entire python process can completely and utterly wedge, requiring someone to log in to the buildbot and manually kill the affected process. (This is easy to reproduce on Windows, unfortunately, and can be traced to the SO_REUSEADDR socket option having different semantics on Windows versus Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind, listen and then accept connections on identical host/ports. An EADDRINUSE socket.error will be raised at some point (depending on the platform and the order bind and listen were called on each socket). However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE will ever be raised when attempting to bind two identical host/ports. When accept() is called on each socket, the second caller's process will steal the port from the first caller, leaving them both in an awkwardly wedged state where they'll no longer respond to any signals or graceful kills, and must be forcibly killed via OpenProcess()/TerminateProcess(). The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option instead of SO_REUSEADDR, which effectively affords the same semantics as SO_REUSEADDR on Unix. Given the propensity of Unix developers in the Open Source world compared to Windows ones, this is a common mistake. A quick look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when openssl.exe is called with the 's_server' option, for example. See http://bugs.python.org/issue2550 for more info. The following site also has a very thorough description about the implications of both REUSEADDR and EXCLUSIVEADDRUSE on Windows: http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx) XXX: although this approach is a vast improvement on previous attempts to elicit unused ports, it rests heavily on the assumption that the ephemeral port returned to us by the OS won't immediately be dished back out to some other process when we close and delete our temporary socket but before our calling code has a chance to bind the returned port. We can deal with this issue if/when we come across it.""" tempsock = socket.socket(family, socktype) port = bind_port(tempsock) tempsock.close() del tempsock return port def bind_port(sock, host=HOST): """Bind the socket to a free port and return the port number. Relies on ephemeral ports in order to ensure we are using an unbound port. This is important as many tests may be running simultaneously, especially in a buildbot environment. This method raises an exception if the sock.family is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR or SO_REUSEPORT set on it. Tests should *never* set these socket options for TCP/IP sockets. The only case for setting these options is testing multicasting via multiple UDP sockets. Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e. on Windows), it will be set on the socket. This will prevent anyone else from bind()'ing to our host/port for the duration of the test. """ if sock.family == socket.AF_INET and sock.type == socket.SOCK_STREAM: if hasattr(socket, 'SO_REUSEADDR'): if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) == 1: raise TestFailed("tests should never set the SO_REUSEADDR " \ "socket option on TCP/IP sockets!") if hasattr(socket, 'SO_REUSEPORT'): try: if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1: raise TestFailed("tests should never set the SO_REUSEPORT " \ "socket option on TCP/IP sockets!") except EnvironmentError: # Python's socket module was compiled using modern headers # thus defining SO_REUSEPORT but this process is running # under an older kernel that does not support SO_REUSEPORT. pass if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'): sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1) sock.bind((host, 0)) port = sock.getsockname()[1] return port def _is_ipv6_enabled(): """Check whether IPv6 is enabled on this host.""" if socket.has_ipv6: sock = None try: sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) sock.bind((HOSTv6, 0)) return True except socket.error: pass finally: if sock: sock.close() return False IPV6_ENABLED = _is_ipv6_enabled() def system_must_validate_cert(f): """Skip the test on TLS certificate validation failures.""" @functools.wraps(f) def dec(*args, **kwargs): try: f(*args, **kwargs) except IOError as e: if "CERTIFICATE_VERIFY_FAILED" in str(e): raise unittest.SkipTest("system does not contain " "necessary certificates") raise return dec FUZZ = 1e-6 def fcmp(x, y): # fuzzy comparison function if isinstance(x, float) or isinstance(y, float): try: fuzz = (abs(x) + abs(y)) * FUZZ if abs(x-y) <= fuzz: return 0 except: pass elif type(x) == type(y) and isinstance(x, (tuple, list)): for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) if outcome != 0: return outcome return (len(x) > len(y)) - (len(x) < len(y)) return (x > y) - (x < y) # A constant likely larger than the underlying OS pipe buffer size, to # make writes blocking. # Windows limit seems to be around 512 B, and many Unix kernels have a # 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure. # (see issue #17835 for a discussion of this number). PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1 # A constant likely larger than the underlying OS socket buffer size, to make # writes blocking. # The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl # on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643 # for a discussion of this number). SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1 is_jython = sys.platform.startswith('java') try: unicode have_unicode = True except NameError: have_unicode = False requires_unicode = unittest.skipUnless(have_unicode, 'no unicode support') def u(s): return unicode(s, 'unicode-escape') # FS_NONASCII: non-ASCII Unicode character encodable by # sys.getfilesystemencoding(), or None if there is no such character. FS_NONASCII = None if have_unicode: for character in ( # First try printable and common characters to have a readable filename. # For each character, the encoding list are just example of encodings able # to encode the character (the list is not exhaustive). # U+00E6 (Latin Small Letter Ae): cp1252, iso-8859-1 unichr(0x00E6), # U+0130 (Latin Capital Letter I With Dot Above): cp1254, iso8859_3 unichr(0x0130), # U+0141 (Latin Capital Letter L With Stroke): cp1250, cp1257 unichr(0x0141), # U+03C6 (Greek Small Letter Phi): cp1253 unichr(0x03C6), # U+041A (Cyrillic Capital Letter Ka): cp1251 unichr(0x041A), # U+05D0 (Hebrew Letter Alef): Encodable to cp424 unichr(0x05D0), # U+060C (Arabic Comma): cp864, cp1006, iso8859_6, mac_arabic unichr(0x060C), # U+062A (Arabic Letter Teh): cp720 unichr(0x062A), # U+0E01 (Thai Character Ko Kai): cp874 unichr(0x0E01), # Then try more "special" characters. "special" because they may be # interpreted or displayed differently depending on the exact locale # encoding and the font. # U+00A0 (No-Break Space) unichr(0x00A0), # U+20AC (Euro Sign) unichr(0x20AC), ): try: # In Windows, 'mbcs' is used, and encode() returns '?' # for characters missing in the ANSI codepage if character.encode(sys.getfilesystemencoding())\ .decode(sys.getfilesystemencoding())\ != character: raise UnicodeError except UnicodeError: pass else: FS_NONASCII = character break # Filename used for testing if os.name == 'java': # Jython disallows @ in module names TESTFN = '$test' elif os.name == 'riscos': TESTFN = 'testfile' else: TESTFN = '@test' # Unicode name only used if TEST_FN_ENCODING exists for the platform. if have_unicode: # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding() # TESTFN_UNICODE is a filename that can be encoded using the # file system encoding, but *not* with the default (ascii) encoding if isinstance('', unicode): # python -U # XXX perhaps unicode() should accept Unicode strings? TESTFN_UNICODE = "@test-\xe0\xf2" else: # 2 latin characters. TESTFN_UNICODE = unicode("@test-\xe0\xf2", "latin-1") TESTFN_ENCODING = sys.getfilesystemencoding() # TESTFN_UNENCODABLE is a filename that should *not* be # able to be encoded by *either* the default or filesystem encoding. # This test really only makes sense on Windows NT platforms # which have special Unicode support in posixmodule. if (not hasattr(sys, "getwindowsversion") or sys.getwindowsversion()[3] < 2): # 0=win32s or 1=9x/ME TESTFN_UNENCODABLE = None else: # Japanese characters (I think - from bug 846133) TESTFN_UNENCODABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"') try: # XXX - Note - should be using TESTFN_ENCODING here - but for # Windows, "mbcs" currently always operates as if in # errors=ignore' mode - hence we get '?' characters rather than # the exception. 'Latin1' operates as we expect - ie, fails. # See [ 850997 ] mbcs encoding ignores errors TESTFN_UNENCODABLE.encode("Latin1") except UnicodeEncodeError: pass else: print \ 'WARNING: The filename %r CAN be encoded by the filesystem. ' \ 'Unicode filename tests may not be effective' \ % TESTFN_UNENCODABLE # Disambiguate TESTFN for parallel testing, while letting it remain a valid # module name. TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid()) # Define the URL of a dedicated HTTP server for the network tests. # The URL must use clear-text HTTP: no redirection to encrypted HTTPS. TEST_HTTP_URL = "http://www.pythontest.net" # Save the initial cwd SAVEDCWD = os.getcwd() @contextlib.contextmanager def temp_dir(path=None, quiet=False): """Return a context manager that creates a temporary directory. Arguments: path: the directory to create temporarily. If omitted or None, defaults to creating a temporary directory using tempfile.mkdtemp. quiet: if False (the default), the context manager raises an exception on error. Otherwise, if the path is specified and cannot be created, only a warning is issued. """ dir_created = False if path is None: import tempfile path = tempfile.mkdtemp() dir_created = True path = os.path.realpath(path) else: if (have_unicode and isinstance(path, unicode) and not os.path.supports_unicode_filenames): try: path = path.encode(sys.getfilesystemencoding() or 'ascii') except UnicodeEncodeError: if not quiet: raise unittest.SkipTest('unable to encode the cwd name with ' 'the filesystem encoding.') try: os.mkdir(path) dir_created = True except OSError: if not quiet: raise warnings.warn('tests may fail, unable to create temp dir: ' + path, RuntimeWarning, stacklevel=3) if dir_created: pid = os.getpid() try: yield path finally: # In case the process forks, let only the parent remove the # directory. The child has a diffent process id. (bpo-30028) if dir_created and pid == os.getpid(): rmtree(path) @contextlib.contextmanager def change_cwd(path, quiet=False): """Return a context manager that changes the current working directory. Arguments: path: the directory to use as the temporary current working directory. quiet: if False (the default), the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same. """ saved_dir = os.getcwd() try: os.chdir(path) except OSError: if not quiet: raise warnings.warn('tests may fail, unable to change CWD to: ' + path, RuntimeWarning, stacklevel=3) try: yield os.getcwd() finally: os.chdir(saved_dir) @contextlib.contextmanager def temp_cwd(name='tempcwd', quiet=False): """ Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkdtemp. If *quiet* is False (default) and it is not possible to create or change the CWD, an error is raised. If *quiet* is True, only a warning is raised and the original CWD is used. """ with temp_dir(path=name, quiet=quiet) as temp_path: with change_cwd(temp_path, quiet=quiet) as cwd_dir: yield cwd_dir # TEST_HOME_DIR refers to the top level directory of the "test" package # that contains Python's regression test suite TEST_SUPPORT_DIR = os.path.dirname(os.path.abspath(__file__)) TEST_HOME_DIR = os.path.dirname(TEST_SUPPORT_DIR) # TEST_DATA_DIR is used as a target download location for remote resources TEST_DATA_DIR = os.path.join(TEST_HOME_DIR, "data") def findfile(file, subdir=None): """Try to find a file on sys.path and the working directory. If it is not found the argument passed to the function is returned (this does not necessarily signal failure; could still be the legitimate path).""" if os.path.isabs(file): return file if subdir is not None: file = os.path.join(subdir, file) path = [TEST_HOME_DIR] + sys.path for dn in path: fn = os.path.join(dn, file) if os.path.exists(fn): return fn return file def sortdict(dict): "Like repr(dict), but in sorted order." items = dict.items() items.sort() reprpairs = ["%r: %r" % pair for pair in items] withcommas = ", ".join(reprpairs) return "{%s}" % withcommas def make_bad_fd(): """ Create an invalid file descriptor by opening and closing a file and return its fd. """ file = open(TESTFN, "wb") try: return file.fileno() finally: file.close() unlink(TESTFN) def check_syntax_error(testcase, statement, errtext='', lineno=None, offset=None): with testcase.assertRaisesRegexp(SyntaxError, errtext) as cm: compile(statement, '', 'exec') err = cm.exception if lineno is not None: testcase.assertEqual(err.lineno, lineno) if offset is not None: testcase.assertEqual(err.offset, offset) def open_urlresource(url, check=None): import urlparse, urllib2 filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL! fn = os.path.join(TEST_DATA_DIR, filename) def check_valid_file(fn): f = open(fn) if check is None: return f elif check(f): f.seek(0) return f f.close() if os.path.exists(fn): f = check_valid_file(fn) if f is not None: return f unlink(fn) # Verify the requirement before downloading the file requires('urlfetch') print >> get_original_stdout(), '\tfetching %s ...' % url f = urllib2.urlopen(url, timeout=15) try: with open(fn, "wb") as out: s = f.read() while s: out.write(s) s = f.read() finally: f.close() f = check_valid_file(fn) if f is not None: return f raise TestFailed('invalid resource "%s"' % fn) class WarningsRecorder(object): """Convenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. """ def __init__(self, warnings_list): self._warnings = warnings_list self._last = 0 def __getattr__(self, attr): if len(self._warnings) > self._last: return getattr(self._warnings[-1], attr) elif attr in warnings.WarningMessage._WARNING_DETAILS: return None raise AttributeError("%r has no attribute %r" % (self, attr)) @property def warnings(self): return self._warnings[self._last:] def reset(self): self._last = len(self._warnings) def _filterwarnings(filters, quiet=False): """Catch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. """ # Clear the warning registry of the calling module # in order to re-raise the warnings. frame = sys._getframe(2) registry = frame.f_globals.get('__warningregistry__') if registry: registry.clear() with warnings.catch_warnings(record=True) as w: # Set filter "always" to record all warnings. Because # test_warnings swap the module, we need to look up in # the sys.modules dictionary. sys.modules['warnings'].simplefilter("always") yield WarningsRecorder(w) # Filter the recorded warnings reraise = [warning.message for warning in w] missing = [] for msg, cat in filters: seen = False for exc in reraise[:]: message = str(exc) # Filter out the matching messages if (re.match(msg, message, re.I) and issubclass(exc.__class__, cat)): seen = True reraise.remove(exc) if not seen and not quiet: # This filter caught nothing missing.append((msg, cat.__name__)) if reraise: raise AssertionError("unhandled warning %r" % reraise[0]) if missing: raise AssertionError("filter (%r, %s) did not catch any warning" % missing[0]) @contextlib.contextmanager def check_warnings(*filters, **kwargs): """Context manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filters are defined) Without argument, it defaults to: check_warnings(("", Warning), quiet=True) """ quiet = kwargs.get('quiet') if not filters: filters = (("", Warning),) # Preserve backward compatibility if quiet is None: quiet = True return _filterwarnings(filters, quiet) @contextlib.contextmanager def check_py3k_warnings(*filters, **kwargs): """Context manager to silence py3k warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default False) Without argument, it defaults to: check_py3k_warnings(("", DeprecationWarning), quiet=False) """ if sys.py3kwarning: if not filters: filters = (("", DeprecationWarning),) else: # It should not raise any py3k warning filters = () return _filterwarnings(filters, kwargs.get('quiet')) class CleanImport(object): """Context manager to force import to return a new module reference. This is useful for testing module-level behaviours, such as the emission of a DeprecationWarning on import. Use like this: with CleanImport("foo"): importlib.import_module("foo") # new reference """ def __init__(self, *module_names): self.original_modules = sys.modules.copy() for module_name in module_names: if module_name in sys.modules: module = sys.modules[module_name] # It is possible that module_name is just an alias for # another module (e.g. stub for modules renamed in 3.x). # In that case, we also need delete the real module to clear # the import cache. if module.__name__ != module_name: del sys.modules[module.__name__] del sys.modules[module_name] def __enter__(self): return self def __exit__(self, *ignore_exc): sys.modules.update(self.original_modules) class EnvironmentVarGuard(UserDict.DictMixin): """Class to help protect the environment variable properly. Can be used as a context manager.""" def __init__(self): self._environ = os.environ self._changed = {} def __getitem__(self, envvar): return self._environ[envvar] def __setitem__(self, envvar, value): # Remember the initial value on the first access if envvar not in self._changed: self._changed[envvar] = self._environ.get(envvar) self._environ[envvar] = value def __delitem__(self, envvar): # Remember the initial value on the first access if envvar not in self._changed: self._changed[envvar] = self._environ.get(envvar) if envvar in self._environ: del self._environ[envvar] def keys(self): return self._environ.keys() def set(self, envvar, value): self[envvar] = value def unset(self, envvar): del self[envvar] def __enter__(self): return self def __exit__(self, *ignore_exc): for (k, v) in self._changed.items(): if v is None: if k in self._environ: del self._environ[k] else: self._environ[k] = v os.environ = self._environ class DirsOnSysPath(object): """Context manager to temporarily add directories to sys.path. This makes a copy of sys.path, appends any directories given as positional arguments, then reverts sys.path to the copied settings when the context ends. Note that *all* sys.path modifications in the body of the context manager, including replacement of the object, will be reverted at the end of the block. """ def __init__(self, *paths): self.original_value = sys.path[:] self.original_object = sys.path sys.path.extend(paths) def __enter__(self): return self def __exit__(self, *ignore_exc): sys.path = self.original_object sys.path[:] = self.original_value class TransientResource(object): """Raise ResourceDenied if an exception is raised while the context manager is in effect that matches the specified exception and attributes.""" def __init__(self, exc, **kwargs): self.exc = exc self.attrs = kwargs def __enter__(self): return self def __exit__(self, type_=None, value=None, traceback=None): """If type_ is a subclass of self.exc and value has attributes matching self.attrs, raise ResourceDenied. Otherwise let the exception propagate (if any).""" if type_ is not None and issubclass(self.exc, type_): for attr, attr_value in self.attrs.iteritems(): if not hasattr(value, attr): break if getattr(value, attr) != attr_value: break else: raise ResourceDenied("an optional resource is not available") @contextlib.contextmanager def transient_internet(resource_name, timeout=30.0, errnos=()): """Return a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions.""" default_errnos = [ ('ECONNREFUSED', 111), ('ECONNRESET', 104), ('EHOSTUNREACH', 113), ('ENETUNREACH', 101), ('ETIMEDOUT', 110), # socket.create_connection() fails randomly with # EADDRNOTAVAIL on Travis CI. ('EADDRNOTAVAIL', 99), ] default_gai_errnos = [ ('EAI_AGAIN', -3), ('EAI_FAIL', -4), ('EAI_NONAME', -2), ('EAI_NODATA', -5), # Windows defines EAI_NODATA as 11001 but idiotic getaddrinfo() # implementation actually returns WSANO_DATA i.e. 11004. ('WSANO_DATA', 11004), ] denied = ResourceDenied("Resource '%s' is not available" % resource_name) captured_errnos = errnos gai_errnos = [] if not captured_errnos: captured_errnos = [getattr(errno, name, num) for (name, num) in default_errnos] gai_errnos = [getattr(socket, name, num) for (name, num) in default_gai_errnos] def filter_error(err): n = getattr(err, 'errno', None) if (isinstance(err, socket.timeout) or (isinstance(err, socket.gaierror) and n in gai_errnos) or n in captured_errnos): if not verbose: sys.stderr.write(denied.args[0] + "\n") raise denied old_timeout = socket.getdefaulttimeout() try: if timeout is not None: socket.setdefaulttimeout(timeout) yield except IOError as err: # urllib can wrap original socket errors multiple times (!), we must # unwrap to get at the original error. while True: a = err.args if len(a) >= 1 and isinstance(a[0], IOError): err = a[0] # The error can also be wrapped as args[1]: # except socket.error as msg: # raise IOError('socket error', msg).with_traceback(sys.exc_info()[2]) elif len(a) >= 2 and isinstance(a[1], IOError): err = a[1] else: break filter_error(err) raise # XXX should we catch generic exceptions and look for their # __cause__ or __context__? finally: socket.setdefaulttimeout(old_timeout) @contextlib.contextmanager def captured_output(stream_name): """Return a context manager used by captured_stdout and captured_stdin that temporarily replaces the sys stream *stream_name* with a StringIO.""" import StringIO orig_stdout = getattr(sys, stream_name) setattr(sys, stream_name, StringIO.StringIO()) try: yield getattr(sys, stream_name) finally: setattr(sys, stream_name, orig_stdout) def captured_stdout(): """Capture the output of sys.stdout: with captured_stdout() as s: print "hello" self.assertEqual(s.getvalue(), "hello") """ return captured_output("stdout") def captured_stderr(): return captured_output("stderr") def captured_stdin(): return captured_output("stdin") def gc_collect(): """Force as many objects as possible to be collected. In non-CPython implementations of Python, this is needed because timely deallocation is not guaranteed by the garbage collector. (Even in CPython this can be the case in case of reference cycles.) This means that __del__ methods may be called later than expected and weakrefs may remain alive for longer than expected. This function tries its best to force all garbage objects to disappear. """ gc.collect() if is_jython: time.sleep(0.1) gc.collect() gc.collect() _header = '2P' if hasattr(sys, "gettotalrefcount"): _header = '2P' + _header _vheader = _header + 'P' def calcobjsize(fmt): return struct.calcsize(_header + fmt + '0P') def calcvobjsize(fmt): return struct.calcsize(_vheader + fmt + '0P') _TPFLAGS_HAVE_GC = 1<<14 _TPFLAGS_HEAPTYPE = 1<<9 def check_sizeof(test, o, size): import _testcapi result = sys.getsizeof(o) # add GC header size if ((type(o) == type) and (o.__flags__ & _TPFLAGS_HEAPTYPE) or\ ((type(o) != type) and (type(o).__flags__ & _TPFLAGS_HAVE_GC))): size += _testcapi.SIZEOF_PYGC_HEAD msg = 'wrong size for %s: got %d, expected %d' \ % (type(o), result, size) test.assertEqual(result, size, msg) #======================================================================= # Decorator for running a function in a different locale, correctly resetting # it afterwards. def run_with_locale(catstr, *locales): def decorator(func): def inner(*args, **kwds): try: import locale category = getattr(locale, catstr) orig_locale = locale.setlocale(category) except AttributeError: # if the test author gives us an invalid category string raise except: # cannot retrieve original locale, so do nothing locale = orig_locale = None else: for loc in locales: try: locale.setlocale(category, loc) break except: pass # now run the function, resetting the locale on exceptions try: return func(*args, **kwds) finally: if locale and orig_locale: locale.setlocale(category, orig_locale) inner.func_name = func.func_name inner.__doc__ = func.__doc__ return inner return decorator #======================================================================= # Decorator for running a function in a specific timezone, correctly # resetting it afterwards. def run_with_tz(tz): def decorator(func): def inner(*args, **kwds): try: tzset = time.tzset except AttributeError: raise unittest.SkipTest("tzset required") if 'TZ' in os.environ: orig_tz = os.environ['TZ'] else: orig_tz = None os.environ['TZ'] = tz tzset() # now run the function, resetting the tz on exceptions try: return func(*args, **kwds) finally: if orig_tz is None: del os.environ['TZ'] else: os.environ['TZ'] = orig_tz time.tzset() inner.__name__ = func.__name__ inner.__doc__ = func.__doc__ return inner return decorator #======================================================================= # Big-memory-test support. Separate from 'resources' because memory use should be configurable. # Some handy shorthands. Note that these are used for byte-limits as well # as size-limits, in the various bigmem tests _1M = 1024*1024 _1G = 1024 * _1M _2G = 2 * _1G _4G = 4 * _1G MAX_Py_ssize_t = sys.maxsize def set_memlimit(limit): global max_memuse global real_max_memuse sizes = { 'k': 1024, 'm': _1M, 'g': _1G, 't': 1024*_1G, } m = re.match(r'(\d+(\.\d+)?) (K|M|G|T)b?$', limit, re.IGNORECASE | re.VERBOSE) if m is None: raise ValueError('Invalid memory limit %r' % (limit,)) memlimit = int(float(m.group(1)) * sizes[m.group(3).lower()]) real_max_memuse = memlimit if memlimit > MAX_Py_ssize_t: memlimit = MAX_Py_ssize_t if memlimit < _2G - 1: raise ValueError('Memory limit %r too low to be useful' % (limit,)) max_memuse = memlimit def bigmemtest(minsize, memuse, overhead=5*_1M): """Decorator for bigmem tests. 'minsize' is the minimum useful size for the test (in arbitrary, test-interpreted units.) 'memuse' is the number of 'bytes per size' for the test, or a good estimate of it. 'overhead' specifies fixed overhead, independent of the testsize, and defaults to 5Mb. The decorator tries to guess a good value for 'size' and passes it to the decorated test function. If minsize * memuse is more than the allowed memory use (as defined by max_memuse), the test is skipped. Otherwise, minsize is adjusted upward to use up to max_memuse. """ def decorator(f): def wrapper(self): if not max_memuse: # If max_memuse is 0 (the default), # we still want to run the tests with size set to a few kb, # to make sure they work. We still want to avoid using # too much memory, though, but we do that noisily. maxsize = 5147 self.assertFalse(maxsize * memuse + overhead > 20 * _1M) else: maxsize = int((max_memuse - overhead) / memuse) if maxsize < minsize: # Really ought to print 'test skipped' or something if verbose: sys.stderr.write("Skipping %s because of memory " "constraint\n" % (f.__name__,)) return # Try to keep some breathing room in memory use maxsize = max(maxsize - 50 * _1M, minsize) return f(self, maxsize) wrapper.minsize = minsize wrapper.memuse = memuse wrapper.overhead = overhead return wrapper return decorator def precisionbigmemtest(size, memuse, overhead=5*_1M, dry_run=True): def decorator(f): def wrapper(self): if not real_max_memuse: maxsize = 5147 else: maxsize = size if ((real_max_memuse or not dry_run) and real_max_memuse < maxsize * memuse): if verbose: sys.stderr.write("Skipping %s because of memory " "constraint\n" % (f.__name__,)) return return f(self, maxsize) wrapper.size = size wrapper.memuse = memuse wrapper.overhead = overhead return wrapper return decorator def bigaddrspacetest(f): """Decorator for tests that fill the address space.""" def wrapper(self): if max_memuse < MAX_Py_ssize_t: if verbose: sys.stderr.write("Skipping %s because of memory " "constraint\n" % (f.__name__,)) else: return f(self) return wrapper #======================================================================= # unittest integration. class BasicTestRunner: def run(self, test): result = unittest.TestResult() test(result) return result def _id(obj): return obj def requires_resource(resource): if resource == 'gui' and not _is_gui_available(): return unittest.skip(_is_gui_available.reason) if is_resource_enabled(resource): return _id else: return unittest.skip("resource {0!r} is not enabled".format(resource)) def cpython_only(test): """ Decorator for tests only applicable on CPython. """ return impl_detail(cpython=True)(test) def impl_detail(msg=None, **guards): if check_impl_detail(**guards): return _id if msg is None: guardnames, default = _parse_guards(guards) if default: msg = "implementation detail not available on {0}" else: msg = "implementation detail specific to {0}" guardnames = sorted(guardnames.keys()) msg = msg.format(' or '.join(guardnames)) return unittest.skip(msg) def _parse_guards(guards): # Returns a tuple ({platform_name: run_me}, default_value) if not guards: return ({'cpython': True}, False) is_true = guards.values()[0] assert guards.values() == [is_true] * len(guards) # all True or all False return (guards, not is_true) # Use the following check to guard CPython's implementation-specific tests -- # or to run them only on the implementation(s) guarded by the arguments. def check_impl_detail(**guards): """This function returns True or False depending on the host platform. Examples: if check_impl_detail(): # only on CPython (default) if check_impl_detail(jython=True): # only on Jython if check_impl_detail(cpython=False): # everywhere except on CPython """ guards, default = _parse_guards(guards) return guards.get(platform.python_implementation().lower(), default) def _filter_suite(suite, pred): """Recursively filter test cases in a suite based on a predicate.""" newtests = [] for test in suite._tests: if isinstance(test, unittest.TestSuite): _filter_suite(test, pred) newtests.append(test) else: if pred(test): newtests.append(test) suite._tests = newtests def _run_suite(suite): """Run tests from a unittest.TestSuite-derived class.""" if verbose: runner = unittest.TextTestRunner(sys.stdout, verbosity=2, failfast=failfast) else: runner = BasicTestRunner() result = runner.run(suite) if not result.testsRun and not result.skipped: raise TestDidNotRun if not result.wasSuccessful(): if len(result.errors) == 1 and not result.failures: err = result.errors[0][1] elif len(result.failures) == 1 and not result.errors: err = result.failures[0][1] else: err = "multiple errors occurred" if not verbose: err += "; run in verbose mode for details" raise TestFailed(err) # By default, don't filter tests _match_test_func = None _match_test_patterns = None def match_test(test): # Function used by support.run_unittest() and regrtest --list-cases if _match_test_func is None: return True else: return _match_test_func(test.id()) def _is_full_match_test(pattern): # If a pattern contains at least one dot, it's considered # as a full test identifier. # Example: 'test.test_os.FileTests.test_access'. # # Reject patterns which contain fnmatch patterns: '*', '?', '[...]' # or '[!...]'. For example, reject 'test_access*'. return ('.' in pattern) and (not re.search(r'[?*\[\]]', pattern)) def set_match_tests(patterns): global _match_test_func, _match_test_patterns if patterns == _match_test_patterns: # No change: no need to recompile patterns. return if not patterns: func = None # set_match_tests(None) behaves as set_match_tests(()) patterns = () elif all(map(_is_full_match_test, patterns)): # Simple case: all patterns are full test identifier. # The test.bisect utility only uses such full test identifiers. func = set(patterns).__contains__ else: regex = '|'.join(map(fnmatch.translate, patterns)) # The search *is* case sensitive on purpose: # don't use flags=re.IGNORECASE regex_match = re.compile(regex).match def match_test_regex(test_id): if regex_match(test_id): # The regex matchs the whole identifier like # 'test.test_os.FileTests.test_access' return True else: # Try to match parts of the test identifier. # For example, split 'test.test_os.FileTests.test_access' # into: 'test', 'test_os', 'FileTests' and 'test_access'. return any(map(regex_match, test_id.split("."))) func = match_test_regex # Create a copy since patterns can be mutable and so modified later _match_test_patterns = tuple(patterns) _match_test_func = func def run_unittest(*classes): """Run tests from unittest.TestCase-derived classes.""" valid_types = (unittest.TestSuite, unittest.TestCase) suite = unittest.TestSuite() for cls in classes: if isinstance(cls, str): if cls in sys.modules: suite.addTest(unittest.findTestCases(sys.modules[cls])) else: raise ValueError("str arguments must be keys in sys.modules") elif isinstance(cls, valid_types): suite.addTest(cls) else: suite.addTest(unittest.makeSuite(cls)) _filter_suite(suite, match_test) _run_suite(suite) #======================================================================= # Check for the presence of docstrings. HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or sys.platform == 'win32' or sysconfig.get_config_var('WITH_DOC_STRINGS')) requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS, "test requires docstrings") #======================================================================= # doctest driver. def run_doctest(module, verbosity=None): """Run doctest on the given module. Return (#failures, #tests). If optional argument verbosity is not specified (or is None), pass test.support's belief about verbosity on to doctest. Else doctest's usual behavior is used (it searches sys.argv for -v). """ import doctest if verbosity is None: verbosity = verbose else: verbosity = None # Direct doctest output (normally just errors) to real stdout; doctest # output shouldn't be compared by regrtest. save_stdout = sys.stdout sys.stdout = get_original_stdout() try: f, t = doctest.testmod(module, verbose=verbosity) if f: raise TestFailed("%d of %d doctests failed" % (f, t)) finally: sys.stdout = save_stdout if verbose: print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t) return f, t #======================================================================= # Threading support to prevent reporting refleaks when running regrtest.py -R # Flag used by saved_test_environment of test.libregrtest.save_env, # to check if a test modified the environment. The flag should be set to False # before running a new test. # # For example, threading_cleanup() sets the flag is the function fails # to cleanup threads. environment_altered = False # NOTE: we use thread._count() rather than threading.enumerate() (or the # moral equivalent thereof) because a threading.Thread object is still alive # until its __bootstrap() method has returned, even after it has been # unregistered from the threading module. # thread._count(), on the other hand, only gets decremented *after* the # __bootstrap() method has returned, which gives us reliable reference counts # at the end of a test run. def threading_setup(): if thread: return thread._count(), else: return 1, def threading_cleanup(nb_threads): if not thread: return _MAX_COUNT = 10 for count in range(_MAX_COUNT): n = thread._count() if n == nb_threads: break time.sleep(0.1) # XXX print a warning in case of failure? def reap_threads(func): """Use this function when threads are being used. This will ensure that the threads are cleaned up even when the test fails. If threading is unavailable this function does nothing. """ if not thread: return func @functools.wraps(func) def decorator(*args): key = threading_setup() try: return func(*args) finally: threading_cleanup(*key) return decorator @contextlib.contextmanager def wait_threads_exit(timeout=60.0): """ bpo-31234: Context manager to wait until all threads created in the with statement exit. Use thread.count() to check if threads exited. Indirectly, wait until threads exit the internal t_bootstrap() C function of the thread module. threading_setup() and threading_cleanup() are designed to emit a warning if a test leaves running threads in the background. This context manager is designed to cleanup threads started by the thread.start_new_thread() which doesn't allow to wait for thread exit, whereas thread.Thread has a join() method. """ old_count = thread._count() try: yield finally: start_time = time.time() deadline = start_time + timeout while True: count = thread._count() if count <= old_count: break if time.time() > deadline: dt = time.time() - start_time msg = ("wait_threads() failed to cleanup %s " "threads after %.1f seconds " "(count: %s, old count: %s)" % (count - old_count, dt, count, old_count)) raise AssertionError(msg) time.sleep(0.010) gc_collect() def reap_children(): """Use this function at the end of test_main() whenever sub-processes are started. This will help ensure that no extra children (zombies) stick around to hog resources and create problems when looking for refleaks. """ # Reap all our dead child processes so we don't leave zombies around. # These hog resources and might be causing some of the buildbots to die. if hasattr(os, 'waitpid'): any_process = -1 while True: try: # This will raise an exception on Windows. That's ok. pid, status = os.waitpid(any_process, os.WNOHANG) if pid == 0: break except: break @contextlib.contextmanager def start_threads(threads, unlock=None): threads = list(threads) started = [] try: try: for t in threads: t.start() started.append(t) except: if verbose: print("Can't start %d threads, only %d threads started" % (len(threads), len(started))) raise yield finally: if unlock: unlock() endtime = starttime = time.time() for timeout in range(1, 16): endtime += 60 for t in started: t.join(max(endtime - time.time(), 0.01)) started = [t for t in started if t.isAlive()] if not started: break if verbose: print('Unable to join %d threads during a period of ' '%d minutes' % (len(started), timeout)) started = [t for t in started if t.isAlive()] if started: raise AssertionError('Unable to join %d threads' % len(started)) @contextlib.contextmanager def swap_attr(obj, attr, new_val): """Temporary swap out an attribute with a new object. Usage: with swap_attr(obj, "attr", 5): ... This will set obj.attr to 5 for the duration of the with: block, restoring the old value at the end of the block. If `attr` doesn't exist on `obj`, it will be created and then deleted at the end of the block. The old value (or None if it doesn't exist) will be assigned to the target of the "as" clause, if there is one. """ if hasattr(obj, attr): real_val = getattr(obj, attr) setattr(obj, attr, new_val) try: yield real_val finally: setattr(obj, attr, real_val) else: setattr(obj, attr, new_val) try: yield finally: if hasattr(obj, attr): delattr(obj, attr) @contextlib.contextmanager def swap_item(obj, item, new_val): """Temporary swap out an item with a new object. Usage: with swap_item(obj, "item", 5): ... This will set obj["item"] to 5 for the duration of the with: block, restoring the old value at the end of the block. If `item` doesn't exist on `obj`, it will be created and then deleted at the end of the block. The old value (or None if it doesn't exist) will be assigned to the target of the "as" clause, if there is one. """ if item in obj: real_val = obj[item] obj[item] = new_val try: yield real_val finally: obj[item] = real_val else: obj[item] = new_val try: yield finally: if item in obj: del obj[item] def py3k_bytes(b): """Emulate the py3k bytes() constructor. NOTE: This is only a best effort function. """ try: # memoryview? return b.tobytes() except AttributeError: try: # iterable of ints? return b"".join(chr(x) for x in b) except TypeError: return bytes(b) requires_type_collecting = unittest.skipIf(hasattr(sys, 'getcounts'), 'types are immortal if COUNT_ALLOCS is defined') def args_from_interpreter_flags(): """Return a list of command-line arguments reproducing the current settings in sys.flags.""" import subprocess return subprocess._args_from_interpreter_flags() def strip_python_stderr(stderr): """Strip the stderr of a Python process from potential debug output emitted by the interpreter. This will typically be run on the result of the communicate() method of a subprocess.Popen object. """ stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip() return stderr def check_free_after_iterating(test, iter, cls, args=()): class A(cls): def __del__(self): done[0] = True try: next(it) except StopIteration: pass done = [False] it = iter(A(*args)) # Issue 26494: Shouldn't crash test.assertRaises(StopIteration, next, it) # The sequence should be deallocated just after the end of iterating gc_collect() test.assertTrue(done[0]) @contextlib.contextmanager def disable_gc(): have_gc = gc.isenabled() gc.disable() try: yield finally: if have_gc: gc.enable() def python_is_optimized(): """Find if Python was built with optimizations.""" cflags = sysconfig.get_config_var('PY_CFLAGS') or '' final_opt = "" for opt in cflags.split(): if opt.startswith('-O'): final_opt = opt return final_opt not in ('', '-O0', '-Og') class SuppressCrashReport: """Try to prevent a crash report from popping up. On Windows, don't display the Windows Error Reporting dialog. On UNIX, disable the creation of coredump file. """ old_value = None old_modes = None def __enter__(self): """On Windows, disable Windows Error Reporting dialogs using SetErrorMode. On UNIX, try to save the previous core file size limit, then set soft limit to 0. """ if sys.platform.startswith('win'): # see http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621.aspx # GetErrorMode is not available on Windows XP and Windows Server 2003, # but SetErrorMode returns the previous value, so we can use that import ctypes self._k32 = ctypes.windll.kernel32 SEM_NOGPFAULTERRORBOX = 0x02 self.old_value = self._k32.SetErrorMode(SEM_NOGPFAULTERRORBOX) self._k32.SetErrorMode(self.old_value | SEM_NOGPFAULTERRORBOX) # Suppress assert dialogs in debug builds # (see http://bugs.python.org/issue23314) try: import _testcapi _testcapi.CrtSetReportMode except (AttributeError, ImportError): # no _testcapi or a release build pass else: self.old_modes = {} for report_type in [_testcapi.CRT_WARN, _testcapi.CRT_ERROR, _testcapi.CRT_ASSERT]: old_mode = _testcapi.CrtSetReportMode(report_type, _testcapi.CRTDBG_MODE_FILE) old_file = _testcapi.CrtSetReportFile(report_type, _testcapi.CRTDBG_FILE_STDERR) self.old_modes[report_type] = old_mode, old_file else: try: import resource except ImportError: resource = None if resource is not None: try: self.old_value = resource.getrlimit(resource.RLIMIT_CORE) resource.setrlimit(resource.RLIMIT_CORE, (0, self.old_value[1])) except (ValueError, OSError): pass if sys.platform == 'darwin': # Check if the 'Crash Reporter' on OSX was configured # in 'Developer' mode and warn that it will get triggered # when it is. # # This assumes that this context manager is used in tests # that might trigger the next manager. import subprocess cmd = ['/usr/bin/defaults', 'read', 'com.apple.CrashReporter', 'DialogType'] proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout = proc.communicate()[0] if stdout.strip() == b'developer': sys.stdout.write("this test triggers the Crash Reporter, " "that is intentional") sys.stdout.flush() return self def __exit__(self, *ignore_exc): """Restore Windows ErrorMode or core file behavior to initial value.""" if self.old_value is None: return if sys.platform.startswith('win'): self._k32.SetErrorMode(self.old_value) if self.old_modes: import _testcapi for report_type, (old_mode, old_file) in self.old_modes.items(): _testcapi.CrtSetReportMode(report_type, old_mode) _testcapi.CrtSetReportFile(report_type, old_file) else: import resource try: resource.setrlimit(resource.RLIMIT_CORE, self.old_value) except (ValueError, OSError): pass def _crash_python(): """Deliberate crash of Python. Python can be killed by a segmentation fault (SIGSEGV), a bus error (SIGBUS), or a different error depending on the platform. Use SuppressCrashReport() to prevent a crash report from popping up. """ import _testcapi with SuppressCrashReport(): _testcapi._read_null() def fd_count(): """Count the number of open file descriptors. """ if sys.platform.startswith(('linux', 'freebsd')): try: names = os.listdir("/proc/self/fd") # Substract one because listdir() opens internally a file # descriptor to list the content of the /proc/self/fd/ directory. return len(names) - 1 except OSError as exc: if exc.errno != errno.ENOENT: raise MAXFD = 256 if hasattr(os, 'sysconf'): try: MAXFD = os.sysconf("SC_OPEN_MAX") except OSError: pass old_modes = None if sys.platform == 'win32': # bpo-25306, bpo-31009: Call CrtSetReportMode() to not kill the process # on invalid file descriptor if Python is compiled in debug mode try: import msvcrt msvcrt.CrtSetReportMode except (AttributeError, ImportError): # no msvcrt or a release build pass else: old_modes = {} for report_type in (msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT): old_modes[report_type] = msvcrt.CrtSetReportMode(report_type, 0) try: count = 0 for fd in range(MAXFD): try: # Prefer dup() over fstat(). fstat() can require input/output # whereas dup() doesn't. fd2 = os.dup(fd) except OSError as e: if e.errno != errno.EBADF: raise else: os.close(fd2) count += 1 finally: if old_modes is not None: for report_type in (msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT): msvcrt.CrtSetReportMode(report_type, old_modes[report_type]) return count class SaveSignals: """ Save an restore signal handlers. This class is only able to save/restore signal handlers registered by the Python signal module: see bpo-13285 for "external" signal handlers. """ def __init__(self): import signal self.signal = signal self.signals = list(range(1, signal.NSIG)) # SIGKILL and SIGSTOP signals cannot be ignored nor catched for signame in ('SIGKILL', 'SIGSTOP'): try: signum = getattr(signal, signame) except AttributeError: continue self.signals.remove(signum) self.handlers = {} def save(self): for signum in self.signals: handler = self.signal.getsignal(signum) if handler is None: # getsignal() returns None if a signal handler was not # registered by the Python signal module, # and the handler is not SIG_DFL nor SIG_IGN. # # Ignore the signal: we cannot restore the handler. continue self.handlers[signum] = handler def restore(self): for signum, handler in self.handlers.items(): self.signal.signal(signum, handler) PK`]LB2 __init__.pynu[import os import sys import unittest here = os.path.dirname(__file__) loader = unittest.defaultTestLoader def suite(): suite = unittest.TestSuite() for fn in os.listdir(here): if fn.startswith("test") and fn.endswith(".py"): modname = "unittest.test." + fn[:-3] __import__(modname) module = sys.modules[modname] suite.addTest(loader.loadTestsFromModule(module)) return suite if __name__ == "__main__": unittest.main(defaultTest="suite") PKbd]z# __init__.pycnu[ {fc@skddlZddlZddlZejjeZejZdZ e dkrgej ddndS(iNcCstj}xstjtD]b}|jdr|jdrd|d }t|tj |}|j t j |qqW|S(Nttests.pysunittest.test.i( tunittestt TestSuitetostlistdirtheret startswithtendswitht __import__tsystmodulestaddTesttloadertloadTestsFromModule(tsuitetfntmodnametmodule((s./usr/lib64/python2.7/unittest/test/__init__.pyR s   t__main__t defaultTestR( RR Rtpathtdirnamet__file__RtdefaultTestLoaderR Rt__name__tmain(((s./usr/lib64/python2.7/unittest/test/__init__.pyts     PKbd]z# __init__.pyonu[ {fc@skddlZddlZddlZejjeZejZdZ e dkrgej ddndS(iNcCstj}xstjtD]b}|jdr|jdrd|d }t|tj |}|j t j |qqW|S(Nttests.pysunittest.test.i( tunittestt TestSuitetostlistdirtheret startswithtendswitht __import__tsystmodulestaddTesttloadertloadTestsFromModule(tsuitetfntmodnametmodule((s./usr/lib64/python2.7/unittest/test/__init__.pyR s   t__main__t defaultTestR( RR Rtpathtdirnamet__file__RtdefaultTestLoaderR Rt__name__tmain(((s./usr/lib64/python2.7/unittest/test/__init__.pyts     PKbd]J[test_support.pycnu[ zfc@s,ddlZddlZejejds  PKbd]g 2))script_helper.pynu[from test.support.script_helper import * PKbd]GKFscript_helper.pyonu[ zfc@sddlTdS(i(t*N(ttest.support.script_helper(((s*/usr/lib64/python2.7/test/script_helper.pyttPKbd]&=support/__init__.pycnu[ {fc=@s dZedkr!ednddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddlZWnek r:dZnXddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d4d<d=d>d?d@g=ZdAZdefdBYZdefdCYZdefdDYZdejfdEYZ ej!e"dFZ#e$dGZ%dHZ&dIZ'dde$dJZ(dKZ)dLZ*dZ+dMa,dMa-e$Z.da/dNZ0dOZ1dPZ2dQZ3e j j4dRr+e$dSZ5dTZ6dUZ7dVZ8ne j9Z6e j:Z7dWZ8dXZ9dYZ:dZZ;d[Z<d\Z=d]Z>dd^Z?d_Z@d`ZAdaZBejCejDdbZEeAdcZFddZGeGZHdeZIdfZJdgZKdZLdZMe j j4dkZNyeOe"ZPWneQk r-e$ZPnXejRePdlZSdmZTdZUePrxeVdneVdoeVdpeVdqeVdreVdseVdteVdueVdveVdweVdxf D]XZWy7eWjXe jYjZe jYeWkre[nWne[k rqXeWZUPqWne j\dkkr6dyZ]ne j\dzkrNd{Z]nd|Z]ePre^d}eOrrd~Z_neOd~dZ_e jYZ`eae d se jbddkrdZcqeddZcyecjXdWneek rqXdecGHndjfe]e jgZ]dZhe jiZjej!de$dZkej!e$dZlej!de$dZme jnjoe jnjpeqZre jnjoerZse jnjtesdZuddZvdZwdZxd}dddZyddZzde{fdYZ|e$dZ}ej!dZ~ej!dZd&e{fdYZd'ejfdYZde{fdYZd*e{fdYZej!dAddZej!dZdZdZdZdZdZeae drdeZnedZdZdZdZdZdZdZdZdZdieZdeZdheZe jZdZdedZdee"dZdZd0ddYZdZdZdZddZdZdZdZdZdadadZdZdZdZede$pW e j dkpW ejdZejRedZddZe$ZdZdZdZej!ddZdZej!ddZej!dZej!dZdZejeae ddZdZdZddZej!dZdZd@ddYZdZdZdddYZdS(s7Supporting definitions for the Python regression tests.s test.supports3test.support must be imported from the test packageiNtErrort TestFailedt TestDidNotRuntResourceDeniedt import_moduletverboset use_resourcest max_memusetrecord_original_stdouttget_original_stdouttunloadtunlinktrmtreetforgettis_resource_enabledtrequirestrequires_mac_vertfind_unused_portt bind_porttfcmpt have_unicodet is_jythontTESTFNtHOSTtFUZZtSAVEDCWDttemp_cwdtfindfiletsortdicttcheck_syntax_errortopen_urlresourcetcheck_warningstcheck_py3k_warningst CleanImporttEnvironmentVarGuardtcaptured_outputtcaptured_stdouttTransientResourcettransient_internettrun_with_localet set_memlimitt bigmemtesttbigaddrspacetesttBasicTestRunnert run_unittestt run_doctesttthreading_setuptthreading_cleanupt reap_threadst start_threadst cpython_onlytcheck_impl_detailt get_attributet py3k_bytestimport_fresh_modulet reap_childrentstrip_python_stderrt IPV6_ENABLEDt run_with_tztSuppressCrashReportg>@cBseZdZRS(s*Base class for regression test exceptions.(t__name__t __module__t__doc__(((s-/usr/lib64/python2.7/test/support/__init__.pyR4scBseZdZRS(s Test failed.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR7scBseZdZRS(sTest did not run any subtests.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR:scBseZdZRS(sTest skipped because it requested a disallowed resource. This is raised when a test calls requires() for a resource that has not been enabled. It is used to distinguish between expected and unexpected skips. (R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR=sccs=|r4tjtjddtdVWdQXndVdS(sContext manager to suppress package and module deprecation warnings when importing them. If ignore is False, this context manager has no effect.tignores.+ (module|package)N(twarningstcatch_warningstfilterwarningstDeprecationWarning(R?((s-/usr/lib64/python2.7/test/support/__init__.pyt_ignore_deprecated_importsEs   c CsSt|Aytj|SWn(tk rH}tjt|nXWdQXdS(sImport and return the module to be tested, raising SkipTest if it is not available. If deprecated is True, any module or package deprecation messages will be suppressed.N(RDt importlibRt ImportErrortunittesttSkipTesttstr(tnamet deprecatedtmsg((s-/usr/lib64/python2.7/test/support/__init__.pyRTs  cCs|tjkr&t|tj|=nxTttjD]C}||ks[|j|dr6tj|||t|t rd|j|f}ndt |j|f}t j |nX|SdS(s?Get an attribute, raising SkipTest if AttributeError is raised.smodule %r has no attribute %rsclass %s has no attribute %rs%s instance has no attribute %rs"type object %r has no attribute %rs%r object has no attribute %rN( tgetattrtAttributeErrort isinstancettypest ModuleTypeR<t ClassTypet InstanceTypet __class__ttypeRGRH(tobjRJt attributeRL((s-/usr/lib64/python2.7/test/support/__init__.pyR4s iicCs |adS(N(t_original_stdout(tstdout((s-/usr/lib64/python2.7/test/support/__init__.pyRscCs tp tjS(N(RrRNRs(((s-/usr/lib64/python2.7/test/support/__init__.pyR scCs&ytj|=Wntk r!nXdS(N(RNRORW(RJ((s-/usr/lib64/python2.7/test/support/__init__.pyR s cGsxy||SWnctk rs}tdkrVd|jj|fGHd|j|fGHntj|tj||SXdS(Nis%s: %ss re-run %s%r(tEnvironmentErrorRRnR<tostchmodtstattS_IRWXU(tpathtfunctargsterr((s-/usr/lib64/python2.7/test/support/__init__.pyt _force_runs twincCs|||r|}n$tjj|\}}|p:d}d}xR|dkrtj|}|rm|n ||ks}dStj||d9}qFWtjd|tdddS(NRMgMbP?g?is)tests may fail, delete still pending for t stackleveli( RuRytsplittlistdirttimetsleepR@twarntRuntimeWarning(RztpathnametwaitalltdirnameRJttimeouttL((s-/usr/lib64/python2.7/test/support/__init__.pyt_waitfors     cCsttj|dS(N(RRuR (tfilename((s-/usr/lib64/python2.7/test/support/__init__.pyt_unlinkscCsttj|dS(N(RRutrmdir(R((s-/usr/lib64/python2.7/test/support/__init__.pyt_rmdirscs6fdt|dttd|dS(Ncsxt|tj|D]i}tjj||}tjj|rlt|dtt|tj|qt|tj |qWdS(NR( R}RuRRytjointisdirRRVRR (RyRJtfullname(t _rmtree_inner(s-/usr/lib64/python2.7/test/support/__init__.pyRs RcSst|tj|S(N(R}RuR(tp((s-/usr/lib64/python2.7/test/support/__init__.pyt t(RRV(Ry((Rs-/usr/lib64/python2.7/test/support/__init__.pyt_rmtreescsSytj|dSWntk r(nXfd|tj|dS(Ncsxt|tj|D]}tjj||}ytj|j}Wntk r`d}nXtj |r|t|tj |qt|tj |qWdS(Ni( R}RuRRyRtlstattst_modeRtRwtS_ISDIRRR (RyRJRtmode(R(s-/usr/lib64/python2.7/test/support/__init__.pyRs   (tshutilR RtRuR(Ry((Rs-/usr/lib64/python2.7/test/support/__init__.pyRs   cCsIyt|Wn4tk rD}|jtjtjfkrEqEnXdS(N(RtOSErrorterrnotENOENTtENOTDIR(Rtexc((s-/usr/lib64/python2.7/test/support/__init__.pyR $s cCs@yt|Wn+tk r;}|jtjkr<q<nXdS(N(RRRR(Rterror((s-/usr/lib64/python2.7/test/support/__init__.pyR+s cCsIyt|Wn4tk rD}|jtjtjfkrEqEnXdS(N(RRRRtESRCH(Ryte((s-/usr/lib64/python2.7/test/support/__init__.pyR 3s cCsjt|xYtjD]N}ttjj||tjdttjj||tjdqWdS(sm"Forget" a module was ever imported by removing it from sys.modules and deleting any .pyc and .pyo files.tpyctpyoN(R RNRyR RuRtextsep(RTR((s-/usr/lib64/python2.7/test/support/__init__.pyR ;s $csttdrtjSd}tjjdr ddlddld}d}dj ffdY}j j }|j }|sj n|}jj}|j||j|j|j|}|sj nt|j|@sd}qntjdkrdd lm} mm} m } dd lm} | j| d } | jd krd }qd| ffdY}|}| |}| j|d ks| j|d krd}qn|sy;ddlm}|}|j |j!|j"Wqt#k r}t$|}t%|dkrz|d d}ndj&t'|j(|}qXn|t_)| t_tjS(NtresultR~iitUSEROBJECTFLAGScs;eZdjjfdjjfdjjfgZRS(tfInheritt fReservedtdwFlags(R<R=twintypestBOOLtDWORDt_fields_((tctypes(s-/usr/lib64/python2.7/test/support/__init__.pyRRss,gui not available (WSF_VISIBLE flag not set)tdarwin(tcdlltc_inttpointert Structure(t find_librarytApplicationServicesis0gui tests cannot run without OS X window managertProcessSerialNumbercs eZdfdfgZRS(t highLongOfPSNt lowLongOfPSN(R<R=R((R(s-/usr/lib64/python2.7/test/support/__init__.pyRts s#cannot run without OS X gui process(tTki2s [...]sTk unavailable due to {}: {}(*thasattrt_is_gui_availableRRYRNtplatformRRRtctypes.wintypesRtwindlltuser32tGetProcessWindowStationtWinErrorRRtGetUserObjectInformationWtbyreftsizeoftboolRRRRt ctypes.utilRt LoadLibrarytCGMainDisplayIDtGetCurrentProcesstSetFrontProcesstTkinterRtwithdrawtupdatetdestroyt ExceptionRItlentformatRoR<treason(Rt UOI_FLAGSt WSF_VISIBLERtdllthtuoftneededtresRRRRt app_servicesRtpsntpsn_pRtrootRt err_string((RRs-/usr/lib64/python2.7/test/support/__init__.pyRGsh         "          cCstdkp|tkS(sTest whether a resource is enabled. Known resources are set by regrtest.py. If not running under regrtest.py, all resources are assumed enabled unless use_resources has been set. N(RRY(tresource((s-/usr/lib64/python2.7/test/support/__init__.pyRscCs`t|s4|dkr%d|}nt|n|dkr\t r\ttjndS(s@Raise ResourceDenied if the specified resource is not available.s$Use of the `%s' resource not enabledtguiN(RRYRRR(RRL((s-/usr/lib64/python2.7/test/support/__init__.pyRs    csfd}|S(sDecorator raising SkipTest if the OS is Mac OS X and the OS X version if less than min_version. For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version is lesser than 10.5. cs.tjfd}|_|S(Ncstjdkrtjd}y"ttt|jd}Wntk rTqX|krdjtt }t j d||fqn||S(NRiRMs&Mac OS X %s or higher required, not %s( RNRtmac_verttupletmaptintRt ValueErrorRRIRGRH(R{tkwt version_txttversiontmin_version_txt(Rzt min_version(s-/usr/lib64/python2.7/test/support/__init__.pytwrappers"  (t functoolstwrapsR(RzR(R(Rzs-/usr/lib64/python2.7/test/support/__init__.pyt decorators! ((RR((Rs-/usr/lib64/python2.7/test/support/__init__.pyRss 127.0.0.1s::1cCs/tj||}t|}|j~|S(s Returns an unused port that should be suitable for binding. This is achieved by creating a temporary socket with the same family and type as the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to the specified host address (defaults to 0.0.0.0) with the port set to 0, eliciting an unused ephemeral port from the OS. The temporary socket is then closed and deleted, and the ephemeral port is returned. Either this method or bind_port() should be used for any tests where a server socket needs to be bound to a particular port for the duration of the test. Which one to use depends on whether the calling code is creating a python socket, or if an unused port needs to be provided in a constructor or passed to an external program (i.e. the -accept argument to openssl's s_server mode). Always prefer bind_port() over find_unused_port() where possible. Hard coded ports should *NEVER* be used. As soon as a server socket is bound to a hard coded port, the ability to run multiple instances of the test simultaneously on the same host is compromised, which makes the test a ticking time bomb in a buildbot environment. On Unix buildbots, this may simply manifest as a failed test, which can be recovered from without intervention in most cases, but on Windows, the entire python process can completely and utterly wedge, requiring someone to log in to the buildbot and manually kill the affected process. (This is easy to reproduce on Windows, unfortunately, and can be traced to the SO_REUSEADDR socket option having different semantics on Windows versus Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind, listen and then accept connections on identical host/ports. An EADDRINUSE socket.error will be raised at some point (depending on the platform and the order bind and listen were called on each socket). However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE will ever be raised when attempting to bind two identical host/ports. When accept() is called on each socket, the second caller's process will steal the port from the first caller, leaving them both in an awkwardly wedged state where they'll no longer respond to any signals or graceful kills, and must be forcibly killed via OpenProcess()/TerminateProcess(). The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option instead of SO_REUSEADDR, which effectively affords the same semantics as SO_REUSEADDR on Unix. Given the propensity of Unix developers in the Open Source world compared to Windows ones, this is a common mistake. A quick look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when openssl.exe is called with the 's_server' option, for example. See http://bugs.python.org/issue2550 for more info. The following site also has a very thorough description about the implications of both REUSEADDR and EXCLUSIVEADDRUSE on Windows: http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx) XXX: although this approach is a vast improvement on previous attempts to elicit unused ports, it rests heavily on the assumption that the ephemeral port returned to us by the OS won't immediately be dished back out to some other process when we close and delete our temporary socket but before our calling code has a chance to bind the returned port. We can deal with this issue if/when we come across it.(tsocketRtclose(tfamilytsocktypettempsocktport((s-/usr/lib64/python2.7/test/support/__init__.pyRs 6  cCs|jtjkr|jtjkrttdrc|jtjtjdkrct dqcnttdry1|jtjtj dkrt dnWqt k rqXnttdr|j tjtj dqn|j|df|jd}|S(s%Bind the socket to a free port and return the port number. Relies on ephemeral ports in order to ensure we are using an unbound port. This is important as many tests may be running simultaneously, especially in a buildbot environment. This method raises an exception if the sock.family is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR or SO_REUSEPORT set on it. Tests should *never* set these socket options for TCP/IP sockets. The only case for setting these options is testing multicasting via multiple UDP sockets. Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e. on Windows), it will be set on the socket. This will prevent anyone else from bind()'ing to our host/port for the duration of the test. t SO_REUSEADDRisHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!t SO_REUSEPORTsHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!tSO_EXCLUSIVEADDRUSEi(RRtAF_INETRot SOCK_STREAMRt getsockoptt SOL_SOCKETRRRRtt setsockoptRtbindt getsockname(tsockthostR((s-/usr/lib64/python2.7/test/support/__init__.pyRs$ cCs{tjrwd}zNy3tjtjtj}|jtdftSWntjk r[nXWd|rs|j nXnt S(s+Check whether IPv6 is enabled on this host.iN( Rthas_ipv6RYtAF_INET6RRtHOSTv6RVRRRX(R((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_ipv6_enabled$s cs"tjfd}|S(s5Skip the test on TLS certificate validation failures.csRy||Wn:tk rM}dt|krGtjdnnXdS(NtCERTIFICATE_VERIFY_FAILEDs.system does not contain necessary certificates(tIOErrorRIRGRH(R{tkwargsR(tf(s-/usr/lib64/python2.7/test/support/__init__.pytdec7s (RR(R R ((R s-/usr/lib64/python2.7/test/support/__init__.pytsystem_must_validate_cert5s gư>cCs#t|tst|trcy8t|t|t}t|||krUdSWqqXnt|t|krt|ttfrxPttt |t |D]-}t ||||}|dkr|SqWt |t |kt |t |kS||k||kS(Ni( RitfloattabsRRoRRQtrangetminRR(txtytfuzztitoutcome((s-/usr/lib64/python2.7/test/support/__init__.pyRDs-( ,iiitjavasno unicode supportcCs t|dS(Nsunicode-escape(tunicode(ts((s-/usr/lib64/python2.7/test/support/__init__.pytumsii0iAiiii i*iii s$testtriscosttestfiles@testRs@test-slatin-1tgetwindowsversioniis'u"@test-\u5171\u6709\u3055\u308c\u308b"tLatin1sgWARNING: The filename %r CAN be encoded by the filesystem. Unicode filename tests may not be effectives {}_{}_tmpshttp://www.pythontest.netccsQt}|dkrEddl}|j}t}tjj|}ntrt |t rtjj ry|j t jpd}Wqtk r|stjdqqXnytj|t}Wn7tk r|sntjd|tddnX|rtj}nz |VWd|rL|tjkrLt|nXdS(sReturn a context manager that creates a temporary directory. Arguments: path: the directory to create temporarily. If omitted or None, defaults to creating a temporary directory using tempfile.mkdtemp. quiet: if False (the default), the context manager raises an exception on error. Otherwise, if the path is specified and cannot be created, only a warning is issued. iNtasciis;unable to encode the cwd name with the filesystem encoding.s+tests may fail, unable to create temp dir: Ri(RXRYttempfiletmkdtempRVRuRytrealpathRRiRtsupports_unicode_filenamestencodeRNtgetfilesystemencodingtUnicodeEncodeErrorRGRHtmkdirRR@RRtgetpidR (Rytquiett dir_createdR tpid((s-/usr/lib64/python2.7/test/support/__init__.pyttemp_dirs6          ccs{tj}ytj|Wn7tk rV|s9ntjd|tddnXztjVWdtj|XdS(sgReturn a context manager that changes the current working directory. Arguments: path: the directory to use as the temporary current working directory. quiet: if False (the default), the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same. s)tests may fail, unable to change CWD to: RiN(RutgetcwdtchdirRR@RR(RyR)t saved_dir((s-/usr/lib64/python2.7/test/support/__init__.pyt change_cwd s   ttempcwdc csBtd|d|'}t|d| }|VWdQXWdQXdS(s Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkdtemp. If *quiet* is False (default) and it is not possible to create or change the CWD, an error is raised. If *quiet* is True, only a warning is raised and the original CWD is used. RyR)N(R,R0(RJR)t temp_pathtcwd_dir((s-/usr/lib64/python2.7/test/support/__init__.pyR&stdatacCstjj|r|S|dk r:tjj||}ntgtj}x9|D]1}tjj||}tjj|rQ|SqQW|S(sTry to find a file on sys.path and the working directory. If it is not found the argument passed to the function is returned (this does not necessarily signal failure; could still be the legitimate path).N(RuRytisabsRYRt TEST_HOME_DIRRNtexists(tfiletsubdirRytdntfn((s-/usr/lib64/python2.7/test/support/__init__.pyRAs  cCsJ|j}|jg|D]}d|^q}dj|}d|S(s%Like repr(dict), but in sorted order.s%r: %rs, s{%s}(R]tsortR(tdictR]tpairt reprpairst withcommas((s-/usr/lib64/python2.7/test/support/__init__.pyROs   cCs9ttd}z|jSWd|jttXdS(s` Create an invalid file descriptor by opening and closing a file and return its fd. twbN(topenRtfilenoRR (R8((s-/usr/lib64/python2.7/test/support/__init__.pyt make_bad_fdWs  cCs||jt|}t|ddWdQX|j}|dk rV|j|j|n|dk rx|j|j|ndS(Ns texec(tassertRaisesRegexpt SyntaxErrortcompilet exceptionRYt assertEqualtlinenotoffset(ttestcaset statementterrtextRKRLtcmR|((s-/usr/lib64/python2.7/test/support/__init__.pyRcs   c sSddl}ddl}|j|djdd}tjjt|}fd}tjj|r||}|dk r|St |nt dt d|IJ|j |dd}zNt |d 9}|j} x#| r |j| |j} qWWdQXWd|jX||}|dk r?|Std |dS( Niit/csGt|}dkr|S|r9|jd|S|jdS(Ni(RBRYtseekR(R;R (tcheck(s-/usr/lib64/python2.7/test/support/__init__.pytcheck_valid_filess    turlfetchs fetching %s ...RiRAsinvalid resource "%s"(turlparseturllib2RRuRyRt TEST_DATA_DIRR7RYR RR turlopenRBtreadtwriteRR( turlRSRVRWRR;RTR toutR((RSs-/usr/lib64/python2.7/test/support/__init__.pyRls.            tWarningsRecordercBs8eZdZdZdZedZdZRS(syConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. cCs||_d|_dS(Ni(t _warningst_last(tselft warnings_list((s-/usr/lib64/python2.7/test/support/__init__.pyt__init__s cCs\t|j|jkr,t|jd|S|tjjkrBdStd||fdS(Nis%r has no attribute %r( RR_R`RgR@tWarningMessaget_WARNING_DETAILSRYRh(Ratattr((s-/usr/lib64/python2.7/test/support/__init__.pyt __getattr__s cCs|j|jS(N(R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR@scCst|j|_dS(N(RR_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pytresets(R<R=R>RcRgtpropertyR@Rh(((s-/usr/lib64/python2.7/test/support/__init__.pyR^s   c csptjd}|jjd}|r4|jntjdt&}tjdj dt |VWdQXg|D]}|j ^qu}g}x|D]\}} t } x[|D]R} t | } tj|| tjrt| j| rt} |j| qqW| r| r|j|| jfqqW|rOtd|dn|rltd |dndS( sCatch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. it__warningregistry__trecordR@talwaysNsunhandled warning %ris)filter (%r, %s) did not catch any warning(RNt _getframet f_globalstgettclearR@RARVROt simplefilterR^tmessageRXRItretmatchtIt issubclassRntremoveR\R<tAssertionError( tfiltersR)tframetregistrytwtwarningtreraisetmissingRLtcattseenRRr((s-/usr/lib64/python2.7/test/support/__init__.pyt_filterwarningss0  cOsI|jd}|s<dtff}|dkr<t}q<nt||S(sContext manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filters are defined) Without argument, it defaults to: check_warnings(("", Warning), quiet=True) R)RN(RotWarningRYRVR(RyR R)((s-/usr/lib64/python2.7/test/support/__init__.pyRs   cOs@tjr$|s*dtff}q*nd}t||jdS(sjContext manager to silence py3k warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default False) Without argument, it defaults to: check_py3k_warnings(("", DeprecationWarning), quiet=False) RR)((RNt py3kwarningRCRRo(RyR ((s-/usr/lib64/python2.7/test/support/__init__.pyR s  cBs)eZdZdZdZdZRS(s,Context manager to force import to return a new module reference. This is useful for testing module-level behaviours, such as the emission of a DeprecationWarning on import. Use like this: with CleanImport("foo"): importlib.import_module("foo") # new reference cGsotjj|_xV|D]N}|tjkrtj|}|j|krZtj|j=ntj|=qqWdS(N(RNROtcopytoriginal_modulesR<(Rat module_namest module_nameRe((s-/usr/lib64/python2.7/test/support/__init__.pyRcs  cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyt __enter__scGstjj|jdS(N(RNRORR(Rat ignore_exc((s-/usr/lib64/python2.7/test/support/__init__.pyt__exit__s(R<R=R>RcRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR!s  cBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( s_Class to help protect the environment variable properly. Can be used as a context manager.cCstj|_i|_dS(N(Rutenviront_environt_changed(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRc(s cCs |j|S(N(R(Ratenvvar((s-/usr/lib64/python2.7/test/support/__init__.pyt __getitem__,scCs<||jkr+|jj||j|RcRRRRRRRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR"#s        t DirsOnSysPathcBs)eZdZdZdZdZRS(sContext manager to temporarily add directories to sys.path. This makes a copy of sys.path, appends any directories given as positional arguments, then reverts sys.path to the copied settings when the context ends. Note that *all* sys.path modifications in the body of the context manager, including replacement of the object, will be reverted at the end of the block. cGs-tj|_tj|_tjj|dS(N(RNRytoriginal_valuetoriginal_objecttextend(Ratpaths((s-/usr/lib64/python2.7/test/support/__init__.pyRc^s  cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRcscGs|jt_|jtj(dS(N(RRNRyR(RaR((s-/usr/lib64/python2.7/test/support/__init__.pyRfs (R<R=R>RcRR(((s-/usr/lib64/python2.7/test/support/__init__.pyRRs   cBs2eZdZdZdZddddZRS(sRaise ResourceDenied if an exception is raised while the context manager is in effect that matches the specified exception and attributes.cKs||_||_dS(N(Rtattrs(RaRR ((s-/usr/lib64/python2.7/test/support/__init__.pyRcps cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRtscCs}|dk ryt|j|ryxX|jjD]8\}}t||sMPnt|||kr.Pq.q.WtdndS(sIf type_ is a subclass of self.exc and value has attributes matching self.attrs, raise ResourceDenied. Otherwise let the exception propagate (if any).s%an optional resource is not availableN(RYRvRRt iteritemsRRgR(Rattype_Rt tracebackRft attr_value((s-/usr/lib64/python2.7/test/support/__init__.pyRwsN(R<R=R>RcRRYR(((s-/usr/lib64/python2.7/test/support/__init__.pyR%ks  c #sdddd d!d"g}d#d$d%d&d'g}td||gsg|D]\}}tt||^qVg|D]\}}tt||^qnfd}tj}zy%|dk rtj|ndVWntk r} xxtr}| j } t | dkrGt | dtrG| d} qt | dkryt | dtry| d} qPqW|| nXWdtj|XdS((sReturn a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions.t ECONNREFUSEDiot ECONNRESETiht EHOSTUNREACHiqt ENETUNREACHiet ETIMEDOUTint EADDRNOTAVAILict EAI_AGAINitEAI_FAILit EAI_NONAMEit EAI_NODATAit WSANO_DATAi*sResource '%s' is not availablecst|dd}t|tjsNt|tjrB|ksN|kr{tsrtjj j ddnndS(NRis ( RgRYRiRRtgaierrorRRNtstderrR[R{(R|tn(tcaptured_errnostdeniedt gai_errnos(s-/usr/lib64/python2.7/test/support/__init__.pyt filter_errors Niii(Rio(Rih(Riq(Rie(Rin(Ric(Ri(Ri(Ri(Ri(Ri*( RRgRRtgetdefaulttimeoutRYtsetdefaulttimeoutR RVR{RRi( t resource_nameRterrnostdefault_errnostdefault_gai_errnosRJtnumRt old_timeoutR|ta((RRRs-/usr/lib64/python2.7/test/support/__init__.pyR&sJ  (+     % %   ccs[ddl}tt|}tt||jztt|VWdtt||XdS(sReturn a context manager used by captured_stdout and captured_stdin that temporarily replaces the sys stream *stream_name* with a StringIO.iN(tStringIORgRNtsetattr(t stream_nameRt orig_stdout((s-/usr/lib64/python2.7/test/support/__init__.pyR#s  cCs tdS(sCapture the output of sys.stdout: with captured_stdout() as s: print "hello" self.assertEqual(s.getvalue(), "hello") Rs(R#(((s-/usr/lib64/python2.7/test/support/__init__.pyR$scCs tdS(NR(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stderrscCs tdS(Ntstdin(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stdinscCs8tjtr tjdntjtjdS(sForce as many objects as possible to be collected. In non-CPython implementations of Python, this is needed because timely deallocation is not guaranteed by the garbage collector. (Even in CPython this can be the case in case of reference cycles.) This means that __del__ methods may be called later than expected and weakrefs may remain alive for longer than expected. This function tries its best to force all garbage objects to disappear. g?N(tgctcollectRRR(((s-/usr/lib64/python2.7/test/support/__init__.pyt gc_collects  t2PtgettotalrefcounttPcCstjt|dS(Nt0P(tstructtcalcsizet_header(tfmt((s-/usr/lib64/python2.7/test/support/__init__.pyt calcobjsizescCstjt|dS(NR(RRt_vheader(R((s-/usr/lib64/python2.7/test/support/__init__.pyt calcvobjsizesii cCsddl}tj|}t|tkr:|jt@s_t|tkrot|jt@ro||j7}ndt|||f}|j|||dS(Nis&wrong size for %s: got %d, expected %d( t _testcapiRNt getsizeofRot __flags__t_TPFLAGS_HEAPTYPEt_TPFLAGS_HAVE_GCtSIZEOF_PYGC_HEADRJ(ttesttotsizeRRRL((s-/usr/lib64/python2.7/test/support/__init__.pyt check_sizeofs %csfd}|S(Ncs1fd}j|_j|_|S(Ncsy.ddl}t|}|j|}Wn$tk rDnAd}}n1Xx-D]%}y|j||PWq\q\Xq\Wz||SWd|r|r|j||nXdS(Ni(tlocaleRgt setlocaleRhRY(R{tkwdsRtcategoryt orig_localetloc(tcatstrRztlocales(s-/usr/lib64/python2.7/test/support/__init__.pytinners$    (t func_nameR>(RzR(RR(Rzs-/usr/lib64/python2.7/test/support/__init__.pyRs  ((RRR((RRs-/usr/lib64/python2.7/test/support/__init__.pyR'scsfd}|S(Ncs.fd}j|_j|_|S(Ncsy tj}Wn tk r/tjdnXdtjkrOtjd}nd}tjd<|z||SWd|dkrtjd=n |tjd(RzR(R(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR:s  ((RR((Rs-/usr/lib64/python2.7/test/support/__init__.pyR:9scCsidd6td6td6dtd6}tjd|tjtjB}|dkrgtd|fntt |j d||j d j }|a |t krt }n|tdkrtd |fn|adS( NiRtmtgtts(\d+(\.\d+)?) (K|M|G|T)b?$sInvalid memory limit %riis$Memory limit %r too low to be useful(t_1Mt_1GRsRtt IGNORECASEtVERBOSERYRRRtgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2GR(tlimittsizesRtmemlimit((s-/usr/lib64/python2.7/test/support/__init__.pyR(bs   2  icsfd}|S(sQDecorator for bigmem tests. 'minsize' is the minimum useful size for the test (in arbitrary, test-interpreted units.) 'memuse' is the number of 'bytes per size' for the test, or a good estimate of it. 'overhead' specifies fixed overhead, independent of the testsize, and defaults to 5Mb. The decorator tries to guess a good value for 'size' and passes it to the decorated test function. If minsize * memuse is more than the allowed memory use (as defined by max_memuse), the test is skipped. Otherwise, minsize is adjusted upward to use up to max_memuse. cs7fd}|_|_|_|S(Ncsts.d}|j|dtkn^tt}|krutrqtjjdjfndSt |dt}||S(Niis)Skipping %s because of memory constraint i2( Rt assertFalseRRRRNRR[R<tmax(Ratmaxsize(R tmemusetminsizetoverhead(s-/usr/lib64/python2.7/test/support/__init__.pyRs"  (RRR(R R(RRR(R s-/usr/lib64/python2.7/test/support/__init__.pyRs    ((RRRR((RRRs-/usr/lib64/python2.7/test/support/__init__.pyR)ws csfd}|S(Ncs7fd}|_|_|_|S(Ncsftsd}n}ts" rYt|krYtrUtjjdjfndS||S(Nis)Skipping %s because of memory constraint (RRRNRR[R<(RaR(tdry_runR RR(s-/usr/lib64/python2.7/test/support/__init__.pyRs   (RRR(R R(RRRR(R s-/usr/lib64/python2.7/test/support/__init__.pyRs    ((RRRRR((RRRRs-/usr/lib64/python2.7/test/support/__init__.pytprecisionbigmemtestscsfd}|S(s0Decorator for tests that fill the address space.cs@ttkr2tr<tjjdjfq<n |SdS(Ns)Skipping %s because of memory constraint (RRRRNRR[R<(Ra(R (s-/usr/lib64/python2.7/test/support/__init__.pyRs   ((R R((R s-/usr/lib64/python2.7/test/support/__init__.pyR*scBseZdZRS(cCstj}|||S(N(RGt TestResult(RaRR((s-/usr/lib64/python2.7/test/support/__init__.pytruns  (R<R=R(((s-/usr/lib64/python2.7/test/support/__init__.pyR+scCs|S(N((Rp((s-/usr/lib64/python2.7/test/support/__init__.pyt_idscCsP|dkr&t r&tjtjSt|r6tStjdj|SdS(NRsresource {0!r} is not enabled(RRGtskipRRRR(R((s-/usr/lib64/python2.7/test/support/__init__.pytrequires_resources  cCstdt|S(s9 Decorator for tests only applicable on CPython. tcpython(t impl_detailRV(R((s-/usr/lib64/python2.7/test/support/__init__.pyR2scKs}t|rtS|dkrpt|\}}|r=d}nd}t|j}|jdj|}ntj |S(Ns*implementation detail not available on {0}s%implementation detail specific to {0}s or ( R3RRYt _parse_guardstsortedRRRRGR(RLtguardst guardnamestdefault((s-/usr/lib64/python2.7/test/support/__init__.pyRs   cCsW|sitd6tfS|jd}|j|gt|ksLt|| fS(NRi(RVRXtvaluesRRx(R tis_true((s-/usr/lib64/python2.7/test/support/__init__.pyR s %cKs.t|\}}|jtjj|S(s5This function returns True or False depending on the host platform. Examples: if check_impl_detail(): # only on CPython (default) if check_impl_detail(jython=True): # only on Jython if check_impl_detail(cpython=False): # everywhere except on CPython (R RoRtpython_implementationR(R R ((s-/usr/lib64/python2.7/test/support/__init__.pyR3scCsrg}x\|jD]Q}t|tjrEt|||j|q||r|j|qqW||_dS(s>Recursively filter test cases in a suite based on a predicate.N(t_testsRiRGt TestSuitet _filter_suiteR\(tsuitetpredtnewtestsR((s-/usr/lib64/python2.7/test/support/__init__.pyRs  cCstr'tjtjdddt}n t}|j|}|j r\|j r\t n|j st |j dkr|j r|j dd}nLt |jdkr|j r|jdd}nd}ts|d7}nt|ndS( s2Run tests from a unittest.TestSuite-derived class.t verbosityitfailfastiismultiple errors occurreds!; run in verbose mode for detailsN(RRGtTextTestRunnerRNRsRR+RttestsRuntskippedRt wasSuccessfulRterrorstfailuresR(RtrunnerRR|((s-/usr/lib64/python2.7/test/support/__init__.pyt _run_suites      cCs$tdkrtSt|jSdS(N(t_match_test_funcRYRVtid(R((s-/usr/lib64/python2.7/test/support/__init__.pyt match_test#s cCsd|kotjd| S(NRMs[?*\[\]](Rstsearch(tpattern((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_full_match_test+scs|tkrdS|s%d}d}nittt|rLt|j}nBdjttj |}t j |j fd}|}t |a|adS(Nt|cs0|rtStt|jdSdS(NRM(RVtanyRR(ttest_id(t regex_match(s-/usr/lib64/python2.7/test/support/__init__.pytmatch_test_regexJs ((t_match_test_patternsRYtallRR&Rt __contains__Rtfnmatcht translateRsRHRtRR!(tpatternsRztregexR+((R*s-/usr/lib64/python2.7/test/support/__init__.pytset_match_tests5s    cGstjtjf}tj}x|D]}t|trx|tjkri|jtjtj|qt dq%t||r|j|q%|jtj |q%Wt |t t |dS(s1Run tests from unittest.TestCase-derived classes.s)str arguments must be keys in sys.modulesN(RGRtTestCaseRiRIRNROtaddTestt findTestCasesRt makeSuiteRR#R (tclassest valid_typesRtcls((s-/usr/lib64/python2.7/test/support/__init__.pyR,]s    Rtwin32tWITH_DOC_STRINGSstest requires docstringscCsddl}|dkr!t}nd}tj}tt_z>|j|d|\}}|rytd||fnWd|t_Xtrd|j|fGHn||fS(s Run doctest on the given module. Return (#failures, #tests). If optional argument verbosity is not specified (or is None), pass test.support's belief about verbosity on to doctest. Else doctest's usual behavior is used (it searches sys.argv for -v). iNRs%d of %d doctests faileds,doctest (%s) ... %d tests with zero failures( tdoctestRYRRNRsR ttestmodRR<(ReRR=t save_stdoutR R((s-/usr/lib64/python2.7/test/support/__init__.pyR-|s      cCstrtjfSdSdS(Ni(i(tthreadt_count(((s-/usr/lib64/python2.7/test/support/__init__.pyR.s cCsTts dSd}x=t|D]/}tj}||kr?PntjdqWdS(Ni g?(R@RRARR(t nb_threadst _MAX_COUNTtcountR((s-/usr/lib64/python2.7/test/support/__init__.pyR/s  cs,ts Stjfd}|S(sUse this function when threads are being used. This will ensure that the threads are cleaned up even when the test fails. If threading is unavailable this function does nothing. cs)t}z|SWdt|XdS(N(R.R/(R{tkey(Rz(s-/usr/lib64/python2.7/test/support/__init__.pyRs (R@RR(RzR((Rzs-/usr/lib64/python2.7/test/support/__init__.pyR0sgN@ccstj}z dVWdtj}||}xtrtj}||krSPntj|krtj|}d|||||f}t|ntjdtq1WXdS(sE bpo-31234: Context manager to wait until all threads created in the with statement exit. Use thread.count() to check if threads exited. Indirectly, wait until threads exit the internal t_bootstrap() C function of the thread module. threading_setup() and threading_cleanup() are designed to emit a warning if a test leaves running threads in the background. This context manager is designed to cleanup threads started by the thread.start_new_thread() which doesn't allow to wait for thread exit, whereas thread.Thread has a join() method. NsYwait_threads() failed to cleanup %s threads after %.1f seconds (count: %s, old count: %s)g{Gz?(R@RARRVRxRR(Rt old_countt start_timetdeadlineRDtdtRL((s-/usr/lib64/python2.7/test/support/__init__.pytwait_threads_exits         cCscttdr_d}xGtr[y/tj|tj\}}|dkrLPnWqPqXqWndS(sUse this function at the end of test_main() whenever sub-processes are started. This will help ensure that no extra children (zombies) stick around to hog resources and create problems when looking for refleaks. twaitpidiiN(RRuRVRKtWNOHANG(t any_processR+tstatus((s-/usr/lib64/python2.7/test/support/__init__.pyR7s   c cst|}g}zfy,x%|D]}|j|j|qWWn.trkdt|t|fGHnnXdVWd|r|ntj}}xtddD]}|d7}x.|D]&}|jt|tjdqWg|D]}|j r|^q}|sPntrdt||fGHqqWXg|D]}|j rE|^qE}|rt dt|ndS(Ns/Can't start %d threads, only %d threads startediii<g{Gz?s7Unable to join %d threads during a period of %d minutessUnable to join %d threads( RQtstartR\RRRRRRtisAliveRx(tthreadstunlocktstartedRtendtimet starttimeR((s-/usr/lib64/python2.7/test/support/__init__.pyR1s:       $%%ccst||rNt||}t|||z |VWdt|||Xn<t|||z dVWdt||rt||nXdS(sTemporary swap out an attribute with a new object. Usage: with swap_attr(obj, "attr", 5): ... This will set obj.attr to 5 for the duration of the with: block, restoring the old value at the end of the block. If `attr` doesn't exist on `obj`, it will be created and then deleted at the end of the block. The old value (or None if it doesn't exist) will be assigned to the target of the "as" clause, if there is one. N(RRgRtdelattr(RpRftnew_valtreal_val((s-/usr/lib64/python2.7/test/support/__init__.pyt swap_attr)s  ccsk||kr:||}|||rsN(ttobytesRhRt TypeErrortbytes(tb((s-/usr/lib64/python2.7/test/support/__init__.pyR5gs  t getcountss-types are immortal if COUNT_ALLOCS is definedcCsddl}|jS(sZReturn a list of command-line arguments reproducing the current settings in sys.flags.iN(t subprocesst_args_from_interpreter_flags(Rc((s-/usr/lib64/python2.7/test/support/__init__.pytargs_from_interpreter_flagsys cCstjdd|j}|S(sStrip the stderr of a Python process from potential debug output emitted by the interpreter. This will typically be run on the result of the communicate() method of a subprocess.Popen object. s\[\d+ refs\]\r?\n?$R(Rstsubtstrip(R((s-/usr/lib64/python2.7/test/support/__init__.pyR8scsid|ffdY}tg||||jttt|jddS(NtAcseZfdZRS(cs0tdRYRRRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR;s  GcCs*ddl}t|jWdQXdS(sDeliberate crash of Python. Python can be killed by a segmentation fault (SIGSEGV), a bus error (SIGBUS), or a different error depending on the platform. Use SuppressCrashReport() to prevent a crash report from popping up. iN(RR;t _read_null(R((s-/usr/lib64/python2.7/test/support/__init__.pyt _crash_pythons  c Cstjjd rdy!tjd}t|dSWqdtk r`}|jtjkraqaqdXnd}t tdrytj d}Wqtk rqXnd }tjdkr+yd d l }|j Wnttfk rq+Xi}x9|j|j|jfD]}|j |d ||RcRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR_s ((ii@i@i@ii(i@ii(((((R>R<RFt contextlibRR/RRRRwRNRuRRR@RGREtUserDictRsRRRxRjR@RYt__all__t SHORT_TIMEOUTRRRRRHRtcontextmanagerRVRDRXRRUR[R6R4RRRRRRrRR R R}RRRRRRR RR R RRRRRRRRRRRR9R RRt PIPE_MAX_SIZEt SOCK_MAX_SIZERRRt NameErrort skipUnlesstrequires_unicodeRt FS_NONASCIItunichrt characterR$R%tdecodet UnicodeErrorRJRRitTESTFN_UNICODEtTESTFN_ENCODINGRRtTESTFN_UNENCODABLEtevalR&RR(t TEST_HTTP_URLR-RR,R0RRyRtabspatht__file__tTEST_SUPPORT_DIRR6RRXRRRDRRtobjectR^RRR R!t DictMixinR"RR%R&R#R$RRRRRRRRRRR'R:RRRt_4GRRR(R)RR*R+RRR2RR R3RR R!R,R#R&R3R,RytHAVE_DOCSTRINGStrequires_docstringsR-tenvironment_alteredR.R/R0RJR7R1RYR[R5tskipIftrequires_type_collectingReR8RqRvR}R;RRR(((s-/usr/lib64/python2.7/test/support/__init__.pyts                                    &      !         J  < $                               .    * ' /D         $ "     '       (    &  #       e  d?d@g=ZdAZdefdBYZdefdCYZdefdDYZdejfdEYZ ej!e"dFZ#e$dGZ%dHZ&dIZ'dde$dJZ(dKZ)dLZ*dZ+dMa,dMa-e$Z.da/dNZ0dOZ1dPZ2dQZ3e j j4dRr+e$dSZ5dTZ6dUZ7dVZ8ne j9Z6e j:Z7dWZ8dXZ9dYZ:dZZ;d[Z<d\Z=d]Z>dd^Z?d_Z@d`ZAdaZBejCejDdbZEeAdcZFddZGeGZHdeZIdfZJdgZKdZLdZMe j j4dkZNyeOe"ZPWneQk r-e$ZPnXejRePdlZSdmZTdZUePrxeVdneVdoeVdpeVdqeVdreVdseVdteVdueVdveVdweVdxf D]XZWy7eWjXe jYjZe jYeWkre[nWne[k rqXeWZUPqWne j\dkkr6dyZ]ne j\dzkrNd{Z]nd|Z]ePre^d}eOrrd~Z_neOd~dZ_e jYZ`eae d se jbddkrdZcqeddZcyecjXdWneek rqXdecGHndjfe]e jgZ]dZhe jiZjej!de$dZkej!e$dZlej!de$dZme jnjoe jnjpeqZre jnjoerZse jnjtesdZuddZvdZwdZxd}dddZyddZzde{fdYZ|e$dZ}ej!dZ~ej!dZd&e{fdYZd'ejfdYZde{fdYZd*e{fdYZej!dAddZej!dZdZdZdZdZdZeae drdeZnedZdZdZdZdZdZdZdZdZdieZdeZdheZe jZdZdedZdee"dZdZd0ddYZdZdZdZddZdZdZdZdZdadadZdZdZdZede$pW e j dkpW ejdZejRedZddZe$ZdZdZdZej!ddZdZej!ddZej!dZej!dZdZejeae ddZdZdZddZej!dZdZd@ddYZdZdZdddYZdS(s7Supporting definitions for the Python regression tests.s test.supports3test.support must be imported from the test packageiNtErrort TestFailedt TestDidNotRuntResourceDeniedt import_moduletverboset use_resourcest max_memusetrecord_original_stdouttget_original_stdouttunloadtunlinktrmtreetforgettis_resource_enabledtrequirestrequires_mac_vertfind_unused_portt bind_porttfcmpt have_unicodet is_jythontTESTFNtHOSTtFUZZtSAVEDCWDttemp_cwdtfindfiletsortdicttcheck_syntax_errortopen_urlresourcetcheck_warningstcheck_py3k_warningst CleanImporttEnvironmentVarGuardtcaptured_outputtcaptured_stdouttTransientResourcettransient_internettrun_with_localet set_memlimitt bigmemtesttbigaddrspacetesttBasicTestRunnert run_unittestt run_doctesttthreading_setuptthreading_cleanupt reap_threadst start_threadst cpython_onlytcheck_impl_detailt get_attributet py3k_bytestimport_fresh_modulet reap_childrentstrip_python_stderrt IPV6_ENABLEDt run_with_tztSuppressCrashReportg>@cBseZdZRS(s*Base class for regression test exceptions.(t__name__t __module__t__doc__(((s-/usr/lib64/python2.7/test/support/__init__.pyR4scBseZdZRS(s Test failed.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR7scBseZdZRS(sTest did not run any subtests.(R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR:scBseZdZRS(sTest skipped because it requested a disallowed resource. This is raised when a test calls requires() for a resource that has not been enabled. It is used to distinguish between expected and unexpected skips. (R<R=R>(((s-/usr/lib64/python2.7/test/support/__init__.pyR=sccs=|r4tjtjddtdVWdQXndVdS(sContext manager to suppress package and module deprecation warnings when importing them. If ignore is False, this context manager has no effect.tignores.+ (module|package)N(twarningstcatch_warningstfilterwarningstDeprecationWarning(R?((s-/usr/lib64/python2.7/test/support/__init__.pyt_ignore_deprecated_importsEs   c CsSt|Aytj|SWn(tk rH}tjt|nXWdQXdS(sImport and return the module to be tested, raising SkipTest if it is not available. If deprecated is True, any module or package deprecation messages will be suppressed.N(RDt importlibRt ImportErrortunittesttSkipTesttstr(tnamet deprecatedtmsg((s-/usr/lib64/python2.7/test/support/__init__.pyRTs  cCs|tjkr&t|tj|=nxTttjD]C}||ks[|j|dr6tj|||t|t rd|j|f}ndt |j|f}t j |nX|SdS(s?Get an attribute, raising SkipTest if AttributeError is raised.smodule %r has no attribute %rsclass %s has no attribute %rs%s instance has no attribute %rs"type object %r has no attribute %rs%r object has no attribute %rN( tgetattrtAttributeErrort isinstancettypest ModuleTypeR<t ClassTypet InstanceTypet __class__ttypeRGRH(tobjRJt attributeRL((s-/usr/lib64/python2.7/test/support/__init__.pyR4s iicCs |adS(N(t_original_stdout(tstdout((s-/usr/lib64/python2.7/test/support/__init__.pyRscCs tp tjS(N(RrRNRs(((s-/usr/lib64/python2.7/test/support/__init__.pyR scCs&ytj|=Wntk r!nXdS(N(RNRORW(RJ((s-/usr/lib64/python2.7/test/support/__init__.pyR s cGsxy||SWnctk rs}tdkrVd|jj|fGHd|j|fGHntj|tj||SXdS(Nis%s: %ss re-run %s%r(tEnvironmentErrorRRnR<tostchmodtstattS_IRWXU(tpathtfunctargsterr((s-/usr/lib64/python2.7/test/support/__init__.pyt _force_runs twincCs|||r|}n$tjj|\}}|p:d}d}xR|dkrtj|}|rm|n ||ks}dStj||d9}qFWtjd|tdddS(NRMgMbP?g?is)tests may fail, delete still pending for t stackleveli( RuRytsplittlistdirttimetsleepR@twarntRuntimeWarning(RztpathnametwaitalltdirnameRJttimeouttL((s-/usr/lib64/python2.7/test/support/__init__.pyt_waitfors     cCsttj|dS(N(RRuR (tfilename((s-/usr/lib64/python2.7/test/support/__init__.pyt_unlinkscCsttj|dS(N(RRutrmdir(R((s-/usr/lib64/python2.7/test/support/__init__.pyt_rmdirscs6fdt|dttd|dS(Ncsxt|tj|D]i}tjj||}tjj|rlt|dtt|tj|qt|tj |qWdS(NR( R}RuRRytjointisdirRRVRR (RyRJtfullname(t _rmtree_inner(s-/usr/lib64/python2.7/test/support/__init__.pyRs RcSst|tj|S(N(R}RuR(tp((s-/usr/lib64/python2.7/test/support/__init__.pyt t(RRV(Ry((Rs-/usr/lib64/python2.7/test/support/__init__.pyt_rmtreescsSytj|dSWntk r(nXfd|tj|dS(Ncsxt|tj|D]}tjj||}ytj|j}Wntk r`d}nXtj |r|t|tj |qt|tj |qWdS(Ni( R}RuRRyRtlstattst_modeRtRwtS_ISDIRRR (RyRJRtmode(R(s-/usr/lib64/python2.7/test/support/__init__.pyRs   (tshutilR RtRuR(Ry((Rs-/usr/lib64/python2.7/test/support/__init__.pyRs   cCsIyt|Wn4tk rD}|jtjtjfkrEqEnXdS(N(RtOSErrorterrnotENOENTtENOTDIR(Rtexc((s-/usr/lib64/python2.7/test/support/__init__.pyR $s cCs@yt|Wn+tk r;}|jtjkr<q<nXdS(N(RRRR(Rterror((s-/usr/lib64/python2.7/test/support/__init__.pyR+s cCsIyt|Wn4tk rD}|jtjtjfkrEqEnXdS(N(RRRRtESRCH(Ryte((s-/usr/lib64/python2.7/test/support/__init__.pyR 3s cCsjt|xYtjD]N}ttjj||tjdttjj||tjdqWdS(sm"Forget" a module was ever imported by removing it from sys.modules and deleting any .pyc and .pyo files.tpyctpyoN(R RNRyR RuRtextsep(RTR((s-/usr/lib64/python2.7/test/support/__init__.pyR ;s $csttdrtjSd}tjjdr ddlddld}d}dj ffdY}j j }|j }|sj n|}jj}|j||j|j|j|}|sj nt|j|@sd}qntjdkrdd lm} mm} m } dd lm} | j| d } | jd krd }qd| ffdY}|}| |}| j|d ks| j|d krd}qn|sy;ddlm}|}|j |j!|j"Wqt#k r}t$|}t%|dkrz|d d}ndj&t'|j(|}qXn|t_)| t_tjS(NtresultR~iitUSEROBJECTFLAGScs;eZdjjfdjjfdjjfgZRS(tfInheritt fReservedtdwFlags(R<R=twintypestBOOLtDWORDt_fields_((tctypes(s-/usr/lib64/python2.7/test/support/__init__.pyRRss,gui not available (WSF_VISIBLE flag not set)tdarwin(tcdlltc_inttpointert Structure(t find_librarytApplicationServicesis0gui tests cannot run without OS X window managertProcessSerialNumbercs eZdfdfgZRS(t highLongOfPSNt lowLongOfPSN(R<R=R((R(s-/usr/lib64/python2.7/test/support/__init__.pyRts s#cannot run without OS X gui process(tTki2s [...]sTk unavailable due to {}: {}(*thasattrt_is_gui_availableRRYRNtplatformRRRtctypes.wintypesRtwindlltuser32tGetProcessWindowStationtWinErrorRRtGetUserObjectInformationWtbyreftsizeoftboolRRRRt ctypes.utilRt LoadLibrarytCGMainDisplayIDtGetCurrentProcesstSetFrontProcesstTkinterRtwithdrawtupdatetdestroyt ExceptionRItlentformatRoR<treason(Rt UOI_FLAGSt WSF_VISIBLERtdllthtuoftneededtresRRRRt app_servicesRtpsntpsn_pRtrootRt err_string((RRs-/usr/lib64/python2.7/test/support/__init__.pyRGsh         "          cCstdkp|tkS(sTest whether a resource is enabled. Known resources are set by regrtest.py. If not running under regrtest.py, all resources are assumed enabled unless use_resources has been set. N(RRY(tresource((s-/usr/lib64/python2.7/test/support/__init__.pyRscCs`t|s4|dkr%d|}nt|n|dkr\t r\ttjndS(s@Raise ResourceDenied if the specified resource is not available.s$Use of the `%s' resource not enabledtguiN(RRYRRR(RRL((s-/usr/lib64/python2.7/test/support/__init__.pyRs    csfd}|S(sDecorator raising SkipTest if the OS is Mac OS X and the OS X version if less than min_version. For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version is lesser than 10.5. cs.tjfd}|_|S(Ncstjdkrtjd}y"ttt|jd}Wntk rTqX|krdjtt }t j d||fqn||S(NRiRMs&Mac OS X %s or higher required, not %s( RNRtmac_verttupletmaptintRt ValueErrorRRIRGRH(R{tkwt version_txttversiontmin_version_txt(Rzt min_version(s-/usr/lib64/python2.7/test/support/__init__.pytwrappers"  (t functoolstwrapsR(RzR(R(Rzs-/usr/lib64/python2.7/test/support/__init__.pyt decorators! ((RR((Rs-/usr/lib64/python2.7/test/support/__init__.pyRss 127.0.0.1s::1cCs/tj||}t|}|j~|S(s Returns an unused port that should be suitable for binding. This is achieved by creating a temporary socket with the same family and type as the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to the specified host address (defaults to 0.0.0.0) with the port set to 0, eliciting an unused ephemeral port from the OS. The temporary socket is then closed and deleted, and the ephemeral port is returned. Either this method or bind_port() should be used for any tests where a server socket needs to be bound to a particular port for the duration of the test. Which one to use depends on whether the calling code is creating a python socket, or if an unused port needs to be provided in a constructor or passed to an external program (i.e. the -accept argument to openssl's s_server mode). Always prefer bind_port() over find_unused_port() where possible. Hard coded ports should *NEVER* be used. As soon as a server socket is bound to a hard coded port, the ability to run multiple instances of the test simultaneously on the same host is compromised, which makes the test a ticking time bomb in a buildbot environment. On Unix buildbots, this may simply manifest as a failed test, which can be recovered from without intervention in most cases, but on Windows, the entire python process can completely and utterly wedge, requiring someone to log in to the buildbot and manually kill the affected process. (This is easy to reproduce on Windows, unfortunately, and can be traced to the SO_REUSEADDR socket option having different semantics on Windows versus Unix/Linux. On Unix, you can't have two AF_INET SOCK_STREAM sockets bind, listen and then accept connections on identical host/ports. An EADDRINUSE socket.error will be raised at some point (depending on the platform and the order bind and listen were called on each socket). However, on Windows, if SO_REUSEADDR is set on the sockets, no EADDRINUSE will ever be raised when attempting to bind two identical host/ports. When accept() is called on each socket, the second caller's process will steal the port from the first caller, leaving them both in an awkwardly wedged state where they'll no longer respond to any signals or graceful kills, and must be forcibly killed via OpenProcess()/TerminateProcess(). The solution on Windows is to use the SO_EXCLUSIVEADDRUSE socket option instead of SO_REUSEADDR, which effectively affords the same semantics as SO_REUSEADDR on Unix. Given the propensity of Unix developers in the Open Source world compared to Windows ones, this is a common mistake. A quick look over OpenSSL's 0.9.8g source shows that they use SO_REUSEADDR when openssl.exe is called with the 's_server' option, for example. See http://bugs.python.org/issue2550 for more info. The following site also has a very thorough description about the implications of both REUSEADDR and EXCLUSIVEADDRUSE on Windows: http://msdn2.microsoft.com/en-us/library/ms740621(VS.85).aspx) XXX: although this approach is a vast improvement on previous attempts to elicit unused ports, it rests heavily on the assumption that the ephemeral port returned to us by the OS won't immediately be dished back out to some other process when we close and delete our temporary socket but before our calling code has a chance to bind the returned port. We can deal with this issue if/when we come across it.(tsocketRtclose(tfamilytsocktypettempsocktport((s-/usr/lib64/python2.7/test/support/__init__.pyRs 6  cCs|jtjkr|jtjkrttdrc|jtjtjdkrct dqcnttdry1|jtjtj dkrt dnWqt k rqXnttdr|j tjtj dqn|j|df|jd}|S(s%Bind the socket to a free port and return the port number. Relies on ephemeral ports in order to ensure we are using an unbound port. This is important as many tests may be running simultaneously, especially in a buildbot environment. This method raises an exception if the sock.family is AF_INET and sock.type is SOCK_STREAM, *and* the socket has SO_REUSEADDR or SO_REUSEPORT set on it. Tests should *never* set these socket options for TCP/IP sockets. The only case for setting these options is testing multicasting via multiple UDP sockets. Additionally, if the SO_EXCLUSIVEADDRUSE socket option is available (i.e. on Windows), it will be set on the socket. This will prevent anyone else from bind()'ing to our host/port for the duration of the test. t SO_REUSEADDRisHtests should never set the SO_REUSEADDR socket option on TCP/IP sockets!t SO_REUSEPORTsHtests should never set the SO_REUSEPORT socket option on TCP/IP sockets!tSO_EXCLUSIVEADDRUSEi(RRtAF_INETRot SOCK_STREAMRt getsockoptt SOL_SOCKETRRRRtt setsockoptRtbindt getsockname(tsockthostR((s-/usr/lib64/python2.7/test/support/__init__.pyRs$ cCs{tjrwd}zNy3tjtjtj}|jtdftSWntjk r[nXWd|rs|j nXnt S(s+Check whether IPv6 is enabled on this host.iN( Rthas_ipv6RYtAF_INET6RRtHOSTv6RVRRRX(R((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_ipv6_enabled$s cs"tjfd}|S(s5Skip the test on TLS certificate validation failures.csRy||Wn:tk rM}dt|krGtjdnnXdS(NtCERTIFICATE_VERIFY_FAILEDs.system does not contain necessary certificates(tIOErrorRIRGRH(R{tkwargsR(tf(s-/usr/lib64/python2.7/test/support/__init__.pytdec7s (RR(R R ((R s-/usr/lib64/python2.7/test/support/__init__.pytsystem_must_validate_cert5s gư>cCs#t|tst|trcy8t|t|t}t|||krUdSWqqXnt|t|krt|ttfrxPttt |t |D]-}t ||||}|dkr|SqWt |t |kt |t |kS||k||kS(Ni( RitfloattabsRRoRRQtrangetminRR(txtytfuzztitoutcome((s-/usr/lib64/python2.7/test/support/__init__.pyRDs-( ,iiitjavasno unicode supportcCs t|dS(Nsunicode-escape(tunicode(ts((s-/usr/lib64/python2.7/test/support/__init__.pytumsii0iAiiii i*iii s$testtriscosttestfiles@testRs@test-slatin-1tgetwindowsversioniis'u"@test-\u5171\u6709\u3055\u308c\u308b"tLatin1sgWARNING: The filename %r CAN be encoded by the filesystem. Unicode filename tests may not be effectives {}_{}_tmpshttp://www.pythontest.netccsQt}|dkrEddl}|j}t}tjj|}ntrt |t rtjj ry|j t jpd}Wqtk r|stjdqqXnytj|t}Wn7tk r|sntjd|tddnX|rtj}nz |VWd|rL|tjkrLt|nXdS(sReturn a context manager that creates a temporary directory. Arguments: path: the directory to create temporarily. If omitted or None, defaults to creating a temporary directory using tempfile.mkdtemp. quiet: if False (the default), the context manager raises an exception on error. Otherwise, if the path is specified and cannot be created, only a warning is issued. iNtasciis;unable to encode the cwd name with the filesystem encoding.s+tests may fail, unable to create temp dir: Ri(RXRYttempfiletmkdtempRVRuRytrealpathRRiRtsupports_unicode_filenamestencodeRNtgetfilesystemencodingtUnicodeEncodeErrorRGRHtmkdirRR@RRtgetpidR (Rytquiett dir_createdR tpid((s-/usr/lib64/python2.7/test/support/__init__.pyttemp_dirs6          ccs{tj}ytj|Wn7tk rV|s9ntjd|tddnXztjVWdtj|XdS(sgReturn a context manager that changes the current working directory. Arguments: path: the directory to use as the temporary current working directory. quiet: if False (the default), the context manager raises an exception on error. Otherwise, it issues only a warning and keeps the current working directory the same. s)tests may fail, unable to change CWD to: RiN(RutgetcwdtchdirRR@RR(RyR)t saved_dir((s-/usr/lib64/python2.7/test/support/__init__.pyt change_cwd s   ttempcwdc csBtd|d|'}t|d| }|VWdQXWdQXdS(s Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkdtemp. If *quiet* is False (default) and it is not possible to create or change the CWD, an error is raised. If *quiet* is True, only a warning is raised and the original CWD is used. RyR)N(R,R0(RJR)t temp_pathtcwd_dir((s-/usr/lib64/python2.7/test/support/__init__.pyR&stdatacCstjj|r|S|dk r:tjj||}ntgtj}x9|D]1}tjj||}tjj|rQ|SqQW|S(sTry to find a file on sys.path and the working directory. If it is not found the argument passed to the function is returned (this does not necessarily signal failure; could still be the legitimate path).N(RuRytisabsRYRt TEST_HOME_DIRRNtexists(tfiletsubdirRytdntfn((s-/usr/lib64/python2.7/test/support/__init__.pyRAs  cCsJ|j}|jg|D]}d|^q}dj|}d|S(s%Like repr(dict), but in sorted order.s%r: %rs, s{%s}(R]tsortR(tdictR]tpairt reprpairst withcommas((s-/usr/lib64/python2.7/test/support/__init__.pyROs   cCs9ttd}z|jSWd|jttXdS(s` Create an invalid file descriptor by opening and closing a file and return its fd. twbN(topenRtfilenoRR (R8((s-/usr/lib64/python2.7/test/support/__init__.pyt make_bad_fdWs  cCs||jt|}t|ddWdQX|j}|dk rV|j|j|n|dk rx|j|j|ndS(Ns texec(tassertRaisesRegexpt SyntaxErrortcompilet exceptionRYt assertEqualtlinenotoffset(ttestcaset statementterrtextRKRLtcmR|((s-/usr/lib64/python2.7/test/support/__init__.pyRcs   c sSddl}ddl}|j|djdd}tjjt|}fd}tjj|r||}|dk r|St |nt dt d|IJ|j |dd}zNt |d 9}|j} x#| r |j| |j} qWWdQXWd|jX||}|dk r?|Std |dS( Niit/csGt|}dkr|S|r9|jd|S|jdS(Ni(RBRYtseekR(R;R (tcheck(s-/usr/lib64/python2.7/test/support/__init__.pytcheck_valid_filess    turlfetchs fetching %s ...RiRAsinvalid resource "%s"(turlparseturllib2RRuRyRt TEST_DATA_DIRR7RYR RR turlopenRBtreadtwriteRR( turlRSRVRWRR;RTR toutR((RSs-/usr/lib64/python2.7/test/support/__init__.pyRls.            tWarningsRecordercBs8eZdZdZdZedZdZRS(syConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. cCs||_d|_dS(Ni(t _warningst_last(tselft warnings_list((s-/usr/lib64/python2.7/test/support/__init__.pyt__init__s cCs\t|j|jkr,t|jd|S|tjjkrBdStd||fdS(Nis%r has no attribute %r( RR_R`RgR@tWarningMessaget_WARNING_DETAILSRYRh(Ratattr((s-/usr/lib64/python2.7/test/support/__init__.pyt __getattr__s cCs|j|jS(N(R_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyR@scCst|j|_dS(N(RR_R`(Ra((s-/usr/lib64/python2.7/test/support/__init__.pytresets(R<R=R>RcRgtpropertyR@Rh(((s-/usr/lib64/python2.7/test/support/__init__.pyR^s   c csptjd}|jjd}|r4|jntjdt&}tjdj dt |VWdQXg|D]}|j ^qu}g}x|D]\}} t } x[|D]R} t | } tj|| tjrt| j| rt} |j| qqW| r| r|j|| jfqqW|rOtd|dn|rltd |dndS( sCatch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. it__warningregistry__trecordR@talwaysNsunhandled warning %ris)filter (%r, %s) did not catch any warning(RNt _getframet f_globalstgettclearR@RARVROt simplefilterR^tmessageRXRItretmatchtIt issubclassRntremoveR\R<tAssertionError( tfiltersR)tframetregistrytwtwarningtreraisetmissingRLtcattseenRRr((s-/usr/lib64/python2.7/test/support/__init__.pyt_filterwarningss0  cOsI|jd}|s<dtff}|dkr<t}q<nt||S(sContext manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filters are defined) Without argument, it defaults to: check_warnings(("", Warning), quiet=True) R)RN(RotWarningRYRVR(RyR R)((s-/usr/lib64/python2.7/test/support/__init__.pyRs   cOs@tjr$|s*dtff}q*nd}t||jdS(sjContext manager to silence py3k warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default False) Without argument, it defaults to: check_py3k_warnings(("", DeprecationWarning), quiet=False) RR)((RNt py3kwarningRCRRo(RyR ((s-/usr/lib64/python2.7/test/support/__init__.pyR s  cBs)eZdZdZdZdZRS(s,Context manager to force import to return a new module reference. This is useful for testing module-level behaviours, such as the emission of a DeprecationWarning on import. Use like this: with CleanImport("foo"): importlib.import_module("foo") # new reference cGsotjj|_xV|D]N}|tjkrtj|}|j|krZtj|j=ntj|=qqWdS(N(RNROtcopytoriginal_modulesR<(Rat module_namest module_nameRe((s-/usr/lib64/python2.7/test/support/__init__.pyRcs  cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyt __enter__scGstjj|jdS(N(RNRORR(Rat ignore_exc((s-/usr/lib64/python2.7/test/support/__init__.pyt__exit__s(R<R=R>RcRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR!s  cBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( s_Class to help protect the environment variable properly. Can be used as a context manager.cCstj|_i|_dS(N(Rutenviront_environt_changed(Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRc(s cCs |j|S(N(R(Ratenvvar((s-/usr/lib64/python2.7/test/support/__init__.pyt __getitem__,scCs<||jkr+|jj||j|RcRRRRRRRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR"#s        t DirsOnSysPathcBs)eZdZdZdZdZRS(sContext manager to temporarily add directories to sys.path. This makes a copy of sys.path, appends any directories given as positional arguments, then reverts sys.path to the copied settings when the context ends. Note that *all* sys.path modifications in the body of the context manager, including replacement of the object, will be reverted at the end of the block. cGs-tj|_tj|_tjj|dS(N(RNRytoriginal_valuetoriginal_objecttextend(Ratpaths((s-/usr/lib64/python2.7/test/support/__init__.pyRc^s  cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRcscGs|jt_|jtj(dS(N(RRNRyR(RaR((s-/usr/lib64/python2.7/test/support/__init__.pyRfs (R<R=R>RcRR(((s-/usr/lib64/python2.7/test/support/__init__.pyRRs   cBs2eZdZdZdZddddZRS(sRaise ResourceDenied if an exception is raised while the context manager is in effect that matches the specified exception and attributes.cKs||_||_dS(N(Rtattrs(RaRR ((s-/usr/lib64/python2.7/test/support/__init__.pyRcps cCs|S(N((Ra((s-/usr/lib64/python2.7/test/support/__init__.pyRtscCs}|dk ryt|j|ryxX|jjD]8\}}t||sMPnt|||kr.Pq.q.WtdndS(sIf type_ is a subclass of self.exc and value has attributes matching self.attrs, raise ResourceDenied. Otherwise let the exception propagate (if any).s%an optional resource is not availableN(RYRvRRt iteritemsRRgR(Rattype_Rt tracebackRft attr_value((s-/usr/lib64/python2.7/test/support/__init__.pyRwsN(R<R=R>RcRRYR(((s-/usr/lib64/python2.7/test/support/__init__.pyR%ks  c #sdddd d!d"g}d#d$d%d&d'g}td||gsg|D]\}}tt||^qVg|D]\}}tt||^qnfd}tj}zy%|dk rtj|ndVWntk r} xxtr}| j } t | dkrGt | dtrG| d} qt | dkryt | dtry| d} qPqW|| nXWdtj|XdS((sReturn a context manager that raises ResourceDenied when various issues with the Internet connection manifest themselves as exceptions.t ECONNREFUSEDiot ECONNRESETiht EHOSTUNREACHiqt ENETUNREACHiet ETIMEDOUTint EADDRNOTAVAILict EAI_AGAINitEAI_FAILit EAI_NONAMEit EAI_NODATAit WSANO_DATAi*sResource '%s' is not availablecst|dd}t|tjsNt|tjrB|ksN|kr{tsrtjj j ddnndS(NRis ( RgRYRiRRtgaierrorRRNtstderrR[R{(R|tn(tcaptured_errnostdeniedt gai_errnos(s-/usr/lib64/python2.7/test/support/__init__.pyt filter_errors Niii(Rio(Rih(Riq(Rie(Rin(Ric(Ri(Ri(Ri(Ri(Ri*( RRgRRtgetdefaulttimeoutRYtsetdefaulttimeoutR RVR{RRi( t resource_nameRterrnostdefault_errnostdefault_gai_errnosRJtnumRt old_timeoutR|ta((RRRs-/usr/lib64/python2.7/test/support/__init__.pyR&sJ  (+     % %   ccs[ddl}tt|}tt||jztt|VWdtt||XdS(sReturn a context manager used by captured_stdout and captured_stdin that temporarily replaces the sys stream *stream_name* with a StringIO.iN(tStringIORgRNtsetattr(t stream_nameRt orig_stdout((s-/usr/lib64/python2.7/test/support/__init__.pyR#s  cCs tdS(sCapture the output of sys.stdout: with captured_stdout() as s: print "hello" self.assertEqual(s.getvalue(), "hello") Rs(R#(((s-/usr/lib64/python2.7/test/support/__init__.pyR$scCs tdS(NR(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stderrscCs tdS(Ntstdin(R#(((s-/usr/lib64/python2.7/test/support/__init__.pytcaptured_stdinscCs8tjtr tjdntjtjdS(sForce as many objects as possible to be collected. In non-CPython implementations of Python, this is needed because timely deallocation is not guaranteed by the garbage collector. (Even in CPython this can be the case in case of reference cycles.) This means that __del__ methods may be called later than expected and weakrefs may remain alive for longer than expected. This function tries its best to force all garbage objects to disappear. g?N(tgctcollectRRR(((s-/usr/lib64/python2.7/test/support/__init__.pyt gc_collects  t2PtgettotalrefcounttPcCstjt|dS(Nt0P(tstructtcalcsizet_header(tfmt((s-/usr/lib64/python2.7/test/support/__init__.pyt calcobjsizescCstjt|dS(NR(RRt_vheader(R((s-/usr/lib64/python2.7/test/support/__init__.pyt calcvobjsizesii cCsddl}tj|}t|tkr:|jt@s_t|tkrot|jt@ro||j7}ndt|||f}|j|||dS(Nis&wrong size for %s: got %d, expected %d( t _testcapiRNt getsizeofRot __flags__t_TPFLAGS_HEAPTYPEt_TPFLAGS_HAVE_GCtSIZEOF_PYGC_HEADRJ(ttesttotsizeRRRL((s-/usr/lib64/python2.7/test/support/__init__.pyt check_sizeofs %csfd}|S(Ncs1fd}j|_j|_|S(Ncsy.ddl}t|}|j|}Wn$tk rDnAd}}n1Xx-D]%}y|j||PWq\q\Xq\Wz||SWd|r|r|j||nXdS(Ni(tlocaleRgt setlocaleRhRY(R{tkwdsRtcategoryt orig_localetloc(tcatstrRztlocales(s-/usr/lib64/python2.7/test/support/__init__.pytinners$    (t func_nameR>(RzR(RR(Rzs-/usr/lib64/python2.7/test/support/__init__.pyRs  ((RRR((RRs-/usr/lib64/python2.7/test/support/__init__.pyR'scsfd}|S(Ncs.fd}j|_j|_|S(Ncsy tj}Wn tk r/tjdnXdtjkrOtjd}nd}tjd<|z||SWd|dkrtjd=n |tjd(RzR(R(Rzs-/usr/lib64/python2.7/test/support/__init__.pyR:s  ((RR((Rs-/usr/lib64/python2.7/test/support/__init__.pyR:9scCsidd6td6td6dtd6}tjd|tjtjB}|dkrgtd|fntt |j d||j d j }|a |t krt }n|tdkrtd |fn|adS( NiRtmtgtts(\d+(\.\d+)?) (K|M|G|T)b?$sInvalid memory limit %riis$Memory limit %r too low to be useful(t_1Mt_1GRsRtt IGNORECASEtVERBOSERYRRRtgrouptlowertreal_max_memusetMAX_Py_ssize_tt_2GR(tlimittsizesRtmemlimit((s-/usr/lib64/python2.7/test/support/__init__.pyR(bs   2  icsfd}|S(sQDecorator for bigmem tests. 'minsize' is the minimum useful size for the test (in arbitrary, test-interpreted units.) 'memuse' is the number of 'bytes per size' for the test, or a good estimate of it. 'overhead' specifies fixed overhead, independent of the testsize, and defaults to 5Mb. The decorator tries to guess a good value for 'size' and passes it to the decorated test function. If minsize * memuse is more than the allowed memory use (as defined by max_memuse), the test is skipped. Otherwise, minsize is adjusted upward to use up to max_memuse. cs7fd}|_|_|_|S(Ncsts.d}|j|dtkn^tt}|krutrqtjjdjfndSt |dt}||S(Niis)Skipping %s because of memory constraint i2( Rt assertFalseRRRRNRR[R<tmax(Ratmaxsize(R tmemusetminsizetoverhead(s-/usr/lib64/python2.7/test/support/__init__.pyRs"  (RRR(R R(RRR(R s-/usr/lib64/python2.7/test/support/__init__.pyRs    ((RRRR((RRRs-/usr/lib64/python2.7/test/support/__init__.pyR)ws csfd}|S(Ncs7fd}|_|_|_|S(Ncsftsd}n}ts" rYt|krYtrUtjjdjfndS||S(Nis)Skipping %s because of memory constraint (RRRNRR[R<(RaR(tdry_runR RR(s-/usr/lib64/python2.7/test/support/__init__.pyRs   (RRR(R R(RRRR(R s-/usr/lib64/python2.7/test/support/__init__.pyRs    ((RRRRR((RRRRs-/usr/lib64/python2.7/test/support/__init__.pytprecisionbigmemtestscsfd}|S(s0Decorator for tests that fill the address space.cs@ttkr2tr<tjjdjfq<n |SdS(Ns)Skipping %s because of memory constraint (RRRRNRR[R<(Ra(R (s-/usr/lib64/python2.7/test/support/__init__.pyRs   ((R R((R s-/usr/lib64/python2.7/test/support/__init__.pyR*scBseZdZRS(cCstj}|||S(N(RGt TestResult(RaRR((s-/usr/lib64/python2.7/test/support/__init__.pytruns  (R<R=R(((s-/usr/lib64/python2.7/test/support/__init__.pyR+scCs|S(N((Rp((s-/usr/lib64/python2.7/test/support/__init__.pyt_idscCsP|dkr&t r&tjtjSt|r6tStjdj|SdS(NRsresource {0!r} is not enabled(RRGtskipRRRR(R((s-/usr/lib64/python2.7/test/support/__init__.pytrequires_resources  cCstdt|S(s9 Decorator for tests only applicable on CPython. tcpython(t impl_detailRV(R((s-/usr/lib64/python2.7/test/support/__init__.pyR2scKs}t|rtS|dkrpt|\}}|r=d}nd}t|j}|jdj|}ntj |S(Ns*implementation detail not available on {0}s%implementation detail specific to {0}s or ( R3RRYt _parse_guardstsortedRRRRGR(RLtguardst guardnamestdefault((s-/usr/lib64/python2.7/test/support/__init__.pyRs   cCs2|sitd6tfS|jd}|| fS(NRi(RVRXtvalues(R tis_true((s-/usr/lib64/python2.7/test/support/__init__.pyR scKs.t|\}}|jtjj|S(s5This function returns True or False depending on the host platform. Examples: if check_impl_detail(): # only on CPython (default) if check_impl_detail(jython=True): # only on Jython if check_impl_detail(cpython=False): # everywhere except on CPython (R RoRtpython_implementationR(R R ((s-/usr/lib64/python2.7/test/support/__init__.pyR3scCsrg}x\|jD]Q}t|tjrEt|||j|q||r|j|qqW||_dS(s>Recursively filter test cases in a suite based on a predicate.N(t_testsRiRGt TestSuitet _filter_suiteR\(tsuitetpredtnewtestsR((s-/usr/lib64/python2.7/test/support/__init__.pyRs  cCstr'tjtjdddt}n t}|j|}|j r\|j r\t n|j st |j dkr|j r|j dd}nLt |jdkr|j r|jdd}nd}ts|d7}nt|ndS( s2Run tests from a unittest.TestSuite-derived class.t verbosityitfailfastiismultiple errors occurreds!; run in verbose mode for detailsN(RRGtTextTestRunnerRNRsRR+RttestsRuntskippedRt wasSuccessfulRterrorstfailuresR(RtrunnerRR|((s-/usr/lib64/python2.7/test/support/__init__.pyt _run_suites      cCs$tdkrtSt|jSdS(N(t_match_test_funcRYRVtid(R((s-/usr/lib64/python2.7/test/support/__init__.pyt match_test#s cCsd|kotjd| S(NRMs[?*\[\]](Rstsearch(tpattern((s-/usr/lib64/python2.7/test/support/__init__.pyt_is_full_match_test+scs|tkrdS|s%d}d}nittt|rLt|j}nBdjttj |}t j |j fd}|}t |a|adS(Nt|cs0|rtStt|jdSdS(NRM(RVtanyRR(ttest_id(t regex_match(s-/usr/lib64/python2.7/test/support/__init__.pytmatch_test_regexJs ((t_match_test_patternsRYtallRR&Rt __contains__Rtfnmatcht translateRsRHRtRR!(tpatternsRztregexR+((R*s-/usr/lib64/python2.7/test/support/__init__.pytset_match_tests5s    cGstjtjf}tj}x|D]}t|trx|tjkri|jtjtj|qt dq%t||r|j|q%|jtj |q%Wt |t t |dS(s1Run tests from unittest.TestCase-derived classes.s)str arguments must be keys in sys.modulesN(RGRtTestCaseRiRIRNROtaddTestt findTestCasesRt makeSuiteRR#R (tclassest valid_typesRtcls((s-/usr/lib64/python2.7/test/support/__init__.pyR,]s    Rtwin32tWITH_DOC_STRINGSstest requires docstringscCsddl}|dkr!t}nd}tj}tt_z>|j|d|\}}|rytd||fnWd|t_Xtrd|j|fGHn||fS(s Run doctest on the given module. Return (#failures, #tests). If optional argument verbosity is not specified (or is None), pass test.support's belief about verbosity on to doctest. Else doctest's usual behavior is used (it searches sys.argv for -v). iNRs%d of %d doctests faileds,doctest (%s) ... %d tests with zero failures( tdoctestRYRRNRsR ttestmodRR<(ReRR=t save_stdoutR R((s-/usr/lib64/python2.7/test/support/__init__.pyR-|s      cCstrtjfSdSdS(Ni(i(tthreadt_count(((s-/usr/lib64/python2.7/test/support/__init__.pyR.s cCsTts dSd}x=t|D]/}tj}||kr?PntjdqWdS(Ni g?(R@RRARR(t nb_threadst _MAX_COUNTtcountR((s-/usr/lib64/python2.7/test/support/__init__.pyR/s  cs,ts Stjfd}|S(sUse this function when threads are being used. This will ensure that the threads are cleaned up even when the test fails. If threading is unavailable this function does nothing. cs)t}z|SWdt|XdS(N(R.R/(R{tkey(Rz(s-/usr/lib64/python2.7/test/support/__init__.pyRs (R@RR(RzR((Rzs-/usr/lib64/python2.7/test/support/__init__.pyR0sgN@ccstj}z dVWdtj}||}xtrtj}||krSPntj|krtj|}d|||||f}t|ntjdtq1WXdS(sE bpo-31234: Context manager to wait until all threads created in the with statement exit. Use thread.count() to check if threads exited. Indirectly, wait until threads exit the internal t_bootstrap() C function of the thread module. threading_setup() and threading_cleanup() are designed to emit a warning if a test leaves running threads in the background. This context manager is designed to cleanup threads started by the thread.start_new_thread() which doesn't allow to wait for thread exit, whereas thread.Thread has a join() method. NsYwait_threads() failed to cleanup %s threads after %.1f seconds (count: %s, old count: %s)g{Gz?(R@RARRVRxRR(Rt old_countt start_timetdeadlineRDtdtRL((s-/usr/lib64/python2.7/test/support/__init__.pytwait_threads_exits         cCscttdr_d}xGtr[y/tj|tj\}}|dkrLPnWqPqXqWndS(sUse this function at the end of test_main() whenever sub-processes are started. This will help ensure that no extra children (zombies) stick around to hog resources and create problems when looking for refleaks. twaitpidiiN(RRuRVRKtWNOHANG(t any_processR+tstatus((s-/usr/lib64/python2.7/test/support/__init__.pyR7s   c cst|}g}zfy,x%|D]}|j|j|qWWn.trkdt|t|fGHnnXdVWd|r|ntj}}xtddD]}|d7}x.|D]&}|jt|tjdqWg|D]}|j r|^q}|sPntrdt||fGHqqWXg|D]}|j rE|^qE}|rt dt|ndS(Ns/Can't start %d threads, only %d threads startediii<g{Gz?s7Unable to join %d threads during a period of %d minutessUnable to join %d threads( RQtstartR\RRRRRRtisAliveRx(tthreadstunlocktstartedRtendtimet starttimeR((s-/usr/lib64/python2.7/test/support/__init__.pyR1s:       $%%ccst||rNt||}t|||z |VWdt|||Xn<t|||z dVWdt||rt||nXdS(sTemporary swap out an attribute with a new object. Usage: with swap_attr(obj, "attr", 5): ... This will set obj.attr to 5 for the duration of the with: block, restoring the old value at the end of the block. If `attr` doesn't exist on `obj`, it will be created and then deleted at the end of the block. The old value (or None if it doesn't exist) will be assigned to the target of the "as" clause, if there is one. N(RRgRtdelattr(RpRftnew_valtreal_val((s-/usr/lib64/python2.7/test/support/__init__.pyt swap_attr)s  ccsk||kr:||}|||rsN(ttobytesRhRt TypeErrortbytes(tb((s-/usr/lib64/python2.7/test/support/__init__.pyR5gs  t getcountss-types are immortal if COUNT_ALLOCS is definedcCsddl}|jS(sZReturn a list of command-line arguments reproducing the current settings in sys.flags.iN(t subprocesst_args_from_interpreter_flags(Rc((s-/usr/lib64/python2.7/test/support/__init__.pytargs_from_interpreter_flagsys cCstjdd|j}|S(sStrip the stderr of a Python process from potential debug output emitted by the interpreter. This will typically be run on the result of the communicate() method of a subprocess.Popen object. s\[\d+ refs\]\r?\n?$R(Rstsubtstrip(R((s-/usr/lib64/python2.7/test/support/__init__.pyR8scsid|ffdY}tg||||jttt|jddS(NtAcseZfdZRS(cs0tdRYRRRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR;s  GcCs*ddl}t|jWdQXdS(sDeliberate crash of Python. Python can be killed by a segmentation fault (SIGSEGV), a bus error (SIGBUS), or a different error depending on the platform. Use SuppressCrashReport() to prevent a crash report from popping up. iN(RR;t _read_null(R((s-/usr/lib64/python2.7/test/support/__init__.pyt _crash_pythons  c Cstjjd rdy!tjd}t|dSWqdtk r`}|jtjkraqaqdXnd}t tdrytj d}Wqtk rqXnd }tjdkr+yd d l }|j Wnttfk rq+Xi}x9|j|j|jfD]}|j |d ||RcRR(((s-/usr/lib64/python2.7/test/support/__init__.pyR_s ((ii@i@i@ii(i@ii(((((R>R<RFt contextlibRR/RRRRwRNRuRRR@RGREtUserDictRsRRRxRjR@RYt__all__t SHORT_TIMEOUTRRRRRHRtcontextmanagerRVRDRXRRUR[R6R4RRRRRRrRR R R}RRRRRRR RR R RRRRRRRRRRRR9R RRt PIPE_MAX_SIZEt SOCK_MAX_SIZERRRt NameErrort skipUnlesstrequires_unicodeRt FS_NONASCIItunichrt characterR$R%tdecodet UnicodeErrorRJRRitTESTFN_UNICODEtTESTFN_ENCODINGRRtTESTFN_UNENCODABLEtevalR&RR(t TEST_HTTP_URLR-RR,R0RRyRtabspatht__file__tTEST_SUPPORT_DIRR6RRXRRRDRRtobjectR^RRR R!t DictMixinR"RR%R&R#R$RRRRRRRRRRR'R:RRRt_4GRRR(R)RR*R+RRR2RR R3RR R!R,R#R&R3R,RytHAVE_DOCSTRINGStrequires_docstringsR-tenvironment_alteredR.R/R0RJR7R1RYR[R5tskipIftrequires_type_collectingReR8RqRvR}R;RRR(((s-/usr/lib64/python2.7/test/support/__init__.pyts                                    &      !         J  < $                               .    * ' /D         $ "     '       (    &  #       e  R(tzip_dirt zip_basenameRCt name_in_zipt zip_filenametzip_nametzip_file((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_zip_scriptzs  tcCs!tj|t|d|dS(Nt__init__(R tmkdirRE(tpkg_dirt init_source((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_pkgs icCsg}t|dd}|j|tjj|} t|||} |j| |rt|}t| } |j|| fngtd|dD]} tjj |g| ^q} tjj | dtjj| } |tj d}tjj ||}t j |d}x3| D]+}tjj || }|j ||q'W|j | | |jx|D]}tj|qwW|tjj || fS(NRYRXiiRLR%(RER R R5RPRKR trangetsepR=R<RMRNR>Rtunlink(RQRRtpkg_nameR@RAtdepthtcompiledR`t init_namet init_basenameRCtit pkg_namestscript_name_in_zipRTRURVtnametinit_name_in_zip((s2/usr/lib64/python2.7/test/support/script_helper.pyt make_zip_pkgs.    9%   (RR tretos.pathR3RRHt contextlibR7RMt ImportErrort test.supportRR R"R$R*R,R0R2tcontextmanagerR:RERKRORWR]R#Rk(((s2/usr/lib64/python2.7/test/support/script_helper.pyts4                    PKbd] support/script_helper.pycnu[ {fc@s.ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddl Z Wne k rnXddl m Z dZ dZdZdZdZdZd Zejd Zd Zd Zdd ZddZdedZdS(iN(tstrip_python_stderrc Ostjg}|s"|jdn|j|tjj}|j|tj |dtj dtj dtj d|}z|j \}}Wdtj |j j|jjX|j}t|}|r|s| r | r td||jddfn|||fS( Ns-Etstdintstdouttstderrtenvs-Process return code is %d, stderr follows: %stasciitignore(tsyst executabletappendtextendtostenvirontcopytupdatet subprocesstPopentPIPEt communicatet_cleanupRtcloseRt returncodeRtAssertionErrortdecode( texpected_successtargstenv_varstcmd_lineRtptoutterrtrc((s2/usr/lib64/python2.7/test/support/script_helper.pyt_assert_pythons*        cOstt||S(s Assert that running the interpreter with `args` and optional environment variables `env_vars` is ok and return a (return code, stdout, stderr) tuple. (R tTrue(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_ok2scOstt||S(s Assert that running the interpreter with `args` and optional environment variables `env_vars` fails and return a (return code, stdout, stderr) tuple. (R tFalse(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_failure9sc GsWtjdg}|j|ttjd#}tj|d|dtjSWdQXdS(Ns-EtwRR( RRR topenR tdevnullRtcalltSTDOUT(RRR'((s2/usr/lib64/python2.7/test/support/script_helper.pytpython_exit_code@s  c OsGtjdg}|j|tj|dtjdtjdtj|S(Ns-ERRR(RRR RRRR)(RtkwargsR((s2/usr/lib64/python2.7/test/support/script_helper.pyt spawn_pythonGs  cCsA|jj|jj}|jj|jtj|S(N(RRRtreadtwaitRR(Rtdata((s2/usr/lib64/python2.7/test/support/script_helper.pyt kill_pythonNs     cOs+t||}t|}|j|fS(N(R,R0R.(RR+Rt stdout_data((s2/usr/lib64/python2.7/test/support/script_helper.pyt run_pythonXs ccs<tj}tjj|}z |VWdtj|XdS(N(ttempfiletmkdtempR tpathtrealpathtshutiltrmtree(tdirname((s2/usr/lib64/python2.7/test/support/script_helper.pyttemp_diras   cCsP|tjd}tjj||}t|d}|j||j|S(NtpyR%(R textsepR5tjoinR&twriteR(t script_dirtscript_basenametsourcetscript_filenamet script_namet script_file((s2/usr/lib64/python2.7/test/support/script_helper.pyt make_scriptjs   cCs!tj|dt|d}|S(Ntdoraisetc(t py_compiletcompileR!(RCt compiled_name((s2/usr/lib64/python2.7/test/support/script_helper.pytcompile_scriptrs cCs|tjd}tjj||}tj|d}|dkrYtjj|}n|j|||j |tjj||fS(NtzipR%( R R<R5R=tzipfiletZipFiletNonetbasenameR>R(tzip_dirt zip_basenameRCt name_in_zipt zip_filenametzip_nametzip_file((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_zip_scriptzs  tcCs!tj|t|d|dS(Nt__init__(R tmkdirRE(tpkg_dirt init_source((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_pkgs icCsg}t|dd}|j|tjj|} t|||} |j| |rt|}t| } |j|| fngtd|dD]} tjj |g| ^q} tjj | dtjj| } |tj d}tjj ||}t j |d}x3| D]+}tjj || }|j ||q'W|j | | |jx|D]}tj|qwW|tjj || fS(NRYRXiiRLR%(RER R R5RPRKR trangetsepR=R<RMRNR>Rtunlink(RQRRtpkg_nameR@RAtdepthtcompiledR`t init_namet init_basenameRCtit pkg_namestscript_name_in_zipRTRURVtnametinit_name_in_zip((s2/usr/lib64/python2.7/test/support/script_helper.pyt make_zip_pkgs.    9%   (RR tretos.pathR3RRHt contextlibR7RMt ImportErrort test.supportRR R"R$R*R,R0R2tcontextmanagerR:RERKRORWR]R#Rk(((s2/usr/lib64/python2.7/test/support/script_helper.pyts4                    PKbd]GKFscript_helper.pycnu[ zfc@sddlTdS(i(t*N(ttest.support.script_helper(((s*/usr/lib64/python2.7/test/script_helper.pyttPKbd]J[test_support.pyonu[ zfc@s,ddlZddlZejejds  PKbd]ӨqOOtest_support.pynu[import sys import test.support sys.modules['test.test_support'] = test.support PK]((test_program.pyonu[ |fc@sddlmZddlZddlZddlZddlZdejfdYZdejfdYZ e Z de fdYZ d ejfd YZ ed krejndS( i(tStringIONtTest_TestProgramcBsgeZdZdZdejfdYZdejfdYZdZ dZ dZ RS( cstj}gtjjtjjtjjt_ fd}||_ |j d}j j j |jdS(Ncst_j|S(N(tTruetwasRunt assertEqual(t start_dirtpattern(t expectedPathtselfttests(s2/usr/lib64/python2.7/unittest/test/test_program.pyt _find_testss s unittest.test(tunittestt TestLoadertostpathtabspathtdirnamettestt__file__tFalseRR tdiscovert assertTrueRt_tests(RtloaderR tsuite((RRR s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_discovery_from_dotted_path s  $  cstt}dtffdY}|}tjjfd}dtj_|j|d}|tj_|j|tjd|dtdd }|j|j|j|j||j|j d dS( Nt FakeRunnercseZfdZRS(cs ||_S(N(R(RR(tresult(s2/usr/lib64/python2.7/unittest/test/test_program.pytrun!s (t__name__t __module__R((R(s2/usr/lib64/python2.7/unittest/test/test_program.pyR scstj_dS(N(R t TestProgramt parseArgs((t oldParseArgs(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestoreParseArgs(scWsdS(N(tNone(targs((s2/usr/lib64/python2.7/unittest/test/test_program.pyt*tcSs tj`dS(N(R RR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyt removeTest-st testRunnertexitt verbosityi( tobjectR RR t addCleanupRRRRR*(RRRtrunnerR"R'tprogram((R!Rs2/usr/lib64/python2.7/unittest/test/test_program.pyt testNoExits        tFooBarcBseZdZdZRS(cCsdS(N((R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestPass9scCsdS(N((R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestFail;s(RRR1R2(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR08s t FooBarLoadercBseZdZdZRS(s3Test loader that returns a suite containing FooBar.cCs|j|jtjgS(N(t suiteClasstloadTestsFromTestCaseRR0(Rtmodule((s2/usr/lib64/python2.7/unittest/test/test_program.pytloadTestsFromModule@s(RRt__doc__R7(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR3>sc CsVtjdtddgdtjdtd|j}|jt|ddS(NR)targvtfoobarR(tstreamt testLoaderR(R tmainRtTextTestRunnerRR3Rthasattr(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyt test_NonExitEs  c CsG|jttjddgdtjdtdtd|jdS(NR9R:R(R;R)R<(t assertRaisest SystemExitR R=R>RRR3(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyt test_ExitMs  c CsA|jttjddgdtjdtd|jdS(NR9R:R(R;R<(RARBR R=R>RR3(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_ExitAsDefaultWs   ( RRRR/R tTestCaseR0R R3R@RCRD(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR s    tInitialisableProgramcBsDeZeZdZdZdZdZe j Z dZ dZ dZRS(iRcGsdS(N((RR$((s2/usr/lib64/python2.7/unittest/test/test_program.pyt__init__isN(RRRR)R#RR*t defaultTestR(R tdefaultTestLoaderR<tprogNameRRG(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRF`s RcBs,eZdZdZeZdZdZRS(cKs(|t_tjr$tt_tndS(N(RtinitArgst raiseErrorRt TypeError(Rtkwargs((s2/usr/lib64/python2.7/unittest/test/test_program.pyRGss   cCs |t_tS(N(RRtRESULT(RR((s2/usr/lib64/python2.7/unittest/test/test_program.pyRys N( RRR#RKRRRLRGR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRns  tTestCommandLineArgscBsPeZdZdZdZdZdZdZdZdZ RS(cCs:t|_d|j_dt_dt_tt_dS(NcSsdS(N(R#(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR%R&( RFR.t createTestsR#RRKRRRL(R((s2/usr/lib64/python2.7/unittest/test/test_program.pytsetUps    cs|jdfd}|_xJdD]B}t_jd|g|jj|jjq+Wjddg|jj|j jdS(Ncs|_t_dS(N(tmsgRR)(RS(R.(s2/usr/lib64/python2.7/unittest/test/test_program.pyt usageExits s-hs-Hs--helps-$(s-hs-Hs--help( R.R#RTRR)R Rt assertIsNoneRStassertIsNotNone(RRTtopt((R.s2/usr/lib64/python2.7/unittest/test/test_program.pyttestHelpAndUnknowns    cCs|j}x=dD]5}d|_|jd|g|j|jdqWx=d D]5}d|_|jd|g|j|jdqPWdS( Ns-qs--quietiis-vs --verbosei(s-qs--quiet(s-vs --verbose(R.R*R R#R(RR.RW((s2/usr/lib64/python2.7/unittest/test/test_program.pyt testVerbositys     cCs |j}xdd d fD]\}}|dkr>t r>qnd|d}d|}xM||fD]?}t||d|jd|g|jt||qcWxY||fD]K}t}t||||jd|g|jt|||qWqWdS( Ntbuffertfailfasttcatcht catchbreaks-%sis--%s(RZRZ(R[R[(R\R]( R.thasInstallHandlertsetattrR#R RtgetattrR+R(RR.targtattrt short_opttlong_optRWtnot_none((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestBufferCatchFailfasts     cCs|j}t|_d|_d|_d|_|j|jtjidd6dd6dd6|jtj d|j |j t dS(NR*R[RZR( R.RR(R*R[RZtrunTestsRRKRtassertIsRRO(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerClasss       cCsb|j}t|_dt_|j|jtj|jtjd|j |j t dS(NR( R.RR(R#RKRgRURRRhRRO(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerInstances    cCs|j}tt_t|_d|_d|_d|_d|_|j |j tj i|j tjd|j |j tdS(NR*R[RZR(R.RRRLR(R*R[RZRRgRRKRhRRO(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsOldRunnerClasss        cstjdjfd}j|t_fd}|_j}t|_t |_ |j j jdS(Ns unittest.maincs _dS(N(tinstallHandler((R6toriginal(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestorescs t_dS(N(Rt installed((R(s2/usr/lib64/python2.7/unittest/test/test_program.pytfakeInstallHandlers( tsystmodulesRlR,RRoR.RR]RR(RgR(RRnRpR.((R6RmRs2/usr/lib64/python2.7/unittest/test/test_program.pyttestCatchBreakInstallsHandlers         ( RRRRRXRYRfRiRjRkRs(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRP}s      t__main__(t cStringIORR RqR t unittest.testRERRRFR+RORRPRR=(((s2/usr/lib64/python2.7/unittest/test/test_program.pyts    W  PK]\pqqtest_setups.pyonu[ |fc@sgddlZddlmZddlZdZdejfdYZedkrcejndS(iN(tStringIOcGs tjS(N(tunittestt TestResult(t_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt resultFactoryst TestSetupscBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZRS(cCstjdtdtS(Nt resultclasststream(RtTextTestRunnerRR(tself((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt getRunnerscGstj}x-|D]%}tjj|}|j|qW|j}tj}|j||jtj|jtj|j|S(N(Rt TestSuitetdefaultTestLoadertloadTestsFromTestCasetaddTestsR taddTesttrun(R tcasestsuitetcasetteststrunnert realSuite((s1/usr/lib64/python2.7/unittest/test/test_setups.pytrunTestss     csqdtjffdY|j}|jjd|j|jd|jt|jddS(NtTestcs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(t setUpCalledRtTestCaset setUpClass(tcls(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR$scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_one(scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_two*s(t__name__t __module__Rt classmethodRRR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR"s iii(RRRt assertEqualRttestsRuntlenterrors(R tresult((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_class!s  csqdtjffdY|j}|jjd|j|jd|jt|jddS(NRcs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(ttearDownCalledRRt tearDownClass(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)6scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR:scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR<s(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR4s iii(RRRR"R(R#R$R%(R R&((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class3s  csdtjffdYdtjffdY|j}|jjd|jjd|j|jd|jt|jddS(NRcs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(R(RRR)(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)HscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRNs(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs tTest2cs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(R(RRR)(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)SscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRWscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRYs(RR R(R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+Qs iii(RRRR"R(R#R$R%(R R&((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class_two_classesEs  cCsdtjfdY}|j|}|j|jd|jt|jd|jd\}}|jt|dtdS(Nt BrokenTestcBs)eZedZdZdZRS(cSstddS(Ntfoo(t TypeError(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRescSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRhscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRjs(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-ds iissetUpClass (%s.BrokenTest)( RRRR"R#R$R%tstrR(R R-R&terrorR((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setupclasscs csdtjffdYdtjffdY|j}|j|jd|jt|jd|jjd|jjd|jd\}}|jt|d t dS( NRcs5eZdZefdZdZdZRS(icsjd7_tddS(NiR.(ttornDownR/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)xscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s(RR R3R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvs R+cs5eZdZefdZdZdZRS(icsjd7_tddS(NiR.(R3R/(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR R3R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+s iiiistearDownClass (%s.Test)( RRRR"R#R$R%R3R0R(R R&R1R((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_classus  cs@dtjffdY|j|jjdS(NRcs;eZeZedZefdZdZRS(cSs tdS(N(R/(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscst_tddS(NR.(tTrueR3R/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)s cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR tFalseR3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RRRt assertFalseR3(R ((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt(test_class_not_torndown_when_setup_failss csedtjffdYtjd|j|jj|jjdS(NRcsGeZeZeZefdZefdZdZRS(cs t_dS(N(R5t classSetUp(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscs t_dS(N(R5R3(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs( RR R6R9R3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs thop(RRtskipRR7R9R3(R ((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt-test_class_not_setup_or_torndown_when_skippeds   cs gdtffdY}dtffdY}dtjffdY}dtjffdY}d tjffd Y}d |_|_d|_|tjd <|tjd((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttearDownModules(RR t staticmethodR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR=stModule2cs2eZefdZefdZRS(csjddS(NsModule2.setUpModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@scsjddS(NsModule2.tearDownModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAs(RR RBR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRCstTest1csPeZefdZefdZfdZfdZRS(csjddS(Nssetup 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(Ns teardown 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Ns Test1.testOne(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestOnescsjddS(Ns Test1.testTwo(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestTwos(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRDsR+csPeZefdZefdZfdZfdZRS(csjddS(Nssetup 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(Ns teardown 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Ns Test2.testOne(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyREscsjddS(Ns Test2.testTwo(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+stTest3csPeZefdZefdZfdZfdZRS(csjddS(Nssetup 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(Ns teardown 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Ns Test3.testOne(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyREscsjddS(Ns Test3.testTwo(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRGstModuleRERFiisModule1.setUpModulessetup 1s Test1.testOnes Test1.testTwos teardown 1ssetup 2s Test2.testOnes Test2.testTwos teardown 2sModule1.tearDownModulesModule2.setUpModulessetup 3s Test3.testOnes Test3.testTwos teardown 3sModule2.tearDownModule( tobjectRRR tsystmodulesR R RR"R#R$R%(R R=RCRDR+RGtfirsttsecondtthirdtfourthtfifthtsixthRRR&((R?s1/usr/lib64/python2.7/unittest/test/test_setups.pyt1test_setup_teardown_order_with_pathological_suites:      !    csdtffdYdtjfdY}d|_tjd<|j|}|jjd|j|j d|jt |j ddS(NRHcs#eZdZefdZRS(icsjd7_dS(Ni(t moduleSetup((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@ s(RR RSRBR@((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH sRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs iii( RIRRR RJRKRR"RSR#R$R%(R RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_module s  cs$dtffdYdtjffdYdtjfdY}d_d|_tjd<|j|}|jjd|jj d|j|j d|j j |j j |jt|jd|jd\}}|jt|d dS( NRHcs>eZdZdZefdZefdZRS(icsjd7_tddS(NiR.(RSR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@"scsjd7_dS(Ni(tmoduleTornDown((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA&s(RR RSRURBR@RA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcsPeZeZeZefdZefdZdZdZ RS(cs t_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-scs t_dS(N(R5t classTornDown(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)0scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR3scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR5s( RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR*s  R+cBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR9scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR;s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+8s iissetUpModule (Module)(RIRRR RJRKRR"RSRUR#R7R9RVR$R%R0(R R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setup_modules    cCs[dtjfdY}d|_tjjdd|j|}|j|j ddS(NRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRMscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyROs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLs RHi( RRR RJRKtpoptNoneRR"R#(R RR&((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt!test_testcase_with_missing_moduleKs  csdtffdYdtjfdY}d|_tjd<|j|}|jjd|j|j d|jt |j ddS(NRHcs#eZdZefdZRS(icsjd7_dS(Ni(RU((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAZs(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHXsRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR_scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRas(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR^s iii( RIRRR RJRKRR"RUR#R$R%(R RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_moduleWs  csdtffdYdtjffdYdtjfdY}d_d|_tjd<|j|}|jjd|j|j d|j j |j j |jt |jd|jd \}}|jt|d dS( NRHcs#eZdZefdZRS(icsjd7_tddS(NiR.(RUR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAns(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHlsRcsPeZeZeZefdZefdZdZdZ RS(cs t_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvscs t_dS(N(R5RV(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)yscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s( RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRss  R+cBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+s iiistearDownModule (Module)(RIRRR RJRKRR"RUR#t assertTrueR9RVR$R%R0(R R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_moduleks   cCsdtjfdY}|j|}|j|jd|jt|jd|jt|jd|jdd}|jt|dt dS(NRcBs)eZedZdZdZRS(cSstjddS(NR.(RtSkipTest(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs iissetUpClass (%s.Test)( RRRR"R#R$R%tskippedR0R(R RR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupclasss cCsdtjfdY}dtfdY}d|_|tjd<|j|}|j|jd|jt |j d|jt |j d|j dd}|jt |ddS(NRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs RHcBseZedZRS(cSstjddS(NR.(RR^(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@s(RR RBR@(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsiissetUpModule (Module)( RRRIR RJRKRR"R#R$R%R_R0(R RRHR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupmodules  csgdtffdY}dtjffdY}d|_|tjd((tordering(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@scsjddS(NRA(R>((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAs(RR RBR@RA((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcsAeZefdZefdZfdZRS(csjddS(NR(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(NR)(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Nttest_something(R>(R (Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRcs(RR R!RR)Rc((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRsR@RRcR)RA( RIRRR RJRKR R tdebugR"(R RHRRt expectedOrder((Rbs1/usr/lib64/python2.7/unittest/test/test_setups.pyt.test_suite_debug_executes_setups_and_teardownss   csdtffdY}dtjffdY}d|_|tjds    PK]CVEEtest_discovery.pyonu[ {fc@srddlZddlZddlZddlZddlZdejfdYZedkrnejndS(iNt TestDiscoverycBs}eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( cCsetj}d|_|jd}|j|dts>dS|jt|jdWdQXdS(Ns/foos/foo/bar/baz.pysbar.bazs /bar/baz.py(tunittestt TestLoadert_top_level_dirt_get_name_from_patht assertEqualt __debug__t assertRaisestAssertionError(tselftloadertname((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_get_name_from_path s  c stj}tjfd}tjjfd}tjjfd}dddddd d gd d ggfd t_|j|d}|tj_|j|d}|tj_|j|d|_d|_ tjj d}||_ t |j |d}gdD]} | d^q6} | jgdD]} d| d^qY|j|| dS(Ncs t_dS(N(tostlistdir((toriginal_listdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_listdirscstj_dS(N(R tpathtisfile((toriginal_isfile(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_isfile!scstj_dS(N(R Rtisdir((toriginal_isdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt restore_isdir$sstest1.pystest2.pys not_a_test.pyttest_dirstest.foostest-not-a-module.pyt another_dirstest3.pystest4.pycs jdS(Ni(tpop(R(t path_lists(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt*tcSs |jdS(Ntdir(tendswith(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR-scSs|jd od|kS(NRR(R(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR2scSs|dS(Ns module((R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR8RcSs|dS(Ns tests((tmodule((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR9Rs/foostest*.pyttest1ttest2s module teststtest3ttest4s test_dir.%s(R!R"(R#R$(RRR RRRRt addCleanupt_get_module_from_nametloadTestsFromModuletabspathRtlistt _find_teststextendR( R R RRRRRt top_leveltsuiteR texpected((RRRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_testss8                 cstj}tjfd}tjjfd}tjjfd}dddgggggfdt_j|dtj_j|fd tj_j|d tfd Yfd |_ fd }||_ d|_ t |j dd}j|dddgjjddgjj|dddfgdS(Ncs t_dS(N(R R((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRIscstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRLscstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyROst a_directoryttest_directoryttest_directory2cs jdS(Ni(R(R(R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRTRcSstS(N(tTrue(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRWRcstjj|kS(N(R Rtbasename(R(t directories(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRZRtModulecBs,eZgZgZdZdZdZRS(csP|_jj|tjj|dkrLfd}|_ndS(NR1csjj|||fdS(Nt load_tests(tload_tests_argstappend(R tteststpattern(R (s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR7es(RtpathsR9R R4R7(R RR7((R s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__init__as  cSs|j|jkS(N(R(R tother((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__eq__jsN(t__name__t __module__R<R8R=R?tNonet__hash__(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR6]s  cs |S(N((R (R6(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRpRcs#|rjdn|jdS(Ns+use_load_tests should be False for packagess module tests(tfailureExceptionR(R tuse_load_tests(R (s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR'qss/foostest*R7s module tests(RRR RRRRR%tobjectR&R'RR)R*RR<R8(R R RRRR'R-((R6R5RRRRR s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_tests_with_packageEs4           c stj}tjjtjjfd}dtj_|j|tjfd}|j|tjjtjj d}|j t |j dddWdQX|j |j||j|tjdtj_dtj_fd }|j|gfd }||_t|_|j d d d}tjjd}tjjd } |j |d |j |j||j | d fg|j|tjdS(Ncstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRscSstS(N(tFalse(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcstj(dS(N(tsysR((t orig_sys_path(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt restore_pathss/foos/foo/bart top_level_dircSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRscsj||fdgS(NR:(R9(t start_dirR;(t_find_tests_args(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*ss /foo/bar/bazR;s ['tests'](RRR RRRR%RIR(tnormpathRt ImportErrortdiscoverRRtassertInR*tstrt suiteClass( R R RRKt full_pathRR*R-RLRM((RNRJRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt test_discovers:         cstj}tjdt_tjjdtj_tjfd}|j||jd}|j tj tj|j |j dt t |dd}|jt|jWdQXdS(NcSsdgS(Nstest_this_does_not_exist.py((t_((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcs#tj_t_tj(dS(N(R RRRRI((RRRJ(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestores  t.ii(RRR RRRRIR%RQRRtgetcwdRtcountTestCasesR)RRPttest_this_does_not_exist(R R RXR-ttest((RRRJs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt.test_discover_with_modules_that_fail_to_imports      cstjtj}gfd}||_|jddg|jg|jddddg|jddgdS(Ncsj|dS(N(R+(targv(targs(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt do_discoveryst somethingRQtfootbar(RFt__new__Rt TestProgramt _do_discoveryt parseArgsR(R tprogramRa((R`s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt$test_command_line_handling_parseArgss c s|dtfdYfd}tjtj}||_d|_|j|j ddddgWdQXdS(NtStopcBseZRS((R@RA(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRkscs dS(N(((Rk(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt usageExitstonettwotthreetfour( t ExceptionRFReRRfRlRBt testLoaderRRg(R RlRi((Rks4/usr/lib64/python2.7/unittest/test/test_discovery.pyt:test_command_line_handling_do_discovery_too_many_argumentss  cCs^tjtj}dtfdY}||_|jdg|j|jdgdS(NtLoadercBseZgZdZRS(cSs|jj|||fdS(NR:(R`R9(R RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQs(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRtss-vRYstest*.py(RYstest*.pyN( RFReRRfRrRgRR`RB(R RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt;test_command_line_handling_do_discovery_uses_default_loaders  cCstjtj}dtfdY}|jdgd||j|jd|j|jd|j|jdgg|_tjtj}|jdgd||j|jd|j|jdgg|_tjtj}|jgd||j|jd|j|jdgg|_tjtj}|jd gd||j|jd|j|jdgg|_tjtj}|jd d gd||j|jd|j|jdgg|_tjtj}|jd d d gd||j|jd|j|jdgg|_tjtj}|jd d gd||j|jd|j|jdgg|_tjtj}|jd d gd||j|jd|j|jdgg|_tjtj}|jdd gd||j|jd|j|jdg|j |j |j |j g|_tjtj}|jdd d d dddgd||j|jd|j|jdg|j|jd|j |j |j |j dS(NRtcBseZgZdZRS(cSs|jj|||fdS(NR:(R`R9(R RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQs(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRtss-viR:RYstest*.pys --verbosetfishteggsthams-ss-ts-ps-fs-c(RYstest*.pyN(RYstest*.pyN(RYstest*.pyN(Rvstest*.pyN(RvRwN(RvRwRx(Rvstest*.pyN(RYstest*.pyRv(RYRvN(RvRwN(RFReRRfRgRt verbosityR]R`RBt assertFalsetfailfastt catchbreakt assertTrue(R RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt4test_command_line_handling_do_discovery_calls_loadersr         !csdtfdY}|tjds           cCs|j}tj}tjjd}tjjd}tjd||f}|jt d||j dddd|j t jd|dS( NRdRcsZ'foo' module incorrectly imported from %r. Expected %r. Is this module globally installed?s^%s$RMR;sfoo.pyi( RRRR RR(tretescapetassertRaisesRegexpRPRQRRI(R RUR tmod_dirt expected_dirtmsg((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_detect_module_clash[s    cs|j}tjjtjjdtjjdfd}|j|fd}|tj_tj}|jdddddS(NRdRccstj_dS(N(R Rtrealpath((toriginal_realpath(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRqscs2|tjjdkr.tjjdS|S(Nsfoo.py(R Rtjoin(R(RR(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRusRMR;sfoo.py( RR RRR(R%RRRQ(R RURRR ((RRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_module_symlink_okis     cstj}gtjjtjjtjjt_ fd}||_ |j d}j j j |jdS(Ncst_j|S(N(R3twasRunR(RMR;(t expectedPathR R:(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*s s unittest.test(RRR RR(tdirnameR]RRHRR*RQR}Rt_tests(R R R*R-((RR R:s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_discovery_from_dotted_path}s  $  (R@RAR R/RGRVR^RjRsRuR~RRRR(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR s  + A .    J   t__main__( R RRIRt unittest.testtTestCaseRR@tmain(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyts      PK]o5z4z4test_assertions.pycnu[ {fc@sgddlZddlZdejfdYZdejfdYZedkrcejndS(iNtTest_AssertionscBs,eZdZdZdZdZRS(cCsH|jdd|jdd|j|j|jdd|j|j|jdd|jdddd|j|j|jdddd|jdd dd|jdd dd|j|j|jdd dd|j|j|jdddd|jtd td |j|j|jtd td dS(Ng1?g?g?g?tplacesiig?y?tinfy??y??y??y??(tassertAlmostEqualtassertNotAlmostEqualt assertRaisestfailureExceptiontfloat(tself((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AlmostEquals$     c Cs|jdddd|jdddd|jdddd|jdddd|jdddd|j|j|jdddd|j|j|jdddd|j|j|jdddd|jt|jdddddd|jt|jddddddtjj}|tjdd }|j||dtjdd |j||dtjdd dS( Ng?g?tdeltag?g?Ritsecondsi ii(RRRRt TypeErrortdatetimetnowt timedelta(Rtfirsttsecond((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AmostEqualWithDeltas*c Csd}|jt|t|jt|tdy|jtdWn)|jk rw}|jd|jnX|jdy|jt|tWntk rnX|jd|jt*}y tWntk r}nXWdQX|j|j ||jttdWdQXy|jtWdQXWn)|jk rr}|jd|jnX|jdy |jt tWdQXWntk rnX|jddS(NcSs |dS(N((te((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt_raise:stkeycSsdS(N(tNone(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt?tsKeyError not raisedsassertRaises() didn't fails0assertRaises() didn't let exception pass through( RtKeyErrorRtassertIntargstfailt ValueErrort ExceptiontassertIst exception(RRRtcm((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_assertRaises9sB         cCs|jddy|jdddWnD|jk rm}|jd|jd|jd|jdnX|jddS(Ns Ala ma kotasr+sk.ttMessages'kot'is*assertNotRegexpMatches should have failed.(tassertNotRegexpMatchesRRRR(RR((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotRegexpMatchesbs(t__name__t __module__R RR"R%(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyRs   )tTestLongMessagecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(sTest that the individual asserts honour longMessage. This actually tests all the message behaviour for asserts that use longMessage.cs`dtjffdY}dtjffdY}|d_|d_dS(NtTestableTestFalsecs eZeZjZdZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestTestws(R&R'tFalset longMessageRR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR)ss tTestableTestTruecs eZeZjZdZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR*~s(R&R'tTrueR,RR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR-zs R*(tunittesttTestCaset testableTruet testableFalse(RR)R-((Rs5/usr/lib64/python2.7/unittest/test/test_assertions.pytsetUprscCs|jtjjdS(N(t assertFalseR/R0R,(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testDefaultscCs|j|jjddd|j|jjddd|j|jjddd|j|jjddd|jjtddS(Ntfootbars bar : foo(t assertEqualR2t_formatMessageRR1tobject(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_formatMsgs cCs6djdtdD}|jj|ddS(NRcss|]}t|VqdS(N(tchr(t.0ti((s5/usr/lib64/python2.7/unittest/test/test_assertions.pys siu�(tjointrangeR1R9(Rtone((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt test_formatMessage_unicode_errorsc sfd}xxt|D]j\}}||}i}|d} | r]idd6}njjd||||WdQXqWdS(Ncs4|dk}|rj}n j}t|S(Ni(R2R1tgetattr(R>tuseTestableFalsettest(t methodNameR(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt getMethods    itoopstmsgtexpected_regexp(t enumeratetassertRaisesRegexpR( RRFRterrorsRGR>RJt testMethodtkwargstwithMsg((RFRs5/usr/lib64/python2.7/unittest/test/test_assertions.pytassertMessagess   cCs&|jdtfddddgdS(Nt assertTrues^False is not true$s^oops$s^False is not true : oops$(RQR+(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertTrues cCs&|jdtfddddgdS(NR4s^True is not false$s^oops$s^True is not false : oops$(RQR.(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertFalses cCs#|jddddddgdS(NtassertNotEqualis^1 == 1$s^oops$s^1 == 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testNotEquals  cCs#|jddddddgdS(NRiis^1 != 2 within 7 places$s^oops$s^1 != 2 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAlmostEquals cCs#|jddddddgdS(NRis^1 == 1 within 7 places$s^oops$s^1 == 1 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestNotAlmostEquals cCs#|jddddddgdS(Nt_baseAssertEqualiis^1 != 2$s^oops$s^1 != 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_baseAssertEquals cCs,|jdgdgfddddgdS(NtassertSequenceEquals \+ \[None\]$s^oops$s\+ \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSequenceEquals cCs5|jdttdgfddddgdS(NtassertSetEqualsNone$s^oops$s None : oops$(RQtsetR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSetEquals cCs)|jddgfddddgdS(NRs^None not found in \[\]$s^oops$s^None not found in \[\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testAssertInscCs,|jdddgfddddgdS(Nt assertNotIns%^None unexpectedly found in \[None\]$s^oops$s,^None unexpectedly found in \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotInscCs0|jdiidd6fddddgdS(NtassertDictEqualtvalueRs\+ \{'key': 'value'\}$s^oops$s\+ \{'key': 'value'\} : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictEqualscCs0|jdidd6ifddddgdS(NtassertDictContainsSubsetRdRs^Missing: 'key'$s^oops$s^Missing: 'key' : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictContainsSubsetscCs#|jddddddgdS(NtassertMultiLineEqualRR6s\+ foo$s^oops$s\+ foo : oops$(RR6(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertMultiLineEquals cCs#|jddddddgdS(Nt assertLessiis^2 not less than 1$s^oops$s^2 not less than 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLesss cCs#|jddddddgdS(NtassertLessEqualiis^2 not less than or equal to 1$s^oops$s&^2 not less than or equal to 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLessEquals cCs#|jddddddgdS(Nt assertGreateriis^1 not greater than 2$s^oops$s^1 not greater than 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreaters cCs#|jddddddgdS(NtassertGreaterEqualiis"^1 not greater than or equal to 2$s^oops$s)^1 not greater than or equal to 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreaterEquals cCs#|jddddddgdS(Nt assertIsNonesnot Nones^'not None' is not None$s^oops$s^'not None' is not None : oops$(snot None(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNones cCs#|jddddddgdS(NtassertIsNotNones^unexpectedly None$s^oops$s^unexpectedly None : oops$(N(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNotNones cCs#|jddddddgdS(NRR6s^None is not 'foo'$s^oops$s^None is not 'foo' : oops$(NR6(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testAssertIss cCs#|jddddddgdS(Nt assertIsNots^unexpectedly identical: None$s^oops$s%^unexpectedly identical: None : oops$(NN(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNots (R&R't__doc__R3R5R;RBRQRSRTRVRWRXRZR\R_R`RbReRgRiRkRmRoRqRsRuRvRx(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR(ms6                        t__main__(R R/R0RR(R&tmain(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyts  g PK]ú((test_program.pycnu[ |fc@sddlmZddlZddlZddlZddlZdejfdYZdejfdYZ e Z de fdYZ d ejfd YZ ed krejndS( i(tStringIONtTest_TestProgramcBsgeZdZdZdejfdYZdejfdYZdZ dZ dZ RS( cstj}gtjjtjjtjjt_ fd}||_ |j d}j j j |jdS(Ncst_j|S(N(tTruetwasRunt assertEqual(t start_dirtpattern(t expectedPathtselfttests(s2/usr/lib64/python2.7/unittest/test/test_program.pyt _find_testss s unittest.test(tunittestt TestLoadertostpathtabspathtdirnamettestt__file__tFalseRR tdiscovert assertTrueRt_tests(RtloaderR tsuite((RRR s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_discovery_from_dotted_path s  $  cstt}dtffdY}|}tjjfd}dtj_|j|d}|tj_|j|tjd|dtdd }|j|j|j|j||j|j d dS( Nt FakeRunnercseZfdZRS(cs ||_S(N(R(RR(tresult(s2/usr/lib64/python2.7/unittest/test/test_program.pytrun!s (t__name__t __module__R((R(s2/usr/lib64/python2.7/unittest/test/test_program.pyR scstj_dS(N(R t TestProgramt parseArgs((t oldParseArgs(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestoreParseArgs(scWsdS(N(tNone(targs((s2/usr/lib64/python2.7/unittest/test/test_program.pyt*tcSs tj`dS(N(R RR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyt removeTest-st testRunnertexitt verbosityi( tobjectR RR t addCleanupRRRRR*(RRRtrunnerR"R'tprogram((R!Rs2/usr/lib64/python2.7/unittest/test/test_program.pyt testNoExits        tFooBarcBseZdZdZRS(cCsts tdS(N(RtAssertionError(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestPass9scCsts tdS(N(RR1(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestFail;s(RRR2R3(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR08s t FooBarLoadercBseZdZdZRS(s3Test loader that returns a suite containing FooBar.cCs|j|jtjgS(N(t suiteClasstloadTestsFromTestCaseRR0(Rtmodule((s2/usr/lib64/python2.7/unittest/test/test_program.pytloadTestsFromModule@s(RRt__doc__R8(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR4>sc CsVtjdtddgdtjdtd|j}|jt|ddS(NR)targvtfoobarR(tstreamt testLoaderR(R tmainRtTextTestRunnerRR4Rthasattr(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyt test_NonExitEs  c CsG|jttjddgdtjdtdtd|jdS(NR:R;R(R<R)R=(t assertRaisest SystemExitR R>R?RRR4(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyt test_ExitMs  c CsA|jttjddgdtjdtd|jdS(NR:R;R(R<R=(RBRCR R>R?RR4(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_ExitAsDefaultWs   ( RRRR/R tTestCaseR0R R4RARDRE(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR s    tInitialisableProgramcBsDeZeZdZdZdZdZe j Z dZ dZ dZRS(iRcGsdS(N((RR$((s2/usr/lib64/python2.7/unittest/test/test_program.pyt__init__isN(RRRR)R#RR*t defaultTestR(R tdefaultTestLoaderR=tprogNameRRH(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRG`s RcBs,eZdZdZeZdZdZRS(cKs(|t_tjr$tt_tndS(N(RtinitArgst raiseErrorRt TypeError(Rtkwargs((s2/usr/lib64/python2.7/unittest/test/test_program.pyRHss   cCs |t_tS(N(RRtRESULT(RR((s2/usr/lib64/python2.7/unittest/test/test_program.pyRys N( RRR#RLRRRMRHR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRns  tTestCommandLineArgscBsPeZdZdZdZdZdZdZdZdZ RS(cCs:t|_d|j_dt_dt_tt_dS(NcSsdS(N(R#(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR%R&( RGR.t createTestsR#RRLRRRM(R((s2/usr/lib64/python2.7/unittest/test/test_program.pytsetUps    cs|jdfd}|_xJdD]B}t_jd|g|jj|jjq+Wjddg|jj|j jdS(Ncs|_t_dS(N(tmsgRR)(RT(R.(s2/usr/lib64/python2.7/unittest/test/test_program.pyt usageExits s-hs-Hs--helps-$(s-hs-Hs--help( R.R#RURR)R Rt assertIsNoneRTtassertIsNotNone(RRUtopt((R.s2/usr/lib64/python2.7/unittest/test/test_program.pyttestHelpAndUnknowns    cCs|j}x=dD]5}d|_|jd|g|j|jdqWx=d D]5}d|_|jd|g|j|jdqPWdS( Ns-qs--quietiis-vs --verbosei(s-qs--quiet(s-vs --verbose(R.R*R R#R(RR.RX((s2/usr/lib64/python2.7/unittest/test/test_program.pyt testVerbositys     cCs |j}xdd d fD]\}}|dkr>t r>qnd|d}d|}xM||fD]?}t||d|jd|g|jt||qcWxY||fD]K}t}t||||jd|g|jt|||qWqWdS( Ntbuffertfailfasttcatcht catchbreaks-%sis--%s(R[R[(R\R\(R]R^( R.thasInstallHandlertsetattrR#R RtgetattrR+R(RR.targtattrt short_opttlong_optRXtnot_none((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestBufferCatchFailfasts     cCs|j}t|_d|_d|_d|_|j|jtjidd6dd6dd6|jtj d|j |j t dS(NR*R\R[R( R.RR(R*R\R[trunTestsRRLRtassertIsRRP(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerClasss       cCsb|j}t|_dt_|j|jtj|jtjd|j |j t dS(NR( R.RR(R#RLRhRVRRRiRRP(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerInstances    cCs|j}tt_t|_d|_d|_d|_d|_|j |j tj i|j tjd|j |j tdS(NR*R\R[R(R.RRRMR(R*R\R[RRhRRLRiRRP(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsOldRunnerClasss        cstjdjfd}j|t_fd}|_j}t|_t |_ |j j jdS(Ns unittest.maincs _dS(N(tinstallHandler((R7toriginal(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestorescs t_dS(N(Rt installed((R(s2/usr/lib64/python2.7/unittest/test/test_program.pytfakeInstallHandlers( tsystmodulesRmR,RRpR.RR^RR(RhR(RRoRqR.((R7RnRs2/usr/lib64/python2.7/unittest/test/test_program.pyttestCatchBreakInstallsHandlers         ( RRRSRYRZRgRjRkRlRt(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRQ}s      t__main__(t cStringIORR RrR t unittest.testRFRRRGR+RPRRQRR>(((s2/usr/lib64/python2.7/unittest/test/test_program.pyts    W  PK]D dummy.pyonu[ {fc@sdS(N((((s+/usr/lib64/python2.7/unittest/test/dummy.pyttPK]S.#Ď<<test_suite.pycnu[ |fc@sddlZddlZddlmZmZdefdYZdZdejefdYZ e dkrej ndS( iN(t LoggingResultt TestEqualitytTestcBs!eZdejfdYZRS(tFoocBs,eZdZdZdZdZRS(cCsdS(N((tself((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_1 tcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_2 RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_3RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pytrunTestR(t__name__t __module__RRRR (((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR s   (R R tunittesttTestCaseR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR scGstjd|DS(Ncss|]}tj|VqdS(N(RR(t.0tn((s0/usr/lib64/python2.7/unittest/test/test_suite.pys s(R t TestSuite(tnames((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt _mk_TestSuitestTest_TestSuitecBsyeZejejfejejgfededfgZejedfejgedfeddeddfededfgZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZRS(RRRcCs&tj}|j|jddS(Ni(R Rt assertEqualtcountTestCases(Rtsuite((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__tests_optional0s cCs)tjg}|j|jddS(Ni(R RRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__empty_tests<scCsd}tj|}|j|jdtj|}|j|jdtjt|}|j|jddS(Ncss&tjdVtjdVdS(NcSsdS(N(tNone(((s0/usr/lib64/python2.7/unittest/test/test_suite.pytIRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRJR(R tFunctionTestCase(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestsHsi(R RRRtset(RRtsuite_1tsuite_2tsuite_3((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt"test_init__tests_from_any_iterableGs cCs5d}tj|}|j|jddS(Ncss8tjd}tj|gVtjdVdS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR^RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR`R(R RR(tftc((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR]si(R RRR(RRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt'test_init__TestSuite_instances_in_tests\s cCsYtjd}tjd}tj||f}|jt|||gdS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRjRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRkR(R RRRtlist(Rttest1ttest2R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt test_iteriscCs&tj}|j|jddS(Ni(R RRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_simpleus cCsKdtjfdY}tjtjg}|j|jddS(NtTest1cBseZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttests(R R R*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)si(R R RRR(RR)R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_nestedscCsStjd}tjd}tj||f}|j|jddS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRi(R RRRR(RR%R&R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_simplescCsdtjfdY}tjd}tjd}tj|d|f}tj|||df}|j|jddS(NR)cBseZdZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&R(R R R%R&(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)s cSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRR&R%i(R R RRRR(RR)R&ttest3tchildtparent((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_nesteds cCs?g}t|}tj}|j||j|gdS(N(RR RtrunR(RteventstresultR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__empty_suites    cCs?tj}y|jWntk r-nX|jddS(NsFailed to raise TypeError(R RR1t TypeErrortfail(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__requires_results   csygt}dtjffdY}|d|dg}tj|j||jddgdS(Nt LoggingCasecs)eZfdZdZdZRS(csjd|jdS(Nsrun %s(tappendt_testMethodName(RR3(R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR1scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&R(R R R1R%R&((R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR8s R%R&s run test1s run test2(RR R RR1R(RR3R8R((R2s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_runs  cCsqdtjfdY}|d}tj}|j||j|jd|jt||gdS(NRcBseZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*R(R R R*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRsR*i(R R RtaddTestRRR$(RRR*R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestCases    cCs}dtjfdY}tj|dg}tj}|j||j|jd|jt||gdS(NRcBseZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*R(R R R*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRsR*i(R R RR<RRR$(RRRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestSuites   csdtjfdY}|d|dtjgfd}tj}|j||jt|t|tj}x|D]}|j|qW|j||dS(NRcBseZdZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRR(R R RR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs RRc3sVVVdS(N(((t inner_suiteRR(s0/usr/lib64/python2.7/unittest/test/test_suite.pytgens(R R RtaddTestsRR$R<(RRR@RRtt((R?RRs0/usr/lib64/python2.7/unittest/test/test_suite.pyt test_addTestss    cCsBtj}y|jdWntk r0nX|jddS(NisFailed to raise TypeError(R RRAR5R6(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noniterables   cCs&tj}|jt|jddS(Ni(R Rt assertRaisesR5R<(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noncallables cCs?tj}|jt|jt|jt|jtjdS(N(R RRER5R<R(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__casesuiteclasss cCs&tj}|jt|jddS(Ntfoo(R RRER5RA(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTests__string"s cCs9d}tj}|j||jtjdS(NcSsdS(N((t_((s0/usr/lib64/python2.7/unittest/test/test_suite.pytf's(R RR<R1t TestResult(RRKR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_function_in_suite&s   csDdtjfdY}dtffdYd|_tjd<|jtjjdtj}|j |d|dg|j |j dtj }|j ||jj|jj|j|j|j|j|j t|jd|j t|jd |j |jddS( NRcBsDeZeZeZedZedZdZdZ RS(cSs t|_dS(N(tTruetwasSetUp(tcls((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt setUpClass5scSs t|_dS(N(RNt wasTornDown(RP((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt tearDownClass8scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestPass;scSstdS(N(R6(R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestFail=s( R R tFalseRORRt classmethodRQRSRTRU(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR2s  tModulecs>eZeZeZefdZefdZRS(cs t_dS(N(RNRO((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyt setUpModuleBscs t_dS(N(RNRR((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyttearDownModuleEs(R R RVRORRt staticmethodRYRZ((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyRX?sRTRUiii(R R tobjectR tsystmodulest addCleanuptpopt BaseTestSuiteRARRRLR1t assertFalseRORRtlenterrorstfailuresttestsRun(RRRR3((RXs0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_basetestsuite1s"      cCsudtjfdY}|}tj}tj}|j||||j|j|j|jdS(NtMySuitecBseZeZdZRS(c_s#t|_tjj|||dS(N(RNtcalledR Rt__call__(Rtargstkw((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRj_s (R R RVRiRj(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRh]s(R RRLR<t assertTrueRiRbt_testRunEntered(RRhRR3twrapper((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_overriding_call\s     (R R R RRteq_pairstne_pairsRRR!R#R'R(R+R,R0R4R7R;R=R>RCRDRFRGRIRMRgRp(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs:         +t__main__( R R]tunittest.test.supportRRR\RRR RR tmain(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyts   X PK]S.#Ď<<test_suite.pyonu[ |fc@sddlZddlZddlmZmZdefdYZdZdejefdYZ e dkrej ndS( iN(t LoggingResultt TestEqualitytTestcBs!eZdejfdYZRS(tFoocBs,eZdZdZdZdZRS(cCsdS(N((tself((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_1 tcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_2 RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_3RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pytrunTestR(t__name__t __module__RRRR (((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR s   (R R tunittesttTestCaseR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR scGstjd|DS(Ncss|]}tj|VqdS(N(RR(t.0tn((s0/usr/lib64/python2.7/unittest/test/test_suite.pys s(R t TestSuite(tnames((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt _mk_TestSuitestTest_TestSuitecBsyeZejejfejejgfededfgZejedfejgedfeddeddfededfgZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZRS(RRRcCs&tj}|j|jddS(Ni(R Rt assertEqualtcountTestCases(Rtsuite((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__tests_optional0s cCs)tjg}|j|jddS(Ni(R RRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__empty_tests<scCsd}tj|}|j|jdtj|}|j|jdtjt|}|j|jddS(Ncss&tjdVtjdVdS(NcSsdS(N(tNone(((s0/usr/lib64/python2.7/unittest/test/test_suite.pytIRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRJR(R tFunctionTestCase(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestsHsi(R RRRtset(RRtsuite_1tsuite_2tsuite_3((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt"test_init__tests_from_any_iterableGs cCs5d}tj|}|j|jddS(Ncss8tjd}tj|gVtjdVdS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR^RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR`R(R RR(tftc((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR]si(R RRR(RRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt'test_init__TestSuite_instances_in_tests\s cCsYtjd}tjd}tj||f}|jt|||gdS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRjRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRkR(R RRRtlist(Rttest1ttest2R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt test_iteriscCs&tj}|j|jddS(Ni(R RRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_simpleus cCsKdtjfdY}tjtjg}|j|jddS(NtTest1cBseZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttests(R R R*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)si(R R RRR(RR)R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_nestedscCsStjd}tjd}tj||f}|j|jddS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRi(R RRRR(RR%R&R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_simplescCsdtjfdY}tjd}tjd}tj|d|f}tj|||df}|j|jddS(NR)cBseZdZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&R(R R R%R&(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)s cSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRR&R%i(R R RRRR(RR)R&ttest3tchildtparent((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_nesteds cCs?g}t|}tj}|j||j|gdS(N(RR RtrunR(RteventstresultR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__empty_suites    cCs?tj}y|jWntk r-nX|jddS(NsFailed to raise TypeError(R RR1t TypeErrortfail(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__requires_results   csygt}dtjffdY}|d|dg}tj|j||jddgdS(Nt LoggingCasecs)eZfdZdZdZRS(csjd|jdS(Nsrun %s(tappendt_testMethodName(RR3(R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR1scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&R(R R R1R%R&((R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR8s R%R&s run test1s run test2(RR R RR1R(RR3R8R((R2s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_runs  cCsqdtjfdY}|d}tj}|j||j|jd|jt||gdS(NRcBseZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*R(R R R*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRsR*i(R R RtaddTestRRR$(RRR*R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestCases    cCs}dtjfdY}tj|dg}tj}|j||j|jd|jt||gdS(NRcBseZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*R(R R R*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRsR*i(R R RR<RRR$(RRRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestSuites   csdtjfdY}|d|dtjgfd}tj}|j||jt|t|tj}x|D]}|j|qW|j||dS(NRcBseZdZdZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRRcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRR(R R RR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs RRc3sVVVdS(N(((t inner_suiteRR(s0/usr/lib64/python2.7/unittest/test/test_suite.pytgens(R R RtaddTestsRR$R<(RRR@RRtt((R?RRs0/usr/lib64/python2.7/unittest/test/test_suite.pyt test_addTestss    cCsBtj}y|jdWntk r0nX|jddS(NisFailed to raise TypeError(R RRAR5R6(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noniterables   cCs&tj}|jt|jddS(Ni(R Rt assertRaisesR5R<(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noncallables cCs?tj}|jt|jt|jt|jtjdS(N(R RRER5R<R(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__casesuiteclasss cCs&tj}|jt|jddS(Ntfoo(R RRER5RA(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTests__string"s cCs9d}tj}|j||jtjdS(NcSsdS(N((t_((s0/usr/lib64/python2.7/unittest/test/test_suite.pytf's(R RR<R1t TestResult(RRKR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_function_in_suite&s   csDdtjfdY}dtffdYd|_tjd<|jtjjdtj}|j |d|dg|j |j dtj }|j ||jj|jj|j|j|j|j|j t|jd|j t|jd |j |jddS( NRcBsDeZeZeZedZedZdZdZ RS(cSs t|_dS(N(tTruetwasSetUp(tcls((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt setUpClass5scSs t|_dS(N(RNt wasTornDown(RP((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt tearDownClass8scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestPass;scSstdS(N(R6(R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestFail=s( R R tFalseRORRt classmethodRQRSRTRU(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR2s  tModulecs>eZeZeZefdZefdZRS(cs t_dS(N(RNRO((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyt setUpModuleBscs t_dS(N(RNRR((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyttearDownModuleEs(R R RVRORRt staticmethodRYRZ((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyRX?sRTRUiii(R R tobjectR tsystmodulest addCleanuptpopt BaseTestSuiteRARRRLR1t assertFalseRORRtlenterrorstfailuresttestsRun(RRRR3((RXs0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_basetestsuite1s"      cCsudtjfdY}|}tj}tj}|j||||j|j|j|jdS(NtMySuitecBseZeZdZRS(c_s#t|_tjj|||dS(N(RNtcalledR Rt__call__(Rtargstkw((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRj_s (R R RVRiRj(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRh]s(R RRLR<t assertTrueRiRbt_testRunEntered(RRhRR3twrapper((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_overriding_call\s     (R R R RRteq_pairstne_pairsRRR!R#R'R(R+R,R0R4R7R;R=R>RCRDRFRGRIRMRgRp(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs:         +t__main__( R R]tunittest.test.supportRRR\RRR RR tmain(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyts   X PK]+%%test_skipping.pycnu[ |fc@sRddlZddlmZdejfdYZedkrNejndS(iN(t LoggingResulttTest_TestSkippingcBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCs dtjfdY}g}t|}|d}|j||j|dddg|j|j|dfgdtjfdY}g}t|}|d }|j||j|dddg|j|j|d fg|j|jd dS( NtFoocBseZdZRS(cSs|jddS(Ntskip(tskipTest(tself((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_skip_me s(t__name__t __module__R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR sRt startTesttaddSkiptstopTestRcBseZdZdZRS(cSs|jddS(Nttesting(R(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pytsetUpscSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_nothingt(RRR R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs RR i(tunittesttTestCaseRtrunt assertEqualtskippedttestsRun(RRteventstresultttest((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_skippings      c s6tjttftjttff}x |D]\dtjffdY}|d}|d}tj||g}g}t|}|j||j t |j dddddd dg}|j |||j |j d |j |j |d fg|j |jq+WdS( NRcs8eZddZddZRS(R cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_skip%scSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_dont_skip(s(RRRR((tdecotdo_skipt dont_skip(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR$sRRiR R R t addSuccessiR (Rt skipUnlesstFalsetTruetskipIfRt TestSuiteRRRtlenRRt assertTruet wasSuccessful( Rtop_tableRt test_do_skipRtsuiteRRtexpected((RRRs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skipping_decorators s"%     cstjddtjffdY}gtj}|d}tj|g}|j||j|j|dfg|jgdS(NR RcseZfdZRS(csjddS(Ni(tappend(R(trecord(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_1;s(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR9sR/(RRRt TestResultR$RRR(RRRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_class8s   cstjdddfdY}d|tjfdY}gtj}|d}tj|g}|j||j|j|dfg|jgdS(NR tMixincseZfdZRS(csjddS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Hs(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2FsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRJsR/((RRRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_old_styleEs(   cstjddtffdY}d|tjfdY}gtj}|d}tj|g}|j||j|j|dfg|jgdS(NR R2cseZfdZRS(csjddS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Ws(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2UsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRYsR/( RRtobjectRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_new_styleTs   cCsdtjfdY}g}t|}|d}|j||j|dddg|j|jdd||j|jdS(NRcBseZejdZRS(cSs|jddS(Nshelp me!(tfail(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_diees(RRRtexpectedFailureR7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRdsR7R taddExpectedFailureR i(RRRRRtexpectedFailuresR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_expected_failurecs    cCsdtjfdY}g}t|}|d}|j||j|dddg|j|j|j|j|g|j|j dS(NRcBseZejdZRS(cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR7ss(RRRR8R7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRrsR7R taddUnexpectedSuccessR ( RRRRRt assertFalsetfailurestunexpectedSuccessesR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_unexpected_successqs    csdtjffdYtj}d}tj|g}|j||j|j|dfg|jj|jj dS(NRcsJeZeZeZfdZfdZejddZ RS(cs t_dS(N(R"twasSetUp(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR scs t_dS(N(R"t wasTornDown(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttornDownsR cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/s( RRR!RARBR RCRRR/((R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs R/R ( RRR0R$RRRR=RARB(RRRR*((Rs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_doesnt_run_setups   csddtjffdY}tj}|d}tj|g}|j||j|j|dfgdS(Ncsfd}|S(Ncs |S(N((ta(tfunc(s3/usr/lib64/python2.7/unittest/test/test_skipping.pytinners((RFRG((RFs3/usr/lib64/python2.7/unittest/test/test_skipping.pyt decoratorsRcs&eZejddZRS(R cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/s(RRRRR/((RH(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRsR/R (RRR0R$RRR(RRRRR*((RHs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_decorated_skips    ( RRRR,R1R3R5R;R@RDRI(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs       t__main__(Rtunittest.test.supportRRRRtmain(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyts  PK]Fcw!!test_runner.pynu[import unittest from cStringIO import StringIO import pickle from unittest.test.support import (LoggingResult, ResultWithNoStartTestRunStopTestRun) class TestCleanUp(unittest.TestCase): def testCleanUp(self): class TestableTest(unittest.TestCase): def testNothing(self): pass test = TestableTest('testNothing') self.assertEqual(test._cleanups, []) cleanups = [] def cleanup1(*args, **kwargs): cleanups.append((1, args, kwargs)) def cleanup2(*args, **kwargs): cleanups.append((2, args, kwargs)) test.addCleanup(cleanup1, 1, 2, 3, four='hello', five='goodbye') test.addCleanup(cleanup2) self.assertEqual(test._cleanups, [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')), (cleanup2, (), {})]) result = test.doCleanups() self.assertTrue(result) self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))]) def testCleanUpWithErrors(self): class TestableTest(unittest.TestCase): def testNothing(self): pass class MockResult(object): errors = [] def addError(self, test, exc_info): self.errors.append((test, exc_info)) result = MockResult() test = TestableTest('testNothing') test._resultForDoCleanups = result exc1 = Exception('foo') exc2 = Exception('bar') def cleanup1(): raise exc1 def cleanup2(): raise exc2 test.addCleanup(cleanup1) test.addCleanup(cleanup2) self.assertFalse(test.doCleanups()) (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors) self.assertEqual((test1, Type1, instance1), (test, Exception, exc1)) self.assertEqual((test2, Type2, instance2), (test, Exception, exc2)) def testCleanupInRun(self): blowUp = False ordering = [] class TestableTest(unittest.TestCase): def setUp(self): ordering.append('setUp') if blowUp: raise Exception('foo') def testNothing(self): ordering.append('test') def tearDown(self): ordering.append('tearDown') test = TestableTest('testNothing') def cleanup1(): ordering.append('cleanup1') def cleanup2(): ordering.append('cleanup2') test.addCleanup(cleanup1) test.addCleanup(cleanup2) def success(some_test): self.assertEqual(some_test, test) ordering.append('success') result = unittest.TestResult() result.addSuccess = success test.run(result) self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup2', 'cleanup1', 'success']) blowUp = True ordering = [] test = TestableTest('testNothing') test.addCleanup(cleanup1) test.run(result) self.assertEqual(ordering, ['setUp', 'cleanup1']) def testTestCaseDebugExecutesCleanups(self): ordering = [] class TestableTest(unittest.TestCase): def setUp(self): ordering.append('setUp') self.addCleanup(cleanup1) def testNothing(self): ordering.append('test') def tearDown(self): ordering.append('tearDown') test = TestableTest('testNothing') def cleanup1(): ordering.append('cleanup1') test.addCleanup(cleanup2) def cleanup2(): ordering.append('cleanup2') test.debug() self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup1', 'cleanup2']) class Test_TextTestRunner(unittest.TestCase): """Tests for TextTestRunner.""" def test_init(self): runner = unittest.TextTestRunner() self.assertFalse(runner.failfast) self.assertFalse(runner.buffer) self.assertEqual(runner.verbosity, 1) self.assertTrue(runner.descriptions) self.assertEqual(runner.resultclass, unittest.TextTestResult) def test_multiple_inheritance(self): class AResult(unittest.TestResult): def __init__(self, stream, descriptions, verbosity): super(AResult, self).__init__(stream, descriptions, verbosity) class ATextResult(unittest.TextTestResult, AResult): pass # This used to raise an exception due to TextTestResult not passing # on arguments in its __init__ super call ATextResult(None, None, 1) def testBufferAndFailfast(self): class Test(unittest.TestCase): def testFoo(self): pass result = unittest.TestResult() runner = unittest.TextTestRunner(stream=StringIO(), failfast=True, buffer=True) # Use our result object runner._makeResult = lambda: result runner.run(Test('testFoo')) self.assertTrue(result.failfast) self.assertTrue(result.buffer) def testRunnerRegistersResult(self): class Test(unittest.TestCase): def testFoo(self): pass originalRegisterResult = unittest.runner.registerResult def cleanup(): unittest.runner.registerResult = originalRegisterResult self.addCleanup(cleanup) result = unittest.TestResult() runner = unittest.TextTestRunner(stream=StringIO()) # Use our result object runner._makeResult = lambda: result self.wasRegistered = 0 def fakeRegisterResult(thisResult): self.wasRegistered += 1 self.assertEqual(thisResult, result) unittest.runner.registerResult = fakeRegisterResult runner.run(unittest.TestSuite()) self.assertEqual(self.wasRegistered, 1) def test_works_with_result_without_startTestRun_stopTestRun(self): class OldTextResult(ResultWithNoStartTestRunStopTestRun): separator2 = '' def printErrors(self): pass class Runner(unittest.TextTestRunner): def __init__(self): super(Runner, self).__init__(StringIO()) def _makeResult(self): return OldTextResult() runner = Runner() runner.run(unittest.TestSuite()) def test_startTestRun_stopTestRun_called(self): class LoggingTextResult(LoggingResult): separator2 = '' def printErrors(self): pass class LoggingRunner(unittest.TextTestRunner): def __init__(self, events): super(LoggingRunner, self).__init__(StringIO()) self._events = events def _makeResult(self): return LoggingTextResult(self._events) events = [] runner = LoggingRunner(events) runner.run(unittest.TestSuite()) expected = ['startTestRun', 'stopTestRun'] self.assertEqual(events, expected) def test_pickle_unpickle(self): # Issue #7197: a TextTestRunner should be (un)pickleable. This is # required by test_multiprocessing under Windows (in verbose mode). from StringIO import StringIO as PickleableIO # cStringIO objects are not pickleable, but StringIO objects are. stream = PickleableIO("foo") runner = unittest.TextTestRunner(stream) for protocol in range(pickle.HIGHEST_PROTOCOL + 1): s = pickle.dumps(runner, protocol=protocol) obj = pickle.loads(s) # StringIO objects never compare equal, a cheap test instead. self.assertEqual(obj.stream.getvalue(), stream.getvalue()) def test_resultclass(self): def MockResultClass(*args): return args STREAM = object() DESCRIPTIONS = object() VERBOSITY = object() runner = unittest.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY, resultclass=MockResultClass) self.assertEqual(runner.resultclass, MockResultClass) expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY) self.assertEqual(runner._makeResult(), expectedresult) if __name__ == '__main__': unittest.main() PK]o5z4z4test_assertions.pyonu[ {fc@sgddlZddlZdejfdYZdejfdYZedkrcejndS(iNtTest_AssertionscBs,eZdZdZdZdZRS(cCsH|jdd|jdd|j|j|jdd|j|j|jdd|jdddd|j|j|jdddd|jdd dd|jdd dd|j|j|jdd dd|j|j|jdddd|jtd td |j|j|jtd td dS(Ng1?g?g?g?tplacesiig?y?tinfy??y??y??y??(tassertAlmostEqualtassertNotAlmostEqualt assertRaisestfailureExceptiontfloat(tself((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AlmostEquals$     c Cs|jdddd|jdddd|jdddd|jdddd|jdddd|j|j|jdddd|j|j|jdddd|j|j|jdddd|jt|jdddddd|jt|jddddddtjj}|tjdd }|j||dtjdd |j||dtjdd dS( Ng?g?tdeltag?g?Ritsecondsi ii(RRRRt TypeErrortdatetimetnowt timedelta(Rtfirsttsecond((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AmostEqualWithDeltas*c Csd}|jt|t|jt|tdy|jtdWn)|jk rw}|jd|jnX|jdy|jt|tWntk rnX|jd|jt*}y tWntk r}nXWdQX|j|j ||jttdWdQXy|jtWdQXWn)|jk rr}|jd|jnX|jdy |jt tWdQXWntk rnX|jddS(NcSs |dS(N((te((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt_raise:stkeycSsdS(N(tNone(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt?tsKeyError not raisedsassertRaises() didn't fails0assertRaises() didn't let exception pass through( RtKeyErrorRtassertIntargstfailt ValueErrort ExceptiontassertIst exception(RRRtcm((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_assertRaises9sB         cCs|jddy|jdddWnD|jk rm}|jd|jd|jd|jdnX|jddS(Ns Ala ma kotasr+sk.ttMessages'kot'is*assertNotRegexpMatches should have failed.(tassertNotRegexpMatchesRRRR(RR((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotRegexpMatchesbs(t__name__t __module__R RR"R%(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyRs   )tTestLongMessagecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(sTest that the individual asserts honour longMessage. This actually tests all the message behaviour for asserts that use longMessage.cs`dtjffdY}dtjffdY}|d_|d_dS(NtTestableTestFalsecs eZeZjZdZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestTestws(R&R'tFalset longMessageRR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR)ss tTestableTestTruecs eZeZjZdZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR*~s(R&R'tTrueR,RR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR-zs R*(tunittesttTestCaset testableTruet testableFalse(RR)R-((Rs5/usr/lib64/python2.7/unittest/test/test_assertions.pytsetUprscCs|jtjjdS(N(t assertFalseR/R0R,(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testDefaultscCs|j|jjddd|j|jjddd|j|jjddd|j|jjddd|jjtddS(Ntfootbars bar : foo(t assertEqualR2t_formatMessageRR1tobject(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_formatMsgs cCs6djdtdD}|jj|ddS(NRcss|]}t|VqdS(N(tchr(t.0ti((s5/usr/lib64/python2.7/unittest/test/test_assertions.pys siu�(tjointrangeR1R9(Rtone((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt test_formatMessage_unicode_errorsc sfd}xxt|D]j\}}||}i}|d} | r]idd6}njjd||||WdQXqWdS(Ncs4|dk}|rj}n j}t|S(Ni(R2R1tgetattr(R>tuseTestableFalsettest(t methodNameR(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt getMethods    itoopstmsgtexpected_regexp(t enumeratetassertRaisesRegexpR( RRFRterrorsRGR>RJt testMethodtkwargstwithMsg((RFRs5/usr/lib64/python2.7/unittest/test/test_assertions.pytassertMessagess   cCs&|jdtfddddgdS(Nt assertTrues^False is not true$s^oops$s^False is not true : oops$(RQR+(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertTrues cCs&|jdtfddddgdS(NR4s^True is not false$s^oops$s^True is not false : oops$(RQR.(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertFalses cCs#|jddddddgdS(NtassertNotEqualis^1 == 1$s^oops$s^1 == 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testNotEquals  cCs#|jddddddgdS(NRiis^1 != 2 within 7 places$s^oops$s^1 != 2 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAlmostEquals cCs#|jddddddgdS(NRis^1 == 1 within 7 places$s^oops$s^1 == 1 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestNotAlmostEquals cCs#|jddddddgdS(Nt_baseAssertEqualiis^1 != 2$s^oops$s^1 != 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_baseAssertEquals cCs,|jdgdgfddddgdS(NtassertSequenceEquals \+ \[None\]$s^oops$s\+ \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSequenceEquals cCs5|jdttdgfddddgdS(NtassertSetEqualsNone$s^oops$s None : oops$(RQtsetR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSetEquals cCs)|jddgfddddgdS(NRs^None not found in \[\]$s^oops$s^None not found in \[\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testAssertInscCs,|jdddgfddddgdS(Nt assertNotIns%^None unexpectedly found in \[None\]$s^oops$s,^None unexpectedly found in \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotInscCs0|jdiidd6fddddgdS(NtassertDictEqualtvalueRs\+ \{'key': 'value'\}$s^oops$s\+ \{'key': 'value'\} : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictEqualscCs0|jdidd6ifddddgdS(NtassertDictContainsSubsetRdRs^Missing: 'key'$s^oops$s^Missing: 'key' : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictContainsSubsetscCs#|jddddddgdS(NtassertMultiLineEqualRR6s\+ foo$s^oops$s\+ foo : oops$(RR6(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertMultiLineEquals cCs#|jddddddgdS(Nt assertLessiis^2 not less than 1$s^oops$s^2 not less than 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLesss cCs#|jddddddgdS(NtassertLessEqualiis^2 not less than or equal to 1$s^oops$s&^2 not less than or equal to 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLessEquals cCs#|jddddddgdS(Nt assertGreateriis^1 not greater than 2$s^oops$s^1 not greater than 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreaters cCs#|jddddddgdS(NtassertGreaterEqualiis"^1 not greater than or equal to 2$s^oops$s)^1 not greater than or equal to 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreaterEquals cCs#|jddddddgdS(Nt assertIsNonesnot Nones^'not None' is not None$s^oops$s^'not None' is not None : oops$(snot None(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNones cCs#|jddddddgdS(NtassertIsNotNones^unexpectedly None$s^oops$s^unexpectedly None : oops$(N(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNotNones cCs#|jddddddgdS(NRR6s^None is not 'foo'$s^oops$s^None is not 'foo' : oops$(NR6(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt testAssertIss cCs#|jddddddgdS(Nt assertIsNots^unexpectedly identical: None$s^oops$s%^unexpectedly identical: None : oops$(NN(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNots (R&R't__doc__R3R5R;RBRQRSRTRVRWRXRZR\R_R`RbReRgRiRkRmRoRqRsRuRvRx(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR(ms6                        t__main__(R R/R0RR(R&tmain(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyts  g PK]grx%% test_break.pynu[import gc import os import sys import signal import weakref from cStringIO import StringIO import unittest @unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") @unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreak(unittest.TestCase): int_handler = None def setUp(self): self._default_handler = signal.getsignal(signal.SIGINT) if self.int_handler is not None: signal.signal(signal.SIGINT, self.int_handler) def tearDown(self): signal.signal(signal.SIGINT, self._default_handler) unittest.signals._results = weakref.WeakKeyDictionary() unittest.signals._interrupt_handler = None def testInstallHandler(self): default_handler = signal.getsignal(signal.SIGINT) unittest.installHandler() self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) try: pid = os.getpid() os.kill(pid, signal.SIGINT) except KeyboardInterrupt: self.fail("KeyboardInterrupt not handled") self.assertTrue(unittest.signals._interrupt_handler.called) def testRegisterResult(self): result = unittest.TestResult() unittest.registerResult(result) for ref in unittest.signals._results: if ref is result: break elif ref is not result: self.fail("odd object in result set") else: self.fail("result not found") def testInterruptCaught(self): default_handler = signal.getsignal(signal.SIGINT) result = unittest.TestResult() unittest.installHandler() unittest.registerResult(result) self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) def test(result): pid = os.getpid() os.kill(pid, signal.SIGINT) result.breakCaught = True self.assertTrue(result.shouldStop) try: test(result) except KeyboardInterrupt: self.fail("KeyboardInterrupt not handled") self.assertTrue(result.breakCaught) def testSecondInterrupt(self): # Can't use skipIf decorator because the signal handler may have # been changed after defining this method. if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: self.skipTest("test requires SIGINT to not be ignored") result = unittest.TestResult() unittest.installHandler() unittest.registerResult(result) def test(result): pid = os.getpid() os.kill(pid, signal.SIGINT) result.breakCaught = True self.assertTrue(result.shouldStop) os.kill(pid, signal.SIGINT) self.fail("Second KeyboardInterrupt not raised") try: test(result) except KeyboardInterrupt: pass else: self.fail("Second KeyboardInterrupt not raised") self.assertTrue(result.breakCaught) def testTwoResults(self): unittest.installHandler() result = unittest.TestResult() unittest.registerResult(result) new_handler = signal.getsignal(signal.SIGINT) result2 = unittest.TestResult() unittest.registerResult(result2) self.assertEqual(signal.getsignal(signal.SIGINT), new_handler) result3 = unittest.TestResult() def test(result): pid = os.getpid() os.kill(pid, signal.SIGINT) try: test(result) except KeyboardInterrupt: self.fail("KeyboardInterrupt not handled") self.assertTrue(result.shouldStop) self.assertTrue(result2.shouldStop) self.assertFalse(result3.shouldStop) def testHandlerReplacedButCalled(self): # Can't use skipIf decorator because the signal handler may have # been changed after defining this method. if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: self.skipTest("test requires SIGINT to not be ignored") # If our handler has been replaced (is no longer installed) but is # called by the *new* handler, then it isn't safe to delay the # SIGINT and we should immediately delegate to the default handler unittest.installHandler() handler = signal.getsignal(signal.SIGINT) def new_handler(frame, signum): handler(frame, signum) signal.signal(signal.SIGINT, new_handler) try: pid = os.getpid() os.kill(pid, signal.SIGINT) except KeyboardInterrupt: pass else: self.fail("replaced but delegated handler doesn't raise interrupt") def testRunner(self): # Creating a TextTestRunner with the appropriate argument should # register the TextTestResult it creates runner = unittest.TextTestRunner(stream=StringIO()) result = runner.run(unittest.TestSuite()) self.assertIn(result, unittest.signals._results) def testWeakReferences(self): # Calling registerResult on a result should not keep it alive result = unittest.TestResult() unittest.registerResult(result) ref = weakref.ref(result) del result # For non-reference counting implementations gc.collect();gc.collect() self.assertIsNone(ref()) def testRemoveResult(self): result = unittest.TestResult() unittest.registerResult(result) unittest.installHandler() self.assertTrue(unittest.removeResult(result)) # Should this raise an error instead? self.assertFalse(unittest.removeResult(unittest.TestResult())) try: pid = os.getpid() os.kill(pid, signal.SIGINT) except KeyboardInterrupt: pass self.assertFalse(result.shouldStop) def testMainInstallsHandler(self): failfast = object() test = object() verbosity = object() result = object() default_handler = signal.getsignal(signal.SIGINT) class FakeRunner(object): initArgs = [] runArgs = [] def __init__(self, *args, **kwargs): self.initArgs.append((args, kwargs)) def run(self, test): self.runArgs.append(test) return result class Program(unittest.TestProgram): def __init__(self, catchbreak): self.exit = False self.verbosity = verbosity self.failfast = failfast self.catchbreak = catchbreak self.testRunner = FakeRunner self.test = test self.result = None p = Program(False) p.runTests() self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None, 'verbosity': verbosity, 'failfast': failfast})]) self.assertEqual(FakeRunner.runArgs, [test]) self.assertEqual(p.result, result) self.assertEqual(signal.getsignal(signal.SIGINT), default_handler) FakeRunner.initArgs = [] FakeRunner.runArgs = [] p = Program(True) p.runTests() self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None, 'verbosity': verbosity, 'failfast': failfast})]) self.assertEqual(FakeRunner.runArgs, [test]) self.assertEqual(p.result, result) self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) def testRemoveHandler(self): default_handler = signal.getsignal(signal.SIGINT) unittest.installHandler() unittest.removeHandler() self.assertEqual(signal.getsignal(signal.SIGINT), default_handler) # check that calling removeHandler multiple times has no ill-effect unittest.removeHandler() self.assertEqual(signal.getsignal(signal.SIGINT), default_handler) def testRemoveHandlerAsDecorator(self): default_handler = signal.getsignal(signal.SIGINT) unittest.installHandler() @unittest.removeHandler def test(): self.assertEqual(signal.getsignal(signal.SIGINT), default_handler) test() self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) @unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") @unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreakDefaultIntHandler(TestBreak): int_handler = signal.default_int_handler @unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") @unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreakSignalIgnored(TestBreak): int_handler = signal.SIG_IGN @unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") @unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreakSignalDefault(TestBreak): int_handler = signal.SIG_DFL PK]}'test_functiontestcase.pycnu[ |fc@sRddlZddlmZdejfdYZedkrNejndS(iN(t LoggingResulttTest_FunctionTestCasecBsPeZdZdZdZdZdZdZdZdZ RS(cCs,tjd}|j|jddS(NcSsdS(N(tNone(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt ti(tunittesttFunctionTestCaset assertEqualtcountTestCases(tselfttest((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_countTestCases scsgt}fd}fd}fd}ddddg}tj|||j||j|dS(NcsjdtddS(NtsetUpsraised by setUp(tappendt RuntimeError((tevents(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR s csjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR scsjddS(NttearDown(R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR!st startTestR taddErrortstopTest(RRRtrunR(R tresultR R Rtexpected((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_run_call_order__error_in_setUps csgt}fd}fd}fd}dddddd g}tj|||j||j|dS( NcsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR 3scsjdtddS(NR sraised by test(R R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR 6s csjddS(NR(R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR:sRR R RRR(RRRRR(R RR R RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt"test_run_call_order__error_in_test/s  csgt}fd}fd}fd}dddddd g}tj|||j|j|dS( NcsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR MscsjdjddS(NR sraised by test(R tfail((RR (s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR Ps csjddS(NR(R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRTsRR R t addFailureRR(RRRRR(R RR R RR((RR s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt$test_run_call_order__failure_in_testIs  csgt}fd}fd}fd}dddddd g}tj|||j||j|dS( NcsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR gscsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR jscsjdtddS(NRsraised by tearDown(R R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRms RR R RRR(RRRRR(R RR R RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt&test_run_call_order__error_in_tearDowncs  cCs,tjd}|j|jtdS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR}R(RRtassertIsInstancetidt basestring(R R ((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_id|scCs,tjd}|j|jddS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRR(RRRtshortDescriptionR(R R ((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_shortDescription__no_docstringscCs8d}tjdd|}|j|jddS(Nsthis tests foocSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRRt description(RRRR!(R tdescR ((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt+test_shortDescription__singleline_docstrings( t__name__t __module__R RRRRR R"R%(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRs      t__main__(Rtunittest.test.supportRtTestCaseRR&tmain(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyts  PK]Yotest_functiontestcase.pynu[import unittest from unittest.test.support import LoggingResult class Test_FunctionTestCase(unittest.TestCase): # "Return the number of tests represented by the this test object. For # TestCase instances, this will always be 1" def test_countTestCases(self): test = unittest.FunctionTestCase(lambda: None) self.assertEqual(test.countTestCases(), 1) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if setUp() raises # an exception. def test_run_call_order__error_in_setUp(self): events = [] result = LoggingResult(events) def setUp(): events.append('setUp') raise RuntimeError('raised by setUp') def test(): events.append('test') def tearDown(): events.append('tearDown') expected = ['startTest', 'setUp', 'addError', 'stopTest'] unittest.FunctionTestCase(test, setUp, tearDown).run(result) self.assertEqual(events, expected) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if the test raises # an error (as opposed to a failure). def test_run_call_order__error_in_test(self): events = [] result = LoggingResult(events) def setUp(): events.append('setUp') def test(): events.append('test') raise RuntimeError('raised by test') def tearDown(): events.append('tearDown') expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown', 'stopTest'] unittest.FunctionTestCase(test, setUp, tearDown).run(result) self.assertEqual(events, expected) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if the test signals # a failure (as opposed to an error). def test_run_call_order__failure_in_test(self): events = [] result = LoggingResult(events) def setUp(): events.append('setUp') def test(): events.append('test') self.fail('raised by test') def tearDown(): events.append('tearDown') expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown', 'stopTest'] unittest.FunctionTestCase(test, setUp, tearDown).run(result) self.assertEqual(events, expected) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if tearDown() raises # an exception. def test_run_call_order__error_in_tearDown(self): events = [] result = LoggingResult(events) def setUp(): events.append('setUp') def test(): events.append('test') def tearDown(): events.append('tearDown') raise RuntimeError('raised by tearDown') expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError', 'stopTest'] unittest.FunctionTestCase(test, setUp, tearDown).run(result) self.assertEqual(events, expected) # "Return a string identifying the specific test case." # # Because of the vague nature of the docs, I'm not going to lock this # test down too much. Really all that can be asserted is that the id() # will be a string (either 8-byte or unicode -- again, because the docs # just say "string") def test_id(self): test = unittest.FunctionTestCase(lambda: None) self.assertIsInstance(test.id(), basestring) # "Returns a one-line description of the test, or None if no description # has been provided. The default implementation of this method returns # the first line of the test method's docstring, if available, or None." def test_shortDescription__no_docstring(self): test = unittest.FunctionTestCase(lambda: None) self.assertEqual(test.shortDescription(), None) # "Returns a one-line description of the test, or None if no description # has been provided. The default implementation of this method returns # the first line of the test method's docstring, if available, or None." def test_shortDescription__singleline_docstring(self): desc = "this tests foo" test = unittest.FunctionTestCase(lambda: None, description=desc) self.assertEqual(test.shortDescription(), "this tests foo") if __name__ == '__main__': unittest.main() PK]Ij̟''test_break.pycnu[ {fc@sddlZddlZddlZddlZddlZddlmZddlZeje eddej ej dkdej ej dkdd ej fd YZ eje eddej ej dkdej ej dkdd e fd YZeje eddej ej dkdej ej dkdd e fdYZeje eddej ej dkdej ej dkdde fdYZdS(iN(tStringIOtkillsTest requires os.killtwin32sTest cannot run on Windowstfreebsd6s9Test kills regrtest on freebsd6 if threads have been usedt TestBreakcBseZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZRS(cCsAtjtj|_|jdk r=tjtj|jndS(N(tsignalt getsignaltSIGINTt_default_handlert int_handlertNone(tself((s0/usr/lib64/python2.7/unittest/test/test_break.pytsetUpscCs8tjtj|jtjtj_dtj_ dS(N( RRRtweakreftWeakKeyDictionarytunittesttsignalst_resultsR t_interrupt_handler(R ((s0/usr/lib64/python2.7/unittest/test/test_break.pyttearDownscCstjtj}tj|jtjtj|y#tj}tj|tjWnt k r{|j dnX|j tj j jdS(NsKeyboardInterrupt not handled(RRRRtinstallHandlertassertNotEqualtostgetpidRtKeyboardInterrupttfailt assertTrueRRtcalled(R tdefault_handlertpid((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestInstallHandlers   cCsmtj}tj|xMtjjD]2}||kr<Pq&||k r&|jdq&q&W|jddS(Nsodd object in result setsresult not found(Rt TestResulttregisterResultRRR(R tresulttref((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRegisterResult,s    cstjtj}tj}tjtj|jtjtj|fd}y||Wntk rj dnXj |j dS(Ncs<tj}tj|tjt|_j|jdS(N( RRRRRtTruet breakCaughtRt shouldStop(R!R(R (s0/usr/lib64/python2.7/unittest/test/test_break.pyttestBs  sKeyboardInterrupt not handled( RRRRRRR RRRRR%(R RR!R'((R s0/usr/lib64/python2.7/unittest/test/test_break.pyttestInterruptCaught9s    cstjtjtjkr+jdntj}tjtj|fd}y||Wnt k r~nXj dj |j dS(Ns&test requires SIGINT to not be ignoredcs\tj}tj|tjt|_j|jtj|tjj ddS(Ns#Second KeyboardInterrupt not raised( RRRRRR$R%RR&R(R!R(R (s0/usr/lib64/python2.7/unittest/test/test_break.pyR'Xs   s#Second KeyboardInterrupt not raised( RRRtSIG_IGNtskipTestRRRR RRRR%(R R!R'((R s0/usr/lib64/python2.7/unittest/test/test_break.pyttestSecondInterruptOs     cCstjtj}tj|tjtj}tj}tj||jtjtj|tj}d}y||Wntk r|j dnX|j |j |j |j |j |j dS(NcSs#tj}tj|tjdS(N(RRRRR(R!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyR'vs sKeyboardInterrupt not handled( RRRR RRRt assertEqualRRRR&t assertFalse(R R!t new_handlertresult2tresult3R'((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestTwoResultsis         cstjtjtjkr+|jdntjtjtjfd}tjtj|y#tj}tj |tjWnt k rnX|j ddS(Ns&test requires SIGINT to not be ignoredcs||dS(N((tframetsignum(thandler(s0/usr/lib64/python2.7/unittest/test/test_break.pyR.ss6replaced but delegated handler doesn't raise interrupt( RRRR)R*RRRRRRR(R R.R((R4s0/usr/lib64/python2.7/unittest/test/test_break.pyttestHandlerReplacedButCalleds   cCsDtjdt}|jtj}|j|tjjdS(Ntstream(RtTextTestRunnerRtrunt TestSuitetassertInRR(R trunnerR!((s0/usr/lib64/python2.7/unittest/test/test_break.pyt testRunnerscCsStj}tj|tj|}~tjtj|j|dS(N(RRR R R"tgctcollectt assertIsNone(R R!R"((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestWeakReferencess   cCstj}tj|tj|jtj||jtjtjy#tj}tj |t j Wnt k rnX|j|j dS(N(RRR RRt removeResultR-RRRRRRR&(R R!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveResults     cstttttjtj}dtffdYdtjffdY}|t}|j|jj didd6d6d6fg|jj g|j|j |jtjtj|g_ g_ |t }|j|jj d idd6d6d6fg|jj g|j|j |jtjtj|dS( Nt FakeRunnercs,eZgZgZdZfdZRS(c_s|jj||fdS(N(tinitArgstappend(R targstkwargs((s0/usr/lib64/python2.7/unittest/test/test_break.pyt__init__scs|jj|S(N(trunArgsRE(R R'(R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyR8s(t__name__t __module__RDRIRHR8((R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyRCs tProgramcs eZfdZRS(csCt|_|_|_||_|_|_d|_dS(N( tFalsetexitt verbositytfailfastt catchbreakR<R'R R!(R RQ(RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRHs      (RJRKRH((RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRLstbufferRORP(((tobjectRRRRt TestProgramRMtrunTestsR,RDR RIR!R$R(R RRLtp((RCRPR!R'ROs0/usr/lib64/python2.7/unittest/test/test_break.pyttestMainInstallsHandlers2     (      cCsltjtj}tjtj|jtjtj|tj|jtjtj|dS(N(RRRRRt removeHandlerR,(R R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandlers    cs^tjtjtjtjfd}|jtjtjdS(Ncs jtjtjdS(N(R,RRR((RR (s0/usr/lib64/python2.7/unittest/test/test_break.pyR's(RRRRRRXR(R R'((RR s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandlerAsDecorators  N(RJRKR R R RRR#R(R+R1R5R<R@RBRWRYRZ(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR s         2 tTestBreakDefaultIntHandlercBseZejZRS((RJRKRtdefault_int_handlerR (((s0/usr/lib64/python2.7/unittest/test/test_break.pyR[ stTestBreakSignalIgnoredcBseZejZRS((RJRKRR)R (((s0/usr/lib64/python2.7/unittest/test/test_break.pyR]stTestBreakSignalDefaultcBseZejZRS((RJRKRtSIG_DFLR (((s0/usr/lib64/python2.7/unittest/test/test_break.pyR^s(R=RtsysRR t cStringIORRt skipUnlessthasattrtskipIftplatformtTestCaseRR[R]R^(((s0/usr/lib64/python2.7/unittest/test/test_break.pyts,      PK]CVEEtest_discovery.pycnu[ {fc@srddlZddlZddlZddlZddlZdejfdYZedkrnejndS(iNt TestDiscoverycBs}eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( cCsetj}d|_|jd}|j|dts>dS|jt|jdWdQXdS(Ns/foos/foo/bar/baz.pysbar.bazs /bar/baz.py(tunittestt TestLoadert_top_level_dirt_get_name_from_patht assertEqualt __debug__t assertRaisestAssertionError(tselftloadertname((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_get_name_from_path s  c stj}tjfd}tjjfd}tjjfd}dddddd d gd d ggfd t_|j|d}|tj_|j|d}|tj_|j|d|_d|_ tjj d}||_ t |j |d}gdD]} | d^q6} | jgdD]} d| d^qY|j|| dS(Ncs t_dS(N(tostlistdir((toriginal_listdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_listdirscstj_dS(N(R tpathtisfile((toriginal_isfile(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_isfile!scstj_dS(N(R Rtisdir((toriginal_isdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt restore_isdir$sstest1.pystest2.pys not_a_test.pyttest_dirstest.foostest-not-a-module.pyt another_dirstest3.pystest4.pycs jdS(Ni(tpop(R(t path_lists(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt*tcSs |jdS(Ntdir(tendswith(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR-scSs|jd od|kS(NRR(R(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR2scSs|dS(Ns module((R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR8RcSs|dS(Ns tests((tmodule((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR9Rs/foostest*.pyttest1ttest2s module teststtest3ttest4s test_dir.%s(R!R"(R#R$(RRR RRRRt addCleanupt_get_module_from_nametloadTestsFromModuletabspathRtlistt _find_teststextendR( R R RRRRRt top_leveltsuiteR texpected((RRRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_testss8                 cstj}tjfd}tjjfd}tjjfd}dddgggggfdt_j|dtj_j|fd tj_j|d tfd Yfd |_ fd }||_ d|_ t |j dd}j|dddgjjddgjj|dddfgdS(Ncs t_dS(N(R R((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRIscstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRLscstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyROst a_directoryttest_directoryttest_directory2cs jdS(Ni(R(R(R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRTRcSstS(N(tTrue(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRWRcstjj|kS(N(R Rtbasename(R(t directories(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRZRtModulecBs,eZgZgZdZdZdZRS(csP|_jj|tjj|dkrLfd}|_ndS(NR1csjj|||fdS(Nt load_tests(tload_tests_argstappend(R tteststpattern(R (s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR7es(RtpathsR9R R4R7(R RR7((R s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__init__as  cSs|j|jkS(N(R(R tother((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__eq__jsN(t__name__t __module__R<R8R=R?tNonet__hash__(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR6]s  cs |S(N((R (R6(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRpRcs#|rjdn|jdS(Ns+use_load_tests should be False for packagess module tests(tfailureExceptionR(R tuse_load_tests(R (s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR'qss/foostest*R7s module tests(RRR RRRRR%tobjectR&R'RR)R*RR<R8(R R RRRR'R-((R6R5RRRRR s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_tests_with_packageEs4           c stj}tjjtjjfd}dtj_|j|tjfd}|j|tjjtjj d}|j t |j dddWdQX|j |j||j|tjdtj_dtj_fd }|j|gfd }||_t|_|j d d d}tjjd}tjjd } |j |d |j |j||j | d fg|j|tjdS(Ncstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRscSstS(N(tFalse(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcstj(dS(N(tsysR((t orig_sys_path(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt restore_pathss/foos/foo/bart top_level_dircSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcstj_dS(N(R RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRscsj||fdgS(NR:(R9(t start_dirR;(t_find_tests_args(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*ss /foo/bar/bazR;s ['tests'](RRR RRRR%RIR(tnormpathRt ImportErrortdiscoverRRtassertInR*tstrt suiteClass( R R RRKt full_pathRR*R-RLRM((RNRJRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt test_discovers:         cstj}tjdt_tjjdtj_tjfd}|j||jd}|j tj tj|j |j dt t |dd}|jt|jWdQXdS(NcSsdgS(Nstest_this_does_not_exist.py((t_((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRcs#tj_t_tj(dS(N(R RRRRI((RRRJ(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestores  t.ii(RRR RRRRIR%RQRRtgetcwdRtcountTestCasesR)RRPttest_this_does_not_exist(R R RXR-ttest((RRRJs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt.test_discover_with_modules_that_fail_to_imports      cstjtj}gfd}||_|jddg|jg|jddddg|jddgdS(Ncsj|dS(N(R+(targv(targs(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt do_discoveryst somethingRQtfootbar(RFt__new__Rt TestProgramt _do_discoveryt parseArgsR(R tprogramRa((R`s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt$test_command_line_handling_parseArgss c s|dtfdYfd}tjtj}||_d|_|j|j ddddgWdQXdS(NtStopcBseZRS((R@RA(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRkscs dS(N(((Rk(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt usageExitstonettwotthreetfour( t ExceptionRFReRRfRlRBt testLoaderRRg(R RlRi((Rks4/usr/lib64/python2.7/unittest/test/test_discovery.pyt:test_command_line_handling_do_discovery_too_many_argumentss  cCs^tjtj}dtfdY}||_|jdg|j|jdgdS(NtLoadercBseZgZdZRS(cSs|jj|||fdS(NR:(R`R9(R RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQs(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRtss-vRYstest*.py(RYstest*.pyN( RFReRRfRrRgRR`RB(R RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt;test_command_line_handling_do_discovery_uses_default_loaders  cCstjtj}dtfdY}|jdgd||j|jd|j|jd|j|jdgg|_tjtj}|jdgd||j|jd|j|jdgg|_tjtj}|jgd||j|jd|j|jdgg|_tjtj}|jd gd||j|jd|j|jdgg|_tjtj}|jd d gd||j|jd|j|jdgg|_tjtj}|jd d d gd||j|jd|j|jdgg|_tjtj}|jd d gd||j|jd|j|jdgg|_tjtj}|jd d gd||j|jd|j|jdgg|_tjtj}|jdd gd||j|jd|j|jdg|j |j |j |j g|_tjtj}|jdd d d dddgd||j|jd|j|jdg|j|jd|j |j |j |j dS(NRtcBseZgZdZRS(cSs|jj|||fdS(NR:(R`R9(R RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQs(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRtss-viR:RYstest*.pys --verbosetfishteggsthams-ss-ts-ps-fs-c(RYstest*.pyN(RYstest*.pyN(RYstest*.pyN(Rvstest*.pyN(RvRwN(RvRwRx(Rvstest*.pyN(RYstest*.pyRv(RYRvN(RvRwN(RFReRRfRgRt verbosityR]R`RBt assertFalsetfailfastt catchbreakt assertTrue(R RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt4test_command_line_handling_do_discovery_calls_loadersr         !csdtfdY}|tjds           cCs|j}tj}tjjd}tjjd}tjd||f}|jt d||j dddd|j t jd|dS( NRdRcsZ'foo' module incorrectly imported from %r. Expected %r. Is this module globally installed?s^%s$RMR;sfoo.pyi( RRRR RR(tretescapetassertRaisesRegexpRPRQRRI(R RUR tmod_dirt expected_dirtmsg((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_detect_module_clash[s    cs|j}tjjtjjdtjjdfd}|j|fd}|tj_tj}|jdddddS(NRdRccstj_dS(N(R Rtrealpath((toriginal_realpath(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRqscs2|tjjdkr.tjjdS|S(Nsfoo.py(R Rtjoin(R(RR(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRusRMR;sfoo.py( RR RRR(R%RRRQ(R RURRR ((RRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_module_symlink_okis     cstj}gtjjtjjtjjt_ fd}||_ |j d}j j j |jdS(Ncst_j|S(N(R3twasRunR(RMR;(t expectedPathR R:(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*s s unittest.test(RRR RR(tdirnameR]RRHRR*RQR}Rt_tests(R R R*R-((RR R:s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_discovery_from_dotted_path}s  $  (R@RAR R/RGRVR^RjRsRuR~RRRR(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR s  + A .    J   t__main__( R RRIRt unittest.testtTestCaseRR@tmain(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyts      PK]lױœtest_loader.pycnu[ |fc@sZddlZddlZddlZdejfdYZedkrVejndS(iNtTest_TestLoadercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!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-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Z<d;Z=d<Z>d=Z?d>Z@d?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIRS(HcCscdtjfdY}tj|d|dg}tj}|j|j||dS(NtFoocBs#eZdZdZdZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_1tcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_2RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoo_barR(t__name__t __module__RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR(tunittesttTestCaset TestSuitet TestLoadert assertEqualtloadTestsFromTestCase(RRtteststloader((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_loadTestsFromTestCases! cCsNdtjfdY}tj}tj}|j|j||dS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs(R R R R R R(RRt empty_suiteR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromTestCase__no_matchess  cCs[dtjfdY}tj}y|j|Wntk rInX|jddS(Nt NotATestCasecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR1ssShould raise TypeError(R R R Rt TypeErrortfail(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromTestCase__TestSuite_subclass0s  cCsdtjfdY}tj}|jdj|j|j|}|j||j|j t ||dgdS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytrunTestDs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRCsR( R R R t assertFalset startswithttestMethodPrefixRtassertIsInstancet suiteClassR tlist(RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromTestCase__default_method_nameBs  cCstjd}dtjfdY}||_tj}|j|}|j||j|j|dgg}|j t ||dS(Ntmt MyTestCasecBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttestYs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"XsR#( ttypest ModuleTypeR R t testcase_1R tloadTestsFromModuleRRR R(RR!R"RRtexpected((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__TestCase_subclassVs  cCsWtjd}tj}|j|}|j||j|jt|gdS(NR!( R$R%R R R'RRR R(RR!RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromModule__no_TestCase_instancesgs  cCstjd}dtjfdY}||_tj}|j|}|j||j|j t ||jgdS(NR!R"cBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"ts( R$R%R R R&R R'RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__no_TestCase_testsrs  csdtjfdYdtffdY}tj}|j|}tjdgg}|jt||dS(NR"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"st NotAModulecseZZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,sR#(R R tobjectR R'R R R(RR,RRt reference((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromModule__not_a_modules  cstjd}dtjfdY}||_gfd}||_tj}|j|}j|tj j ||dgg|j|dt }j gdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"scs-j|tjj|||f|S(N(RR R textend(RRtpattern(tload_tests_argsR(s1/usr/lib64/python2.7/unittest/test/test_loader.pyt load_testsstuse_load_tests( R$R%R R R&R3R R'RR R tNonetFalse(RR!R"R3RR((R2Rs1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_loadTestsFromModule__load_testss   cCstjd}d}||_tj}|j|}|j|tj|j|j dt |d}|j t d|j dS(NR!cSstddS(Ns some failure(R(RRR1((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR3siis some failure(R$R%R3R R R'RR R tcountTestCasesRtassertRaisesRegexpRR!(RR!R3RRR#((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__faulty_load_testss   cCsZtj}y|jdWn)tk rH}|jt|dnX|jddS(NRsEmpty module names7TestLoader.loadTestsFromName failed to raise ValueError(R R tloadTestsFromNamet ValueErrorR tstrR(RRte((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_loadTestsFromName__empty_names  cCsRtj}y|jdWn!tk r0ntk r@nX|jddS(Ns abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R R R;R<t ImportErrorR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromName__malformed_names   cCsZtj}y|jdWn)tk rH}|jt|dnX|jddS(Nt sdasfasfasdfsNo module named sdasfasfasdfs8TestLoader.loadTestsFromName failed to raise ImportError(R R R;R@R R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__unknown_module_names  cCsZtj}y|jdWn)tk rH}|jt|dnX|jddS(Nsunittest.sdasfasfasdfs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R R;tAttributeErrorR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__unknown_attr_names  cCs]tj}y|jdtWn)tk rK}|jt|dnX|jddS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R R;RDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_unknown_name s  cCsEtj}y|jdtWntk r3nX|jddS(NRsFailed to raise AttributeError(R R R;RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_empty_name"s   cCsUtj}y|jdtWn!tk r3ntk rCnX|jddS(Ns abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R R R;R<RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromName__relative_malformed_name5s   cs|dtjfdYdtffdY}tj}|jd|}dg}|jt||dS(NR"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#Ms(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"LsR,cseZZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,PsRR#(R R R-R R;R R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_not_a_moduleKs  cCs`tjd}t|_tj}y|jd|Wntk rNnX|jddS(NR!R&sShould have raised TypeError( R$R%R-R&R R R;RR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_bad_object`s   cCstjd}dtjfdY}||_tj}|jd|}|j||j|j t ||dgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#qs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"psR&R#( R$R%R R R&R R;RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt2test_loadTestsFromName__relative_TestCase_subclassns  cCstjd}dtjfdY}tj|dg|_tj}|jd|}|j||j |j t ||dgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR#t testsuite( R$R%R R R RLR R;RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromName__relative_TestSuite~s cCstjd}dtjfdY}||_tj}|jd|}|j||j|j t ||dgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#( R$R%R R R&R R;RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_testmethods  cCstjd}dtjfdY}||_tj}y|jd|Wn)tk r|}|jt |dnX|j ddS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError( R$R%R R R&R R;RDR R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__relative_invalid_testmethods  cstjd}tjdtjdfd}||_tj}|jd|}|j||j|j t |gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pytRcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRcstjgS(N(R R ((R&t testcase_2(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestSuitesRR( R$R%R tFunctionTestCaseRRR R;RRR R(RR!RRRR((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__callable__TestSuites  cstjd}tjdfd}||_tj}|jd|}|j||j|j t |gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRcsS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestCasesRU( R$R%R RSRUR R;RRR R(RR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__callable__TestCase_instances  csdtjfdY}tjd}tjdfd}||_tj}||_|jd|}|j ||j|j t |gdS(Nt SubTestSuitecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWsR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRcsS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRUsRU( R R R$R%RSRUR RR;RR R(RRWR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pytDtest_loadTestsFromName__callable__TestCase_instance_ProperSuiteClasss   cCsdtjfdY}tjd}dtjfdY}||_tj}||_|jd|}|j ||j|j t ||dgdS(NRWcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWsR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#( R R R$R%R R&R RR;RR R(RRWR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<test_loadTestsFromName__relative_testmethod_ProperSuiteClasss   cCsftjd}d}||_tj}y|jd|Wntk rTnX|jddS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt return_wrongsRZs6TestLoader.loadTestsFromName failed to raise TypeError(R$R%RZR R R;RR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromName__callable__wrong_types    cCsd}tjj|dtj}zO|j|}|j||j|j t |g|j |tjWd|tjkrtj|=nXdS(Nsunittest.test.dummy( tsystmodulestpopR5R R R;RRR RtassertIn(Rt module_nameRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__module_not_loaded s cCsHtj}|jg}|j||j|jt|gdS(N(R R tloadTestsFromNamesRRR R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_loadTestsFromNames__empty_name_list)s cCsKtj}|jgt}|j||j|jt|gdS(N(R R RbRRR R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt1test_loadTestsFromNames__relative_empty_name_list8s cCs]tj}y|jdgWn)tk rK}|jt|dnX|jddS(NRsEmpty module names8TestLoader.loadTestsFromNames failed to raise ValueError(R R RbR<R R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_loadTestsFromNames__empty_nameEs  cCsUtj}y|jdgWn!tk r3ntk rCnX|jddS(Ns abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R R RbR<R@R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt'test_loadTestsFromNames__malformed_nameUs   cCs]tj}y|jdgWn)tk rK}|jt|dnX|jddS(NRBsNo module named sdasfasfasdfs9TestLoader.loadTestsFromNames failed to raise ImportError(R R RbR@R R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__unknown_module_namehs  cCs`tj}y|jddgWn)tk rN}|jt|dnX|jddS(Nsunittest.sdasfasfasdfR s/'module' object has no attribute 'sdasfasfasdf's<TestLoader.loadTestsFromNames failed to raise AttributeError(R R RbRDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__unknown_attr_namexs  cCs`tj}y|jdgtWn)tk rN}|jt|dnX|jddS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R RbRDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_1s  cCsctj}y|jddgtWn)tk rQ}|jt|dnX|jddS(NR RBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R RbRDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_2s  cCsHtj}y|jdgtWntk r6nX|jddS(NRsFailed to raise ValueError(R R RbRDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_empty_names   cCsXtj}y|jdgtWn!tk r6ntk rFnX|jddS(Ns abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R R RbRDR<R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__relative_malformed_names   csdtjfdYdtffdY}tj}|jdg|}tjdgg}|jt||dS(NR"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR,cseZZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,sRR#(R R R-R RbR R R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromNames__relative_not_a_modules  cCsctjd}t|_tj}y|jdg|Wntk rQnX|jddS(NR!R&sShould have raised TypeError( R$R%R-R&R R RbRR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_bad_objects   cCstjd}dtjfdY}||_tj}|jdg|}|j||j|j|dg}|j t ||gdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR&R#( R$R%R R R&R RbRRR R(RR!R"RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromNames__relative_TestCase_subclasss  cCstjd}dtjfdY}tj|dg|_tj}|jdg|}|j||j |j t ||jgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR#RL( R$R%R R R RLR RbRRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromNames__relative_TestSuite s cCstjd}dtjfdY}||_tj}|jdg|}|j||jtj |dg}|j t ||gdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#( R$R%R R R&R RbRRR R R(RR!R"RRt ref_suite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_testmethods  cCstjd}dtjfdY}||_tj}y|jdg|Wn)tk r}|jt |dnX|j ddS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#1s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"0sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError( R$R%R R R&R RbRDR R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__relative_invalid_testmethod.s  cstjd}tjdtjdfd}||_tj}|jdg|}|j||jtj g}|j t ||gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPARcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPBRcstjgS(N(R R ((R&RQ(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRCsRR( R$R%R RSRRR RbRRR R R(RR!RRRRR(((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__callable__TestSuite?s  cstjd}tjdfd}||_tj}|jdg|}|j||jtj g}|j t ||gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRRcsS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRUSsRU( R$R%R RSRUR RbRRR R R(RR!RURRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__TestCase_instancePs  cstjd}dtjfdY}|ddtjffdY}||_tj}|jdg|}|j||jtj g}|j t ||gdS(NR!tTest1cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#es(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRvdsR#RcseZefdZRS(csS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoojs(RRt staticmethodRw((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRissFoo.foo( R$R%R R RR RbRRR R R(RR!RvRRRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__call_staticmethodbs   cCsitjd}d}||_tj}y|jdg|Wntk rWnX|jddS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRZ|sRZs7TestLoader.loadTestsFromNames failed to raise TypeError(R$R%RZR R RbRR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromNames__callable__wrong_typezs    cCsd}tjj|dtj}z[|j|g}|j||j|j t |tj g|j |tjWd|tjkrtj|=nXdS(Nsunittest.test.dummy( R\R]R^R5R R RbRRR RR R_(RR`RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__module_not_loadeds cCsHdtjfdY}tj}|j|j|ddgdS(NtTestcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoobarR(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|s  RR(R R R R tgetTestCaseNames(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNamess cCsBdtjfdY}tj}|j|j|gdS(NR|cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}R(RRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|s(R R R R R~(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNames__no_testss cCsHdtfdY}tj}|j|}|j|dgdS(NtBadCasecBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_foos(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRsR(tintR R R~R (RRRtnames((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt%test_getTestCaseNames__not_a_TestCases cCsgdtjfdY}d|fdY}tj}dddg}|j|j||dS(NtTestPcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}R(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  tTestCcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_3R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RRR(R R R R R~(RRRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_getTestCaseNames__inheritances  cCsdtjfdY}tj|dg}tj|d|dg}tj}d|_|j|j||d|_|j|j||dS(NRcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RRRRwR#(R R R R RR R(RRttests_1ttests_2R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_testMethodPrefix__loadTestsFromTestCases!   cCstjd}dtjfdY}||_tj|dgg}tj|d|dgg}tj}d|_|jt |j ||d|_|jt |j ||dS( NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RRRRwR#( R$R%R R RR R RR RR'(RR!RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_testMethodPrefix__loadTestsFromModules $   cCstjd}dtjfdY}||_tj|dg}tj|d|dg}tj}d|_|j|j d||d|_|j|j d||dS( NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RRRRwR#( R$R%R R RR R RR R;(RR!RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_testMethodPrefix__loadTestsFromNames !   cCstjd}dtjfdY}||_tjtj|dgg}tj|d|dg}tj|g}tj}d|_|j|j dg||d|_|j|j dg||dS( NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR5RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR6RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR7R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR4s  RRRRwR#( R$R%R R RR R RR Rb(RR!RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_testMethodPrefix__loadTestsFromNames2s $!   cCs&tj}|j|jdkdS(NR#(R R t assertTrueR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_testMethodPrefix__default_valueFs cCsud}dtjfdY}tj}||_|j|d|dg}|j|j||dS(NcSst|| S(N(tcmp(txty((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt reversed_cmpSsRcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRXR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRVs RR(R R R tsortTestMethodsUsingRR R(RRRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_sortTestMethodsUsing__loadTestsFromTestCaseRs    !cCsd}tjd}dtjfdY}||_tj}||_|j|d|dgg}|jt |j ||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRcsR!RcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRhRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRiR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRgs RR( R$R%R R RR RRR RR'(RRR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_sortTestMethodsUsing__loadTestsFromModulebs    $cCsd}tjd}dtjfdY}||_tj}||_|j|d|dg}|j|j d||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRusR!RcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRzRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR{R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRys RR( R$R%R R RR RRR R;(RRR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_sortTestMethodsUsing__loadTestsFromNamets    !cCsd}tjd}dtjfdY}||_tj}||_|j|d|dgg}|jt |j dg||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRsR!RcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RR( R$R%R R RR RRR RRb(RRR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_sortTestMethodsUsing__loadTestsFromNamess    $cCs`d}dtjfdY}tj}||_ddg}|j|j||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRsRcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RR(R R R RR R~(RRRRt test_names((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_sortTestMethodsUsing__getTestCaseNamess     cCs&tj}|j|jtkdS(N(R R RRR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_sortTestMethodsUsing__default_values cCscdtjfdY}tj}d|_ddg}|jt|j|t|dS(NRcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RR(R R R R5RR tsetR~(RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_sortTestMethodsUsing__Nones    cCscdtjfdY}|d|dg}tj}t|_|j|j||dS(NRcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR(R R R RRR R(RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_suiteClass__loadTestsFromTestCases   cCs~tjd}dtjfdY}||_|d|dgg}tj}t|_|j|j ||dS(NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR( R$R%R R RR RRR R'(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_suiteClass__loadTestsFromModules   cCs~tjd}dtjfdY}||_|d|dg}tj}t|_|j|j d||dS(NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR( R$R%R R RR RRR R;(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_suiteClass__loadTestsFromNames   cCstjd}dtjfdY}||_|d|dgg}tj}t|_|j|j dg||dS(NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR( R$R%R R RR RRR Rb(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_suiteClass__loadTestsFromNamess   cCs&tj}|j|jtjdS(N(R R tassertIsRR (RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_suiteClass__default_values cCstjd}dtjfdY}||_tj}|jdg|}|j||jtj |dg}|j t ||gdS(NR!R"cBseZdZRS(cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP R(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR" sstestcase_1.testR#( R$R%R R R&R RbRRR R R(RR!R"RRRq((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt@test_loadTestsFromName__function_with_different_name_than_methods  (JRRRRRR R)R*R+R/R7R:R?RARCRERFRGRHRIRJRKRMRNRORTRVRXRYR[RaRcRdReRfRgRhRiRjRkRlRmRnRoRpRrRsRtRuRyRzR{RRRRRRRRRRRRRRRRRRRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs                                                                   t__main__(R\R$R R RRtmain(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyts    PK]x'Әtest_program.pynu[from cStringIO import StringIO import os import sys import unittest import unittest.test class Test_TestProgram(unittest.TestCase): def test_discovery_from_dotted_path(self): loader = unittest.TestLoader() tests = [self] expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__)) self.wasRun = False def _find_tests(start_dir, pattern): self.wasRun = True self.assertEqual(start_dir, expectedPath) return tests loader._find_tests = _find_tests suite = loader.discover('unittest.test') self.assertTrue(self.wasRun) self.assertEqual(suite._tests, tests) # Horrible white box test def testNoExit(self): result = object() test = object() class FakeRunner(object): def run(self, test): self.test = test return result runner = FakeRunner() oldParseArgs = unittest.TestProgram.parseArgs def restoreParseArgs(): unittest.TestProgram.parseArgs = oldParseArgs unittest.TestProgram.parseArgs = lambda *args: None self.addCleanup(restoreParseArgs) def removeTest(): del unittest.TestProgram.test unittest.TestProgram.test = test self.addCleanup(removeTest) program = unittest.TestProgram(testRunner=runner, exit=False, verbosity=2) self.assertEqual(program.result, result) self.assertEqual(runner.test, test) self.assertEqual(program.verbosity, 2) class FooBar(unittest.TestCase): def testPass(self): assert True def testFail(self): assert False class FooBarLoader(unittest.TestLoader): """Test loader that returns a suite containing FooBar.""" def loadTestsFromModule(self, module): return self.suiteClass( [self.loadTestsFromTestCase(Test_TestProgram.FooBar)]) def test_NonExit(self): program = unittest.main(exit=False, argv=["foobar"], testRunner=unittest.TextTestRunner(stream=StringIO()), testLoader=self.FooBarLoader()) self.assertTrue(hasattr(program, 'result')) def test_Exit(self): self.assertRaises( SystemExit, unittest.main, argv=["foobar"], testRunner=unittest.TextTestRunner(stream=StringIO()), exit=True, testLoader=self.FooBarLoader()) def test_ExitAsDefault(self): self.assertRaises( SystemExit, unittest.main, argv=["foobar"], testRunner=unittest.TextTestRunner(stream=StringIO()), testLoader=self.FooBarLoader()) class InitialisableProgram(unittest.TestProgram): exit = False result = None verbosity = 1 defaultTest = None testRunner = None testLoader = unittest.defaultTestLoader progName = 'test' test = 'test' def __init__(self, *args): pass RESULT = object() class FakeRunner(object): initArgs = None test = None raiseError = False def __init__(self, **kwargs): FakeRunner.initArgs = kwargs if FakeRunner.raiseError: FakeRunner.raiseError = False raise TypeError def run(self, test): FakeRunner.test = test return RESULT class TestCommandLineArgs(unittest.TestCase): def setUp(self): self.program = InitialisableProgram() self.program.createTests = lambda: None FakeRunner.initArgs = None FakeRunner.test = None FakeRunner.raiseError = False def testHelpAndUnknown(self): program = self.program def usageExit(msg=None): program.msg = msg program.exit = True program.usageExit = usageExit for opt in '-h', '-H', '--help': program.exit = False program.parseArgs([None, opt]) self.assertTrue(program.exit) self.assertIsNone(program.msg) program.parseArgs([None, '-$']) self.assertTrue(program.exit) self.assertIsNotNone(program.msg) def testVerbosity(self): program = self.program for opt in '-q', '--quiet': program.verbosity = 1 program.parseArgs([None, opt]) self.assertEqual(program.verbosity, 0) for opt in '-v', '--verbose': program.verbosity = 1 program.parseArgs([None, opt]) self.assertEqual(program.verbosity, 2) def testBufferCatchFailfast(self): program = self.program for arg, attr in (('buffer', 'buffer'), ('failfast', 'failfast'), ('catch', 'catchbreak')): if attr == 'catch' and not hasInstallHandler: continue short_opt = '-%s' % arg[0] long_opt = '--%s' % arg for opt in short_opt, long_opt: setattr(program, attr, None) program.parseArgs([None, opt]) self.assertTrue(getattr(program, attr)) for opt in short_opt, long_opt: not_none = object() setattr(program, attr, not_none) program.parseArgs([None, opt]) self.assertEqual(getattr(program, attr), not_none) def testRunTestsRunnerClass(self): program = self.program program.testRunner = FakeRunner program.verbosity = 'verbosity' program.failfast = 'failfast' program.buffer = 'buffer' program.runTests() self.assertEqual(FakeRunner.initArgs, {'verbosity': 'verbosity', 'failfast': 'failfast', 'buffer': 'buffer'}) self.assertEqual(FakeRunner.test, 'test') self.assertIs(program.result, RESULT) def testRunTestsRunnerInstance(self): program = self.program program.testRunner = FakeRunner() FakeRunner.initArgs = None program.runTests() # A new FakeRunner should not have been instantiated self.assertIsNone(FakeRunner.initArgs) self.assertEqual(FakeRunner.test, 'test') self.assertIs(program.result, RESULT) def testRunTestsOldRunnerClass(self): program = self.program FakeRunner.raiseError = True program.testRunner = FakeRunner program.verbosity = 'verbosity' program.failfast = 'failfast' program.buffer = 'buffer' program.test = 'test' program.runTests() # If initializing raises a type error it should be retried # without the new keyword arguments self.assertEqual(FakeRunner.initArgs, {}) self.assertEqual(FakeRunner.test, 'test') self.assertIs(program.result, RESULT) def testCatchBreakInstallsHandler(self): module = sys.modules['unittest.main'] original = module.installHandler def restore(): module.installHandler = original self.addCleanup(restore) self.installed = False def fakeInstallHandler(): self.installed = True module.installHandler = fakeInstallHandler program = self.program program.catchbreak = True program.testRunner = FakeRunner program.runTests() self.assertTrue(self.installed) if __name__ == '__main__': unittest.main() PK]\pqqtest_setups.pycnu[ |fc@sgddlZddlmZddlZdZdejfdYZedkrcejndS(iN(tStringIOcGs tjS(N(tunittestt TestResult(t_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt resultFactoryst TestSetupscBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZRS(cCstjdtdtS(Nt resultclasststream(RtTextTestRunnerRR(tself((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt getRunnerscGstj}x-|D]%}tjj|}|j|qW|j}tj}|j||jtj|jtj|j|S(N(Rt TestSuitetdefaultTestLoadertloadTestsFromTestCasetaddTestsR taddTesttrun(R tcasestsuitetcasetteststrunnert realSuite((s1/usr/lib64/python2.7/unittest/test/test_setups.pytrunTestss     csqdtjffdY|j}|jjd|j|jd|jt|jddS(NtTestcs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(t setUpCalledRtTestCaset setUpClass(tcls(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR$scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_one(scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_two*s(t__name__t __module__Rt classmethodRRR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR"s iii(RRRt assertEqualRttestsRuntlenterrors(R tresult((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_class!s  csqdtjffdY|j}|jjd|j|jd|jt|jddS(NRcs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(ttearDownCalledRRt tearDownClass(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)6scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR:scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR<s(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR4s iii(RRRR"R(R#R$R%(R R&((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class3s  csdtjffdYdtjffdY|j}|jjd|jjd|j|jd|jt|jddS(NRcs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(R(RRR)(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)HscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRNs(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs tTest2cs5eZdZefdZdZdZRS(ics jd7_tjjdS(Ni(R(RRR)(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)SscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRWscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRYs(RR R(R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+Qs iii(RRRR"R(R#R$R%(R R&((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class_two_classesEs  cCsdtjfdY}|j|}|j|jd|jt|jd|jd\}}|jt|dtdS(Nt BrokenTestcBs)eZedZdZdZRS(cSstddS(Ntfoo(t TypeError(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRescSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRhscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRjs(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-ds iissetUpClass (%s.BrokenTest)( RRRR"R#R$R%tstrR(R R-R&terrorR((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setupclasscs csdtjffdYdtjffdY|j}|j|jd|jt|jd|jjd|jjd|jd\}}|jt|d t dS( NRcs5eZdZefdZdZdZRS(icsjd7_tddS(NiR.(ttornDownR/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)xscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s(RR R3R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvs R+cs5eZdZefdZdZdZRS(icsjd7_tddS(NiR.(R3R/(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR R3R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+s iiiistearDownClass (%s.Test)( RRRR"R#R$R%R3R0R(R R&R1R((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_classus  cs@dtjffdY|j|jjdS(NRcs;eZeZedZefdZdZRS(cSs tdS(N(R/(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscst_tddS(NR.(tTrueR3R/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)s cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR tFalseR3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RRRt assertFalseR3(R ((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt(test_class_not_torndown_when_setup_failss csedtjffdYtjd|j|jj|jjdS(NRcsGeZeZeZefdZefdZdZRS(cs t_dS(N(R5t classSetUp(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscs t_dS(N(R5R3(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs( RR R6R9R3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs thop(RRtskipRR7R9R3(R ((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt-test_class_not_setup_or_torndown_when_skippeds   cs gdtffdY}dtffdY}dtjffdY}dtjffdY}d tjffd Y}d |_|_d|_|tjd <|tjd((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttearDownModules(RR t staticmethodR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR=stModule2cs2eZefdZefdZRS(csjddS(NsModule2.setUpModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@scsjddS(NsModule2.tearDownModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAs(RR RBR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRCstTest1csPeZefdZefdZfdZfdZRS(csjddS(Nssetup 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(Ns teardown 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Ns Test1.testOne(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestOnescsjddS(Ns Test1.testTwo(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestTwos(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRDsR+csPeZefdZefdZfdZfdZRS(csjddS(Nssetup 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(Ns teardown 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Ns Test2.testOne(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyREscsjddS(Ns Test2.testTwo(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+stTest3csPeZefdZefdZfdZfdZRS(csjddS(Nssetup 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(Ns teardown 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Ns Test3.testOne(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyREscsjddS(Ns Test3.testTwo(R>(R (R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRGstModuleRERFiisModule1.setUpModulessetup 1s Test1.testOnes Test1.testTwos teardown 1ssetup 2s Test2.testOnes Test2.testTwos teardown 2sModule1.tearDownModulesModule2.setUpModulessetup 3s Test3.testOnes Test3.testTwos teardown 3sModule2.tearDownModule( tobjectRRR tsystmodulesR R RR"R#R$R%(R R=RCRDR+RGtfirsttsecondtthirdtfourthtfifthtsixthRRR&((R?s1/usr/lib64/python2.7/unittest/test/test_setups.pyt1test_setup_teardown_order_with_pathological_suites:      !    csdtffdYdtjfdY}d|_tjd<|j|}|jjd|j|j d|jt |j ddS(NRHcs#eZdZefdZRS(icsjd7_dS(Ni(t moduleSetup((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@ s(RR RSRBR@((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH sRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs iii( RIRRR RJRKRR"RSR#R$R%(R RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_module s  cs$dtffdYdtjffdYdtjfdY}d_d|_tjd<|j|}|jjd|jj d|j|j d|j j |j j |jt|jd|jd\}}|jt|d dS( NRHcs>eZdZdZefdZefdZRS(icsjd7_tddS(NiR.(RSR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@"scsjd7_dS(Ni(tmoduleTornDown((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA&s(RR RSRURBR@RA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcsPeZeZeZefdZefdZdZdZ RS(cs t_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-scs t_dS(N(R5t classTornDown(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)0scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR3scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR5s( RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR*s  R+cBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR9scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR;s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+8s iissetUpModule (Module)(RIRRR RJRKRR"RSRUR#R7R9RVR$R%R0(R R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setup_modules    cCs[dtjfdY}d|_tjjdd|j|}|j|j ddS(NRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRMscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyROs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLs RHi( RRR RJRKtpoptNoneRR"R#(R RR&((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt!test_testcase_with_missing_moduleKs  csdtffdYdtjfdY}d|_tjd<|j|}|jjd|j|j d|jt |j ddS(NRHcs#eZdZefdZRS(icsjd7_dS(Ni(RU((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAZs(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHXsRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR_scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRas(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR^s iii( RIRRR RJRKRR"RUR#R$R%(R RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_moduleWs  csdtffdYdtjffdYdtjfdY}d_d|_tjd<|j|}|jjd|j|j d|j j |j j |jt |jd|jd \}}|jt|d dS( NRHcs#eZdZefdZRS(icsjd7_tddS(NiR.(RUR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAns(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHlsRcsPeZeZeZefdZefdZdZdZ RS(cs t_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvscs t_dS(N(R5RV(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)yscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s( RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRss  R+cBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+s iiistearDownModule (Module)(RIRRR RJRKRR"RUR#t assertTrueR9RVR$R%R0(R R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_moduleks   cCsdtjfdY}|j|}|j|jd|jt|jd|jt|jd|jdd}|jt|dt dS(NRcBs)eZedZdZdZRS(cSstjddS(NR.(RtSkipTest(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs iissetUpClass (%s.Test)( RRRR"R#R$R%tskippedR0R(R RR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupclasss cCsdtjfdY}dtfdY}d|_|tjd<|j|}|j|jd|jt |j d|jt |j d|j dd}|jt |ddS(NRcBseZdZdZRS(cSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R ((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs RHcBseZedZRS(cSstjddS(NR.(RR^(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@s(RR RBR@(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsiissetUpModule (Module)( RRRIR RJRKRR"R#R$R%R_R0(R RRHR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupmodules  csgdtffdY}dtjffdY}d|_|tjd((tordering(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@scsjddS(NRA(R>((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAs(RR RBR@RA((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcsAeZefdZefdZfdZRS(csjddS(NR(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscsjddS(NR)(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)scsjddS(Nttest_something(R>(R (Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRcs(RR R!RR)Rc((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRsR@RRcR)RA( RIRRR RJRKR R tdebugR"(R RHRRt expectedOrder((Rbs1/usr/lib64/python2.7/unittest/test/test_setups.pyt.test_suite_debug_executes_setups_and_teardownss   csdtffdY}dtjffdY}d|_|tjds    PK]M;E,2/2/ test_suite.pynu[import unittest import sys from unittest.test.support import LoggingResult, TestEquality ### Support code for Test_TestSuite ################################################################ class Test(object): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def test_3(self): pass def runTest(self): pass def _mk_TestSuite(*names): return unittest.TestSuite(Test.Foo(n) for n in names) ################################################################ class Test_TestSuite(unittest.TestCase, TestEquality): ### Set up attributes needed by inherited tests ################################################################ # Used by TestEquality.test_eq eq_pairs = [(unittest.TestSuite(), unittest.TestSuite()), (unittest.TestSuite(), unittest.TestSuite([])), (_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))] # Used by TestEquality.test_ne ne_pairs = [(unittest.TestSuite(), _mk_TestSuite('test_1')), (unittest.TestSuite([]), _mk_TestSuite('test_1')), (_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 'test_3')), (_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))] ################################################################ ### /Set up attributes needed by inherited tests ### Tests for TestSuite.__init__ ################################################################ # "class TestSuite([tests])" # # The tests iterable should be optional def test_init__tests_optional(self): suite = unittest.TestSuite() self.assertEqual(suite.countTestCases(), 0) # "class TestSuite([tests])" # ... # "If tests is given, it must be an iterable of individual test cases # or other test suites that will be used to build the suite initially" # # TestSuite should deal with empty tests iterables by allowing the # creation of an empty suite def test_init__empty_tests(self): suite = unittest.TestSuite([]) self.assertEqual(suite.countTestCases(), 0) # "class TestSuite([tests])" # ... # "If tests is given, it must be an iterable of individual test cases # or other test suites that will be used to build the suite initially" # # TestSuite should allow any iterable to provide tests def test_init__tests_from_any_iterable(self): def tests(): yield unittest.FunctionTestCase(lambda: None) yield unittest.FunctionTestCase(lambda: None) suite_1 = unittest.TestSuite(tests()) self.assertEqual(suite_1.countTestCases(), 2) suite_2 = unittest.TestSuite(suite_1) self.assertEqual(suite_2.countTestCases(), 2) suite_3 = unittest.TestSuite(set(suite_1)) self.assertEqual(suite_3.countTestCases(), 2) # "class TestSuite([tests])" # ... # "If tests is given, it must be an iterable of individual test cases # or other test suites that will be used to build the suite initially" # # Does TestSuite() also allow other TestSuite() instances to be present # in the tests iterable? def test_init__TestSuite_instances_in_tests(self): def tests(): ftc = unittest.FunctionTestCase(lambda: None) yield unittest.TestSuite([ftc]) yield unittest.FunctionTestCase(lambda: None) suite = unittest.TestSuite(tests()) self.assertEqual(suite.countTestCases(), 2) ################################################################ ### /Tests for TestSuite.__init__ # Container types should support the iter protocol def test_iter(self): test1 = unittest.FunctionTestCase(lambda: None) test2 = unittest.FunctionTestCase(lambda: None) suite = unittest.TestSuite((test1, test2)) self.assertEqual(list(suite), [test1, test2]) # "Return the number of tests represented by the this test object. # ...this method is also implemented by the TestSuite class, which can # return larger [greater than 1] values" # # Presumably an empty TestSuite returns 0? def test_countTestCases_zero_simple(self): suite = unittest.TestSuite() self.assertEqual(suite.countTestCases(), 0) # "Return the number of tests represented by the this test object. # ...this method is also implemented by the TestSuite class, which can # return larger [greater than 1] values" # # Presumably an empty TestSuite (even if it contains other empty # TestSuite instances) returns 0? def test_countTestCases_zero_nested(self): class Test1(unittest.TestCase): def test(self): pass suite = unittest.TestSuite([unittest.TestSuite()]) self.assertEqual(suite.countTestCases(), 0) # "Return the number of tests represented by the this test object. # ...this method is also implemented by the TestSuite class, which can # return larger [greater than 1] values" def test_countTestCases_simple(self): test1 = unittest.FunctionTestCase(lambda: None) test2 = unittest.FunctionTestCase(lambda: None) suite = unittest.TestSuite((test1, test2)) self.assertEqual(suite.countTestCases(), 2) # "Return the number of tests represented by the this test object. # ...this method is also implemented by the TestSuite class, which can # return larger [greater than 1] values" # # Make sure this holds for nested TestSuite instances, too def test_countTestCases_nested(self): class Test1(unittest.TestCase): def test1(self): pass def test2(self): pass test2 = unittest.FunctionTestCase(lambda: None) test3 = unittest.FunctionTestCase(lambda: None) child = unittest.TestSuite((Test1('test2'), test2)) parent = unittest.TestSuite((test3, child, Test1('test1'))) self.assertEqual(parent.countTestCases(), 4) # "Run the tests associated with this suite, collecting the result into # the test result object passed as result." # # And if there are no tests? What then? def test_run__empty_suite(self): events = [] result = LoggingResult(events) suite = unittest.TestSuite() suite.run(result) self.assertEqual(events, []) # "Note that unlike TestCase.run(), TestSuite.run() requires the # "result object to be passed in." def test_run__requires_result(self): suite = unittest.TestSuite() try: suite.run() except TypeError: pass else: self.fail("Failed to raise TypeError") # "Run the tests associated with this suite, collecting the result into # the test result object passed as result." def test_run(self): events = [] result = LoggingResult(events) class LoggingCase(unittest.TestCase): def run(self, result): events.append('run %s' % self._testMethodName) def test1(self): pass def test2(self): pass tests = [LoggingCase('test1'), LoggingCase('test2')] unittest.TestSuite(tests).run(result) self.assertEqual(events, ['run test1', 'run test2']) # "Add a TestCase ... to the suite" def test_addTest__TestCase(self): class Foo(unittest.TestCase): def test(self): pass test = Foo('test') suite = unittest.TestSuite() suite.addTest(test) self.assertEqual(suite.countTestCases(), 1) self.assertEqual(list(suite), [test]) # "Add a ... TestSuite to the suite" def test_addTest__TestSuite(self): class Foo(unittest.TestCase): def test(self): pass suite_2 = unittest.TestSuite([Foo('test')]) suite = unittest.TestSuite() suite.addTest(suite_2) self.assertEqual(suite.countTestCases(), 1) self.assertEqual(list(suite), [suite_2]) # "Add all the tests from an iterable of TestCase and TestSuite # instances to this test suite." # # "This is equivalent to iterating over tests, calling addTest() for # each element" def test_addTests(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass test_1 = Foo('test_1') test_2 = Foo('test_2') inner_suite = unittest.TestSuite([test_2]) def gen(): yield test_1 yield test_2 yield inner_suite suite_1 = unittest.TestSuite() suite_1.addTests(gen()) self.assertEqual(list(suite_1), list(gen())) # "This is equivalent to iterating over tests, calling addTest() for # each element" suite_2 = unittest.TestSuite() for t in gen(): suite_2.addTest(t) self.assertEqual(suite_1, suite_2) # "Add all the tests from an iterable of TestCase and TestSuite # instances to this test suite." # # What happens if it doesn't get an iterable? def test_addTest__noniterable(self): suite = unittest.TestSuite() try: suite.addTests(5) except TypeError: pass else: self.fail("Failed to raise TypeError") def test_addTest__noncallable(self): suite = unittest.TestSuite() self.assertRaises(TypeError, suite.addTest, 5) def test_addTest__casesuiteclass(self): suite = unittest.TestSuite() self.assertRaises(TypeError, suite.addTest, Test_TestSuite) self.assertRaises(TypeError, suite.addTest, unittest.TestSuite) def test_addTests__string(self): suite = unittest.TestSuite() self.assertRaises(TypeError, suite.addTests, "foo") def test_function_in_suite(self): def f(_): pass suite = unittest.TestSuite() suite.addTest(f) # when the bug is fixed this line will not crash suite.run(unittest.TestResult()) def test_basetestsuite(self): class Test(unittest.TestCase): wasSetUp = False wasTornDown = False @classmethod def setUpClass(cls): cls.wasSetUp = True @classmethod def tearDownClass(cls): cls.wasTornDown = True def testPass(self): pass def testFail(self): fail class Module(object): wasSetUp = False wasTornDown = False @staticmethod def setUpModule(): Module.wasSetUp = True @staticmethod def tearDownModule(): Module.wasTornDown = True Test.__module__ = 'Module' sys.modules['Module'] = Module self.addCleanup(sys.modules.pop, 'Module') suite = unittest.BaseTestSuite() suite.addTests([Test('testPass'), Test('testFail')]) self.assertEqual(suite.countTestCases(), 2) result = unittest.TestResult() suite.run(result) self.assertFalse(Module.wasSetUp) self.assertFalse(Module.wasTornDown) self.assertFalse(Test.wasSetUp) self.assertFalse(Test.wasTornDown) self.assertEqual(len(result.errors), 1) self.assertEqual(len(result.failures), 0) self.assertEqual(result.testsRun, 2) def test_overriding_call(self): class MySuite(unittest.TestSuite): called = False def __call__(self, *args, **kw): self.called = True unittest.TestSuite.__call__(self, *args, **kw) suite = MySuite() result = unittest.TestResult() wrapper = unittest.TestSuite() wrapper.addTest(suite) wrapper(result) self.assertTrue(suite.called) # reusing results should be permitted even if abominable self.assertFalse(result._testRunEntered) if __name__ == '__main__': unittest.main() PK]pJpJtest_result.pynu[import sys import textwrap from StringIO import StringIO from test import test_support import traceback import unittest class Test_TestResult(unittest.TestCase): # Note: there are not separate tests for TestResult.wasSuccessful(), # TestResult.errors, TestResult.failures, TestResult.testsRun or # TestResult.shouldStop because these only have meaning in terms of # other TestResult methods. # # Accordingly, tests for the aforenamed attributes are incorporated # in with the tests for the defining methods. ################################################################ def test_init(self): result = unittest.TestResult() self.assertTrue(result.wasSuccessful()) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.failures), 0) self.assertEqual(result.testsRun, 0) self.assertEqual(result.shouldStop, False) self.assertIsNone(result._stdout_buffer) self.assertIsNone(result._stderr_buffer) # "This method can be called to signal that the set of tests being # run should be aborted by setting the TestResult's shouldStop # attribute to True." def test_stop(self): result = unittest.TestResult() result.stop() self.assertEqual(result.shouldStop, True) # "Called when the test case test is about to be run. The default # implementation simply increments the instance's testsRun counter." def test_startTest(self): class Foo(unittest.TestCase): def test_1(self): pass test = Foo('test_1') result = unittest.TestResult() result.startTest(test) self.assertTrue(result.wasSuccessful()) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.failures), 0) self.assertEqual(result.testsRun, 1) self.assertEqual(result.shouldStop, False) result.stopTest(test) # "Called after the test case test has been executed, regardless of # the outcome. The default implementation does nothing." def test_stopTest(self): class Foo(unittest.TestCase): def test_1(self): pass test = Foo('test_1') result = unittest.TestResult() result.startTest(test) self.assertTrue(result.wasSuccessful()) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.failures), 0) self.assertEqual(result.testsRun, 1) self.assertEqual(result.shouldStop, False) result.stopTest(test) # Same tests as above; make sure nothing has changed self.assertTrue(result.wasSuccessful()) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.failures), 0) self.assertEqual(result.testsRun, 1) self.assertEqual(result.shouldStop, False) # "Called before and after tests are run. The default implementation does nothing." def test_startTestRun_stopTestRun(self): result = unittest.TestResult() result.startTestRun() result.stopTestRun() # "addSuccess(test)" # ... # "Called when the test case test succeeds" # ... # "wasSuccessful() - Returns True if all tests run so far have passed, # otherwise returns False" # ... # "testsRun - The total number of tests run so far." # ... # "errors - A list containing 2-tuples of TestCase instances and # formatted tracebacks. Each tuple represents a test which raised an # unexpected exception. Contains formatted # tracebacks instead of sys.exc_info() results." # ... # "failures - A list containing 2-tuples of TestCase instances and # formatted tracebacks. Each tuple represents a test where a failure was # explicitly signalled using the TestCase.fail*() or TestCase.assert*() # methods. Contains formatted tracebacks instead # of sys.exc_info() results." def test_addSuccess(self): class Foo(unittest.TestCase): def test_1(self): pass test = Foo('test_1') result = unittest.TestResult() result.startTest(test) result.addSuccess(test) result.stopTest(test) self.assertTrue(result.wasSuccessful()) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.failures), 0) self.assertEqual(result.testsRun, 1) self.assertEqual(result.shouldStop, False) # "addFailure(test, err)" # ... # "Called when the test case test signals a failure. err is a tuple of # the form returned by sys.exc_info(): (type, value, traceback)" # ... # "wasSuccessful() - Returns True if all tests run so far have passed, # otherwise returns False" # ... # "testsRun - The total number of tests run so far." # ... # "errors - A list containing 2-tuples of TestCase instances and # formatted tracebacks. Each tuple represents a test which raised an # unexpected exception. Contains formatted # tracebacks instead of sys.exc_info() results." # ... # "failures - A list containing 2-tuples of TestCase instances and # formatted tracebacks. Each tuple represents a test where a failure was # explicitly signalled using the TestCase.fail*() or TestCase.assert*() # methods. Contains formatted tracebacks instead # of sys.exc_info() results." def test_addFailure(self): class Foo(unittest.TestCase): def test_1(self): pass test = Foo('test_1') try: test.fail("foo") except: exc_info_tuple = sys.exc_info() result = unittest.TestResult() result.startTest(test) result.addFailure(test, exc_info_tuple) result.stopTest(test) self.assertFalse(result.wasSuccessful()) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.failures), 1) self.assertEqual(result.testsRun, 1) self.assertEqual(result.shouldStop, False) test_case, formatted_exc = result.failures[0] self.assertIs(test_case, test) self.assertIsInstance(formatted_exc, str) # "addError(test, err)" # ... # "Called when the test case test raises an unexpected exception err # is a tuple of the form returned by sys.exc_info(): # (type, value, traceback)" # ... # "wasSuccessful() - Returns True if all tests run so far have passed, # otherwise returns False" # ... # "testsRun - The total number of tests run so far." # ... # "errors - A list containing 2-tuples of TestCase instances and # formatted tracebacks. Each tuple represents a test which raised an # unexpected exception. Contains formatted # tracebacks instead of sys.exc_info() results." # ... # "failures - A list containing 2-tuples of TestCase instances and # formatted tracebacks. Each tuple represents a test where a failure was # explicitly signalled using the TestCase.fail*() or TestCase.assert*() # methods. Contains formatted tracebacks instead # of sys.exc_info() results." def test_addError(self): class Foo(unittest.TestCase): def test_1(self): pass test = Foo('test_1') try: raise TypeError() except: exc_info_tuple = sys.exc_info() result = unittest.TestResult() result.startTest(test) result.addError(test, exc_info_tuple) result.stopTest(test) self.assertFalse(result.wasSuccessful()) self.assertEqual(len(result.errors), 1) self.assertEqual(len(result.failures), 0) self.assertEqual(result.testsRun, 1) self.assertEqual(result.shouldStop, False) test_case, formatted_exc = result.errors[0] self.assertIs(test_case, test) self.assertIsInstance(formatted_exc, str) def testGetDescriptionWithoutDocstring(self): result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), 'testGetDescriptionWithoutDocstring (' + __name__ + '.Test_TestResult)') @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def testGetDescriptionWithOneLineDocstring(self): """Tests getDescription() for a method with a docstring.""" result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), ('testGetDescriptionWithOneLineDocstring ' '(' + __name__ + '.Test_TestResult)\n' 'Tests getDescription() for a method with a docstring.')) @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def testGetDescriptionWithMultiLineDocstring(self): """Tests getDescription() for a method with a longer docstring. The second line of the docstring. """ result = unittest.TextTestResult(None, True, 1) self.assertEqual( result.getDescription(self), ('testGetDescriptionWithMultiLineDocstring ' '(' + __name__ + '.Test_TestResult)\n' 'Tests getDescription() for a method with a longer ' 'docstring.')) def testStackFrameTrimming(self): class Frame(object): class tb_frame(object): f_globals = {} result = unittest.TestResult() self.assertFalse(result._is_relevant_tb_level(Frame)) Frame.tb_frame.f_globals['__unittest'] = True self.assertTrue(result._is_relevant_tb_level(Frame)) def testFailFast(self): result = unittest.TestResult() result._exc_info_to_string = lambda *_: '' result.failfast = True result.addError(None, None) self.assertTrue(result.shouldStop) result = unittest.TestResult() result._exc_info_to_string = lambda *_: '' result.failfast = True result.addFailure(None, None) self.assertTrue(result.shouldStop) result = unittest.TestResult() result._exc_info_to_string = lambda *_: '' result.failfast = True result.addUnexpectedSuccess(None) self.assertTrue(result.shouldStop) def testFailFastSetByRunner(self): runner = unittest.TextTestRunner(stream=StringIO(), failfast=True) def test(result): self.assertTrue(result.failfast) runner.run(test) classDict = dict(unittest.TestResult.__dict__) for m in ('addSkip', 'addExpectedFailure', 'addUnexpectedSuccess', '__init__'): del classDict[m] def __init__(self, stream=None, descriptions=None, verbosity=None): self.failures = [] self.errors = [] self.testsRun = 0 self.shouldStop = False self.buffer = False classDict['__init__'] = __init__ OldResult = type('OldResult', (object,), classDict) class Test_OldTestResult(unittest.TestCase): def assertOldResultWarning(self, test, failures): with test_support.check_warnings(("TestResult has no add.+ method,", RuntimeWarning)): result = OldResult() test.run(result) self.assertEqual(len(result.failures), failures) def testOldTestResult(self): class Test(unittest.TestCase): def testSkip(self): self.skipTest('foobar') @unittest.expectedFailure def testExpectedFail(self): raise TypeError @unittest.expectedFailure def testUnexpectedSuccess(self): pass for test_name, should_pass in (('testSkip', True), ('testExpectedFail', True), ('testUnexpectedSuccess', False)): test = Test(test_name) self.assertOldResultWarning(test, int(not should_pass)) def testOldTestTesultSetup(self): class Test(unittest.TestCase): def setUp(self): self.skipTest('no reason') def testFoo(self): pass self.assertOldResultWarning(Test('testFoo'), 0) def testOldTestResultClass(self): @unittest.skip('no reason') class Test(unittest.TestCase): def testFoo(self): pass self.assertOldResultWarning(Test('testFoo'), 0) def testOldResultWithRunner(self): class Test(unittest.TestCase): def testFoo(self): pass runner = unittest.TextTestRunner(resultclass=OldResult, stream=StringIO()) # This will raise an exception if TextTestRunner can't handle old # test result objects runner.run(Test('testFoo')) class MockTraceback(object): @staticmethod def format_exception(*_): return ['A traceback'] def restore_traceback(): unittest.result.traceback = traceback class TestOutputBuffering(unittest.TestCase): def setUp(self): self._real_out = sys.stdout self._real_err = sys.stderr def tearDown(self): sys.stdout = self._real_out sys.stderr = self._real_err def testBufferOutputOff(self): real_out = self._real_out real_err = self._real_err result = unittest.TestResult() self.assertFalse(result.buffer) self.assertIs(real_out, sys.stdout) self.assertIs(real_err, sys.stderr) result.startTest(self) self.assertIs(real_out, sys.stdout) self.assertIs(real_err, sys.stderr) def testBufferOutputStartTestAddSuccess(self): real_out = self._real_out real_err = self._real_err result = unittest.TestResult() self.assertFalse(result.buffer) result.buffer = True self.assertIs(real_out, sys.stdout) self.assertIs(real_err, sys.stderr) result.startTest(self) self.assertIsNot(real_out, sys.stdout) self.assertIsNot(real_err, sys.stderr) self.assertIsInstance(sys.stdout, StringIO) self.assertIsInstance(sys.stderr, StringIO) self.assertIsNot(sys.stdout, sys.stderr) out_stream = sys.stdout err_stream = sys.stderr result._original_stdout = StringIO() result._original_stderr = StringIO() print 'foo' print >> sys.stderr, 'bar' self.assertEqual(out_stream.getvalue(), 'foo\n') self.assertEqual(err_stream.getvalue(), 'bar\n') self.assertEqual(result._original_stdout.getvalue(), '') self.assertEqual(result._original_stderr.getvalue(), '') result.addSuccess(self) result.stopTest(self) self.assertIs(sys.stdout, result._original_stdout) self.assertIs(sys.stderr, result._original_stderr) self.assertEqual(result._original_stdout.getvalue(), '') self.assertEqual(result._original_stderr.getvalue(), '') self.assertEqual(out_stream.getvalue(), '') self.assertEqual(err_stream.getvalue(), '') def getStartedResult(self): result = unittest.TestResult() result.buffer = True result.startTest(self) return result def testBufferOutputAddErrorOrFailure(self): unittest.result.traceback = MockTraceback self.addCleanup(restore_traceback) for message_attr, add_attr, include_error in [ ('errors', 'addError', True), ('failures', 'addFailure', False), ('errors', 'addError', True), ('failures', 'addFailure', False) ]: result = self.getStartedResult() buffered_out = sys.stdout buffered_err = sys.stderr result._original_stdout = StringIO() result._original_stderr = StringIO() print >> sys.stdout, 'foo' if include_error: print >> sys.stderr, 'bar' addFunction = getattr(result, add_attr) addFunction(self, (None, None, None)) result.stopTest(self) result_list = getattr(result, message_attr) self.assertEqual(len(result_list), 1) test, message = result_list[0] expectedOutMessage = textwrap.dedent(""" Stdout: foo """) expectedErrMessage = '' if include_error: expectedErrMessage = textwrap.dedent(""" Stderr: bar """) expectedFullMessage = 'A traceback%s%s' % (expectedOutMessage, expectedErrMessage) self.assertIs(test, self) self.assertEqual(result._original_stdout.getvalue(), expectedOutMessage) self.assertEqual(result._original_stderr.getvalue(), expectedErrMessage) self.assertMultiLineEqual(message, expectedFullMessage) def testBufferSetupClass(self): result = unittest.TestResult() result.buffer = True class Foo(unittest.TestCase): @classmethod def setUpClass(cls): 1//0 def test_foo(self): pass suite = unittest.TestSuite([Foo('test_foo')]) suite(result) self.assertEqual(len(result.errors), 1) def testBufferTearDownClass(self): result = unittest.TestResult() result.buffer = True class Foo(unittest.TestCase): @classmethod def tearDownClass(cls): 1//0 def test_foo(self): pass suite = unittest.TestSuite([Foo('test_foo')]) suite(result) self.assertEqual(len(result.errors), 1) def testBufferSetUpModule(self): result = unittest.TestResult() result.buffer = True class Foo(unittest.TestCase): def test_foo(self): pass class Module(object): @staticmethod def setUpModule(): 1//0 Foo.__module__ = 'Module' sys.modules['Module'] = Module self.addCleanup(sys.modules.pop, 'Module') suite = unittest.TestSuite([Foo('test_foo')]) suite(result) self.assertEqual(len(result.errors), 1) def testBufferTearDownModule(self): result = unittest.TestResult() result.buffer = True class Foo(unittest.TestCase): def test_foo(self): pass class Module(object): @staticmethod def tearDownModule(): 1//0 Foo.__module__ = 'Module' sys.modules['Module'] = Module self.addCleanup(sys.modules.pop, 'Module') suite = unittest.TestSuite([Foo('test_foo')]) suite(result) self.assertEqual(len(result.errors), 1) if __name__ == '__main__': unittest.main() PK]+%%test_skipping.pyonu[ |fc@sRddlZddlmZdejfdYZedkrNejndS(iN(t LoggingResulttTest_TestSkippingcBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCs dtjfdY}g}t|}|d}|j||j|dddg|j|j|dfgdtjfdY}g}t|}|d }|j||j|dddg|j|j|d fg|j|jd dS( NtFoocBseZdZRS(cSs|jddS(Ntskip(tskipTest(tself((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_skip_me s(t__name__t __module__R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR sRt startTesttaddSkiptstopTestRcBseZdZdZRS(cSs|jddS(Nttesting(R(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pytsetUpscSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_nothingt(RRR R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs RR i(tunittesttTestCaseRtrunt assertEqualtskippedttestsRun(RRteventstresultttest((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_skippings      c s6tjttftjttff}x |D]\dtjffdY}|d}|d}tj||g}g}t|}|j||j t |j dddddd dg}|j |||j |j d |j |j |d fg|j |jq+WdS( NRcs8eZddZddZRS(R cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt test_skip%scSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_dont_skip(s(RRRR((tdecotdo_skipt dont_skip(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR$sRRiR R R t addSuccessiR (Rt skipUnlesstFalsetTruetskipIfRt TestSuiteRRRtlenRRt assertTruet wasSuccessful( Rtop_tableRt test_do_skipRtsuiteRRtexpected((RRRs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skipping_decorators s"%     cstjddtjffdY}gtj}|d}tj|g}|j||j|j|dfg|jgdS(NR RcseZfdZRS(csjddS(Ni(tappend(R(trecord(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_1;s(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR9sR/(RRRt TestResultR$RRR(RRRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_class8s   cstjdddfdY}d|tjfdY}gtj}|d}tj|g}|j||j|j|dfg|jgdS(NR tMixincseZfdZRS(csjddS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Hs(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2FsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRJsR/((RRRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_old_styleEs(   cstjddtffdY}d|tjfdY}gtj}|d}tj|g}|j||j|j|dfg|jgdS(NR R2cseZfdZRS(csjddS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Ws(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2UsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRYsR/( RRtobjectRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_new_styleTs   cCsdtjfdY}g}t|}|d}|j||j|dddg|j|jdd||j|jdS(NRcBseZejdZRS(cSs|jddS(Nshelp me!(tfail(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_diees(RRRtexpectedFailureR7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRdsR7R taddExpectedFailureR i(RRRRRtexpectedFailuresR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_expected_failurecs    cCsdtjfdY}g}t|}|d}|j||j|dddg|j|j|j|j|g|j|j dS(NRcBseZejdZRS(cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR7ss(RRRR8R7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRrsR7R taddUnexpectedSuccessR ( RRRRRt assertFalsetfailurestunexpectedSuccessesR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_unexpected_successqs    csdtjffdYtj}d}tj|g}|j||j|j|dfg|jj|jj dS(NRcsJeZeZeZfdZfdZejddZ RS(cs t_dS(N(R"twasSetUp(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR scs t_dS(N(R"t wasTornDown(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttornDownsR cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/s( RRR!RARBR RCRRR/((R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs R/R ( RRR0R$RRRR=RARB(RRRR*((Rs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_doesnt_run_setups   csddtjffdY}tj}|d}tj|g}|j||j|j|dfgdS(Ncsfd}|S(Ncs |S(N((ta(tfunc(s3/usr/lib64/python2.7/unittest/test/test_skipping.pytinners((RFRG((RFs3/usr/lib64/python2.7/unittest/test/test_skipping.pyt decoratorsRcs&eZejddZRS(R cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/s(RRRRR/((RH(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRsR/R (RRR0R$RRR(RRRRR*((RHs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_decorated_skips    ( RRRR,R1R3R5R;R@RDRI(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs       t__main__(Rtunittest.test.supportRRRRtmain(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyts  PK]ٙ7L@L@test_setups.pynu[import sys from cStringIO import StringIO import unittest def resultFactory(*_): return unittest.TestResult() class TestSetups(unittest.TestCase): def getRunner(self): return unittest.TextTestRunner(resultclass=resultFactory, stream=StringIO()) def runTests(self, *cases): suite = unittest.TestSuite() for case in cases: tests = unittest.defaultTestLoader.loadTestsFromTestCase(case) suite.addTests(tests) runner = self.getRunner() # creating a nested suite exposes some potential bugs realSuite = unittest.TestSuite() realSuite.addTest(suite) # adding empty suites to the end exposes potential bugs suite.addTest(unittest.TestSuite()) realSuite.addTest(unittest.TestSuite()) return runner.run(realSuite) def test_setup_class(self): class Test(unittest.TestCase): setUpCalled = 0 @classmethod def setUpClass(cls): Test.setUpCalled += 1 unittest.TestCase.setUpClass() def test_one(self): pass def test_two(self): pass result = self.runTests(Test) self.assertEqual(Test.setUpCalled, 1) self.assertEqual(result.testsRun, 2) self.assertEqual(len(result.errors), 0) def test_teardown_class(self): class Test(unittest.TestCase): tearDownCalled = 0 @classmethod def tearDownClass(cls): Test.tearDownCalled += 1 unittest.TestCase.tearDownClass() def test_one(self): pass def test_two(self): pass result = self.runTests(Test) self.assertEqual(Test.tearDownCalled, 1) self.assertEqual(result.testsRun, 2) self.assertEqual(len(result.errors), 0) def test_teardown_class_two_classes(self): class Test(unittest.TestCase): tearDownCalled = 0 @classmethod def tearDownClass(cls): Test.tearDownCalled += 1 unittest.TestCase.tearDownClass() def test_one(self): pass def test_two(self): pass class Test2(unittest.TestCase): tearDownCalled = 0 @classmethod def tearDownClass(cls): Test2.tearDownCalled += 1 unittest.TestCase.tearDownClass() def test_one(self): pass def test_two(self): pass result = self.runTests(Test, Test2) self.assertEqual(Test.tearDownCalled, 1) self.assertEqual(Test2.tearDownCalled, 1) self.assertEqual(result.testsRun, 4) self.assertEqual(len(result.errors), 0) def test_error_in_setupclass(self): class BrokenTest(unittest.TestCase): @classmethod def setUpClass(cls): raise TypeError('foo') def test_one(self): pass def test_two(self): pass result = self.runTests(BrokenTest) self.assertEqual(result.testsRun, 0) self.assertEqual(len(result.errors), 1) error, _ = result.errors[0] self.assertEqual(str(error), 'setUpClass (%s.BrokenTest)' % __name__) def test_error_in_teardown_class(self): class Test(unittest.TestCase): tornDown = 0 @classmethod def tearDownClass(cls): Test.tornDown += 1 raise TypeError('foo') def test_one(self): pass def test_two(self): pass class Test2(unittest.TestCase): tornDown = 0 @classmethod def tearDownClass(cls): Test2.tornDown += 1 raise TypeError('foo') def test_one(self): pass def test_two(self): pass result = self.runTests(Test, Test2) self.assertEqual(result.testsRun, 4) self.assertEqual(len(result.errors), 2) self.assertEqual(Test.tornDown, 1) self.assertEqual(Test2.tornDown, 1) error, _ = result.errors[0] self.assertEqual(str(error), 'tearDownClass (%s.Test)' % __name__) def test_class_not_torndown_when_setup_fails(self): class Test(unittest.TestCase): tornDown = False @classmethod def setUpClass(cls): raise TypeError @classmethod def tearDownClass(cls): Test.tornDown = True raise TypeError('foo') def test_one(self): pass self.runTests(Test) self.assertFalse(Test.tornDown) def test_class_not_setup_or_torndown_when_skipped(self): class Test(unittest.TestCase): classSetUp = False tornDown = False @classmethod def setUpClass(cls): Test.classSetUp = True @classmethod def tearDownClass(cls): Test.tornDown = True def test_one(self): pass Test = unittest.skip("hop")(Test) self.runTests(Test) self.assertFalse(Test.classSetUp) self.assertFalse(Test.tornDown) def test_setup_teardown_order_with_pathological_suite(self): results = [] class Module1(object): @staticmethod def setUpModule(): results.append('Module1.setUpModule') @staticmethod def tearDownModule(): results.append('Module1.tearDownModule') class Module2(object): @staticmethod def setUpModule(): results.append('Module2.setUpModule') @staticmethod def tearDownModule(): results.append('Module2.tearDownModule') class Test1(unittest.TestCase): @classmethod def setUpClass(cls): results.append('setup 1') @classmethod def tearDownClass(cls): results.append('teardown 1') def testOne(self): results.append('Test1.testOne') def testTwo(self): results.append('Test1.testTwo') class Test2(unittest.TestCase): @classmethod def setUpClass(cls): results.append('setup 2') @classmethod def tearDownClass(cls): results.append('teardown 2') def testOne(self): results.append('Test2.testOne') def testTwo(self): results.append('Test2.testTwo') class Test3(unittest.TestCase): @classmethod def setUpClass(cls): results.append('setup 3') @classmethod def tearDownClass(cls): results.append('teardown 3') def testOne(self): results.append('Test3.testOne') def testTwo(self): results.append('Test3.testTwo') Test1.__module__ = Test2.__module__ = 'Module' Test3.__module__ = 'Module2' sys.modules['Module'] = Module1 sys.modules['Module2'] = Module2 first = unittest.TestSuite((Test1('testOne'),)) second = unittest.TestSuite((Test1('testTwo'),)) third = unittest.TestSuite((Test2('testOne'),)) fourth = unittest.TestSuite((Test2('testTwo'),)) fifth = unittest.TestSuite((Test3('testOne'),)) sixth = unittest.TestSuite((Test3('testTwo'),)) suite = unittest.TestSuite((first, second, third, fourth, fifth, sixth)) runner = self.getRunner() result = runner.run(suite) self.assertEqual(result.testsRun, 6) self.assertEqual(len(result.errors), 0) self.assertEqual(results, ['Module1.setUpModule', 'setup 1', 'Test1.testOne', 'Test1.testTwo', 'teardown 1', 'setup 2', 'Test2.testOne', 'Test2.testTwo', 'teardown 2', 'Module1.tearDownModule', 'Module2.setUpModule', 'setup 3', 'Test3.testOne', 'Test3.testTwo', 'teardown 3', 'Module2.tearDownModule']) def test_setup_module(self): class Module(object): moduleSetup = 0 @staticmethod def setUpModule(): Module.moduleSetup += 1 class Test(unittest.TestCase): def test_one(self): pass def test_two(self): pass Test.__module__ = 'Module' sys.modules['Module'] = Module result = self.runTests(Test) self.assertEqual(Module.moduleSetup, 1) self.assertEqual(result.testsRun, 2) self.assertEqual(len(result.errors), 0) def test_error_in_setup_module(self): class Module(object): moduleSetup = 0 moduleTornDown = 0 @staticmethod def setUpModule(): Module.moduleSetup += 1 raise TypeError('foo') @staticmethod def tearDownModule(): Module.moduleTornDown += 1 class Test(unittest.TestCase): classSetUp = False classTornDown = False @classmethod def setUpClass(cls): Test.classSetUp = True @classmethod def tearDownClass(cls): Test.classTornDown = True def test_one(self): pass def test_two(self): pass class Test2(unittest.TestCase): def test_one(self): pass def test_two(self): pass Test.__module__ = 'Module' Test2.__module__ = 'Module' sys.modules['Module'] = Module result = self.runTests(Test, Test2) self.assertEqual(Module.moduleSetup, 1) self.assertEqual(Module.moduleTornDown, 0) self.assertEqual(result.testsRun, 0) self.assertFalse(Test.classSetUp) self.assertFalse(Test.classTornDown) self.assertEqual(len(result.errors), 1) error, _ = result.errors[0] self.assertEqual(str(error), 'setUpModule (Module)') def test_testcase_with_missing_module(self): class Test(unittest.TestCase): def test_one(self): pass def test_two(self): pass Test.__module__ = 'Module' sys.modules.pop('Module', None) result = self.runTests(Test) self.assertEqual(result.testsRun, 2) def test_teardown_module(self): class Module(object): moduleTornDown = 0 @staticmethod def tearDownModule(): Module.moduleTornDown += 1 class Test(unittest.TestCase): def test_one(self): pass def test_two(self): pass Test.__module__ = 'Module' sys.modules['Module'] = Module result = self.runTests(Test) self.assertEqual(Module.moduleTornDown, 1) self.assertEqual(result.testsRun, 2) self.assertEqual(len(result.errors), 0) def test_error_in_teardown_module(self): class Module(object): moduleTornDown = 0 @staticmethod def tearDownModule(): Module.moduleTornDown += 1 raise TypeError('foo') class Test(unittest.TestCase): classSetUp = False classTornDown = False @classmethod def setUpClass(cls): Test.classSetUp = True @classmethod def tearDownClass(cls): Test.classTornDown = True def test_one(self): pass def test_two(self): pass class Test2(unittest.TestCase): def test_one(self): pass def test_two(self): pass Test.__module__ = 'Module' Test2.__module__ = 'Module' sys.modules['Module'] = Module result = self.runTests(Test, Test2) self.assertEqual(Module.moduleTornDown, 1) self.assertEqual(result.testsRun, 4) self.assertTrue(Test.classSetUp) self.assertTrue(Test.classTornDown) self.assertEqual(len(result.errors), 1) error, _ = result.errors[0] self.assertEqual(str(error), 'tearDownModule (Module)') def test_skiptest_in_setupclass(self): class Test(unittest.TestCase): @classmethod def setUpClass(cls): raise unittest.SkipTest('foo') def test_one(self): pass def test_two(self): pass result = self.runTests(Test) self.assertEqual(result.testsRun, 0) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.skipped), 1) skipped = result.skipped[0][0] self.assertEqual(str(skipped), 'setUpClass (%s.Test)' % __name__) def test_skiptest_in_setupmodule(self): class Test(unittest.TestCase): def test_one(self): pass def test_two(self): pass class Module(object): @staticmethod def setUpModule(): raise unittest.SkipTest('foo') Test.__module__ = 'Module' sys.modules['Module'] = Module result = self.runTests(Test) self.assertEqual(result.testsRun, 0) self.assertEqual(len(result.errors), 0) self.assertEqual(len(result.skipped), 1) skipped = result.skipped[0][0] self.assertEqual(str(skipped), 'setUpModule (Module)') def test_suite_debug_executes_setups_and_teardowns(self): ordering = [] class Module(object): @staticmethod def setUpModule(): ordering.append('setUpModule') @staticmethod def tearDownModule(): ordering.append('tearDownModule') class Test(unittest.TestCase): @classmethod def setUpClass(cls): ordering.append('setUpClass') @classmethod def tearDownClass(cls): ordering.append('tearDownClass') def test_something(self): ordering.append('test_something') Test.__module__ = 'Module' sys.modules['Module'] = Module suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test) suite.debug() expectedOrder = ['setUpModule', 'setUpClass', 'test_something', 'tearDownClass', 'tearDownModule'] self.assertEqual(ordering, expectedOrder) def test_suite_debug_propagates_exceptions(self): class Module(object): @staticmethod def setUpModule(): if phase == 0: raise Exception('setUpModule') @staticmethod def tearDownModule(): if phase == 1: raise Exception('tearDownModule') class Test(unittest.TestCase): @classmethod def setUpClass(cls): if phase == 2: raise Exception('setUpClass') @classmethod def tearDownClass(cls): if phase == 3: raise Exception('tearDownClass') def test_something(self): if phase == 4: raise Exception('test_something') Test.__module__ = 'Module' sys.modules['Module'] = Module _suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test) suite = unittest.TestSuite() suite.addTest(_suite) messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something') for phase, msg in enumerate(messages): with self.assertRaisesRegexp(Exception, msg): suite.debug() if __name__ == '__main__': unittest.main() PK]}'test_functiontestcase.pyonu[ |fc@sRddlZddlmZdejfdYZedkrNejndS(iN(t LoggingResulttTest_FunctionTestCasecBsPeZdZdZdZdZdZdZdZdZ RS(cCs,tjd}|j|jddS(NcSsdS(N(tNone(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt ti(tunittesttFunctionTestCaset assertEqualtcountTestCases(tselfttest((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_countTestCases scsgt}fd}fd}fd}ddddg}tj|||j||j|dS(NcsjdtddS(NtsetUpsraised by setUp(tappendt RuntimeError((tevents(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR s csjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR scsjddS(NttearDown(R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR!st startTestR taddErrortstopTest(RRRtrunR(R tresultR R Rtexpected((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_run_call_order__error_in_setUps csgt}fd}fd}fd}dddddd g}tj|||j||j|dS( NcsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR 3scsjdtddS(NR sraised by test(R R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR 6s csjddS(NR(R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR:sRR R RRR(RRRRR(R RR R RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt"test_run_call_order__error_in_test/s  csgt}fd}fd}fd}dddddd g}tj|||j|j|dS( NcsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR MscsjdjddS(NR sraised by test(R tfail((RR (s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR Ps csjddS(NR(R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRTsRR R t addFailureRR(RRRRR(R RR R RR((RR s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt$test_run_call_order__failure_in_testIs  csgt}fd}fd}fd}dddddd g}tj|||j||j|dS( NcsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR gscsjddS(NR (R ((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR jscsjdtddS(NRsraised by tearDown(R R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRms RR R RRR(RRRRR(R RR R RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt&test_run_call_order__error_in_tearDowncs  cCs,tjd}|j|jtdS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR}R(RRtassertIsInstancetidt basestring(R R ((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_id|scCs,tjd}|j|jddS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRR(RRRtshortDescriptionR(R R ((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_shortDescription__no_docstringscCs8d}tjdd|}|j|jddS(Nsthis tests foocSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRRt description(RRRR!(R tdescR ((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt+test_shortDescription__singleline_docstrings( t__name__t __module__R RRRRR R"R%(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRs      t__main__(Rtunittest.test.supportRtTestCaseRR&tmain(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyts  PK]4}pptest_skipping.pynu[import unittest from unittest.test.support import LoggingResult class Test_TestSkipping(unittest.TestCase): def test_skipping(self): class Foo(unittest.TestCase): def test_skip_me(self): self.skipTest("skip") events = [] result = LoggingResult(events) test = Foo("test_skip_me") test.run(result) self.assertEqual(events, ['startTest', 'addSkip', 'stopTest']) self.assertEqual(result.skipped, [(test, "skip")]) # Try letting setUp skip the test now. class Foo(unittest.TestCase): def setUp(self): self.skipTest("testing") def test_nothing(self): pass events = [] result = LoggingResult(events) test = Foo("test_nothing") test.run(result) self.assertEqual(events, ['startTest', 'addSkip', 'stopTest']) self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(result.testsRun, 1) def test_skipping_decorators(self): op_table = ((unittest.skipUnless, False, True), (unittest.skipIf, True, False)) for deco, do_skip, dont_skip in op_table: class Foo(unittest.TestCase): @deco(do_skip, "testing") def test_skip(self): pass @deco(dont_skip, "testing") def test_dont_skip(self): pass test_do_skip = Foo("test_skip") test_dont_skip = Foo("test_dont_skip") suite = unittest.TestSuite([test_do_skip, test_dont_skip]) events = [] result = LoggingResult(events) suite.run(result) self.assertEqual(len(result.skipped), 1) expected = ['startTest', 'addSkip', 'stopTest', 'startTest', 'addSuccess', 'stopTest'] self.assertEqual(events, expected) self.assertEqual(result.testsRun, 2) self.assertEqual(result.skipped, [(test_do_skip, "testing")]) self.assertTrue(result.wasSuccessful()) def test_skip_class(self): @unittest.skip("testing") class Foo(unittest.TestCase): def test_1(self): record.append(1) record = [] result = unittest.TestResult() test = Foo("test_1") suite = unittest.TestSuite([test]) suite.run(result) self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, []) def test_skip_non_unittest_class_old_style(self): @unittest.skip("testing") class Mixin: def test_1(self): record.append(1) class Foo(Mixin, unittest.TestCase): pass record = [] result = unittest.TestResult() test = Foo("test_1") suite = unittest.TestSuite([test]) suite.run(result) self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, []) def test_skip_non_unittest_class_new_style(self): @unittest.skip("testing") class Mixin(object): def test_1(self): record.append(1) class Foo(Mixin, unittest.TestCase): pass record = [] result = unittest.TestResult() test = Foo("test_1") suite = unittest.TestSuite([test]) suite.run(result) self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, []) def test_expected_failure(self): class Foo(unittest.TestCase): @unittest.expectedFailure def test_die(self): self.fail("help me!") events = [] result = LoggingResult(events) test = Foo("test_die") test.run(result) self.assertEqual(events, ['startTest', 'addExpectedFailure', 'stopTest']) self.assertEqual(result.expectedFailures[0][0], test) self.assertTrue(result.wasSuccessful()) def test_unexpected_success(self): class Foo(unittest.TestCase): @unittest.expectedFailure def test_die(self): pass events = [] result = LoggingResult(events) test = Foo("test_die") test.run(result) self.assertEqual(events, ['startTest', 'addUnexpectedSuccess', 'stopTest']) self.assertFalse(result.failures) self.assertEqual(result.unexpectedSuccesses, [test]) self.assertTrue(result.wasSuccessful()) def test_skip_doesnt_run_setup(self): class Foo(unittest.TestCase): wasSetUp = False wasTornDown = False def setUp(self): Foo.wasSetUp = True def tornDown(self): Foo.wasTornDown = True @unittest.skip('testing') def test_1(self): pass result = unittest.TestResult() test = Foo("test_1") suite = unittest.TestSuite([test]) suite.run(result) self.assertEqual(result.skipped, [(test, "testing")]) self.assertFalse(Foo.wasSetUp) self.assertFalse(Foo.wasTornDown) def test_decorated_skip(self): def decorator(func): def inner(*a): return func(*a) return inner class Foo(unittest.TestCase): @decorator @unittest.skip('testing') def test_1(self): pass result = unittest.TestResult() test = Foo("test_1") suite = unittest.TestSuite([test]) suite.run(result) self.assertEqual(result.skipped, [(test, "testing")]) if __name__ == '__main__': unittest.main() PK]77test_discovery.pynu[import os import re import sys import unittest import unittest.test class TestDiscovery(unittest.TestCase): # Heavily mocked tests so I can avoid hitting the filesystem def test_get_name_from_path(self): loader = unittest.TestLoader() loader._top_level_dir = '/foo' name = loader._get_name_from_path('/foo/bar/baz.py') self.assertEqual(name, 'bar.baz') if not __debug__: # asserts are off return with self.assertRaises(AssertionError): loader._get_name_from_path('/bar/baz.py') def test_find_tests(self): loader = unittest.TestLoader() original_listdir = os.listdir def restore_listdir(): os.listdir = original_listdir original_isfile = os.path.isfile def restore_isfile(): os.path.isfile = original_isfile original_isdir = os.path.isdir def restore_isdir(): os.path.isdir = original_isdir path_lists = [['test1.py', 'test2.py', 'not_a_test.py', 'test_dir', 'test.foo', 'test-not-a-module.py', 'another_dir'], ['test3.py', 'test4.py', ]] os.listdir = lambda path: path_lists.pop(0) self.addCleanup(restore_listdir) def isdir(path): return path.endswith('dir') os.path.isdir = isdir self.addCleanup(restore_isdir) def isfile(path): # another_dir is not a package and so shouldn't be recursed into return not path.endswith('dir') and not 'another_dir' in path os.path.isfile = isfile self.addCleanup(restore_isfile) loader._get_module_from_name = lambda path: path + ' module' loader.loadTestsFromModule = lambda module: module + ' tests' top_level = os.path.abspath('/foo') loader._top_level_dir = top_level suite = list(loader._find_tests(top_level, 'test*.py')) expected = [name + ' module tests' for name in ('test1', 'test2')] expected.extend([('test_dir.%s' % name) + ' module tests' for name in ('test3', 'test4')]) self.assertEqual(suite, expected) def test_find_tests_with_package(self): loader = unittest.TestLoader() original_listdir = os.listdir def restore_listdir(): os.listdir = original_listdir original_isfile = os.path.isfile def restore_isfile(): os.path.isfile = original_isfile original_isdir = os.path.isdir def restore_isdir(): os.path.isdir = original_isdir directories = ['a_directory', 'test_directory', 'test_directory2'] path_lists = [directories, [], [], []] os.listdir = lambda path: path_lists.pop(0) self.addCleanup(restore_listdir) os.path.isdir = lambda path: True self.addCleanup(restore_isdir) os.path.isfile = lambda path: os.path.basename(path) not in directories self.addCleanup(restore_isfile) class Module(object): paths = [] load_tests_args = [] def __init__(self, path): self.path = path self.paths.append(path) if os.path.basename(path) == 'test_directory': def load_tests(loader, tests, pattern): self.load_tests_args.append((loader, tests, pattern)) return 'load_tests' self.load_tests = load_tests def __eq__(self, other): return self.path == other.path # Silence py3k warning __hash__ = None loader._get_module_from_name = lambda name: Module(name) def loadTestsFromModule(module, use_load_tests): if use_load_tests: raise self.failureException('use_load_tests should be False for packages') return module.path + ' module tests' loader.loadTestsFromModule = loadTestsFromModule loader._top_level_dir = '/foo' # this time no '.py' on the pattern so that it can match # a test package suite = list(loader._find_tests('/foo', 'test*')) # We should have loaded tests from the test_directory package by calling load_tests # and directly from the test_directory2 package self.assertEqual(suite, ['load_tests', 'test_directory2' + ' module tests']) self.assertEqual(Module.paths, ['test_directory', 'test_directory2']) # load_tests should have been called once with loader, tests and pattern self.assertEqual(Module.load_tests_args, [(loader, 'test_directory' + ' module tests', 'test*')]) def test_discover(self): loader = unittest.TestLoader() original_isfile = os.path.isfile original_isdir = os.path.isdir def restore_isfile(): os.path.isfile = original_isfile os.path.isfile = lambda path: False self.addCleanup(restore_isfile) orig_sys_path = sys.path[:] def restore_path(): sys.path[:] = orig_sys_path self.addCleanup(restore_path) full_path = os.path.abspath(os.path.normpath('/foo')) with self.assertRaises(ImportError): loader.discover('/foo/bar', top_level_dir='/foo') self.assertEqual(loader._top_level_dir, full_path) self.assertIn(full_path, sys.path) os.path.isfile = lambda path: True os.path.isdir = lambda path: True def restore_isdir(): os.path.isdir = original_isdir self.addCleanup(restore_isdir) _find_tests_args = [] def _find_tests(start_dir, pattern): _find_tests_args.append((start_dir, pattern)) return ['tests'] loader._find_tests = _find_tests loader.suiteClass = str suite = loader.discover('/foo/bar/baz', 'pattern', '/foo/bar') top_level_dir = os.path.abspath('/foo/bar') start_dir = os.path.abspath('/foo/bar/baz') self.assertEqual(suite, "['tests']") self.assertEqual(loader._top_level_dir, top_level_dir) self.assertEqual(_find_tests_args, [(start_dir, 'pattern')]) self.assertIn(top_level_dir, sys.path) def test_discover_with_modules_that_fail_to_import(self): loader = unittest.TestLoader() listdir = os.listdir os.listdir = lambda _: ['test_this_does_not_exist.py'] isfile = os.path.isfile os.path.isfile = lambda _: True orig_sys_path = sys.path[:] def restore(): os.path.isfile = isfile os.listdir = listdir sys.path[:] = orig_sys_path self.addCleanup(restore) suite = loader.discover('.') self.assertIn(os.getcwd(), sys.path) self.assertEqual(suite.countTestCases(), 1) test = list(list(suite)[0])[0] # extract test from suite with self.assertRaises(ImportError): test.test_this_does_not_exist() def test_command_line_handling_parseArgs(self): # Haha - take that uninstantiable class program = object.__new__(unittest.TestProgram) args = [] def do_discovery(argv): args.extend(argv) program._do_discovery = do_discovery program.parseArgs(['something', 'discover']) self.assertEqual(args, []) program.parseArgs(['something', 'discover', 'foo', 'bar']) self.assertEqual(args, ['foo', 'bar']) def test_command_line_handling_do_discovery_too_many_arguments(self): class Stop(Exception): pass def usageExit(): raise Stop program = object.__new__(unittest.TestProgram) program.usageExit = usageExit program.testLoader = None with self.assertRaises(Stop): # too many args program._do_discovery(['one', 'two', 'three', 'four']) def test_command_line_handling_do_discovery_uses_default_loader(self): program = object.__new__(unittest.TestProgram) class Loader(object): args = [] def discover(self, start_dir, pattern, top_level_dir): self.args.append((start_dir, pattern, top_level_dir)) return 'tests' program.testLoader = Loader() program._do_discovery(['-v']) self.assertEqual(Loader.args, [('.', 'test*.py', None)]) def test_command_line_handling_do_discovery_calls_loader(self): program = object.__new__(unittest.TestProgram) class Loader(object): args = [] def discover(self, start_dir, pattern, top_level_dir): self.args.append((start_dir, pattern, top_level_dir)) return 'tests' program._do_discovery(['-v'], Loader=Loader) self.assertEqual(program.verbosity, 2) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('.', 'test*.py', None)]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['--verbose'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('.', 'test*.py', None)]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery([], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('.', 'test*.py', None)]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['fish'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('fish', 'test*.py', None)]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['fish', 'eggs'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('fish', 'eggs', None)]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['fish', 'eggs', 'ham'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('fish', 'eggs', 'ham')]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['-s', 'fish'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('fish', 'test*.py', None)]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['-t', 'fish'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('.', 'test*.py', 'fish')]) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['-p', 'fish'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('.', 'fish', None)]) self.assertFalse(program.failfast) self.assertFalse(program.catchbreak) Loader.args = [] program = object.__new__(unittest.TestProgram) program._do_discovery(['-p', 'eggs', '-s', 'fish', '-v', '-f', '-c'], Loader=Loader) self.assertEqual(program.test, 'tests') self.assertEqual(Loader.args, [('fish', 'eggs', None)]) self.assertEqual(program.verbosity, 2) self.assertTrue(program.failfast) self.assertTrue(program.catchbreak) def setup_module_clash(self): class Module(object): __file__ = 'bar/foo.py' sys.modules['foo'] = Module full_path = os.path.abspath('foo') original_listdir = os.listdir original_isfile = os.path.isfile original_isdir = os.path.isdir def cleanup(): os.listdir = original_listdir os.path.isfile = original_isfile os.path.isdir = original_isdir del sys.modules['foo'] if full_path in sys.path: sys.path.remove(full_path) self.addCleanup(cleanup) def listdir(_): return ['foo.py'] def isfile(_): return True def isdir(_): return True os.listdir = listdir os.path.isfile = isfile os.path.isdir = isdir return full_path def test_detect_module_clash(self): full_path = self.setup_module_clash() loader = unittest.TestLoader() mod_dir = os.path.abspath('bar') expected_dir = os.path.abspath('foo') msg = re.escape(r"'foo' module incorrectly imported from %r. Expected %r. " "Is this module globally installed?" % (mod_dir, expected_dir)) self.assertRaisesRegexp( ImportError, '^%s$' % msg, loader.discover, start_dir='foo', pattern='foo.py' ) self.assertEqual(sys.path[0], full_path) def test_module_symlink_ok(self): full_path = self.setup_module_clash() original_realpath = os.path.realpath mod_dir = os.path.abspath('bar') expected_dir = os.path.abspath('foo') def cleanup(): os.path.realpath = original_realpath self.addCleanup(cleanup) def realpath(path): if path == os.path.join(mod_dir, 'foo.py'): return os.path.join(expected_dir, 'foo.py') return path os.path.realpath = realpath loader = unittest.TestLoader() loader.discover(start_dir='foo', pattern='foo.py') def test_discovery_from_dotted_path(self): loader = unittest.TestLoader() tests = [self] expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__)) self.wasRun = False def _find_tests(start_dir, pattern): self.wasRun = True self.assertEqual(start_dir, expectedPath) return tests loader._find_tests = _find_tests suite = loader.discover('unittest.test') self.assertTrue(self.wasRun) self.assertEqual(suite._tests, tests) if __name__ == '__main__': unittest.main() PK]22dummy.pynu[# Empty module for testing the loading of modules PK]L test_case.pycnu[ {fc@sddlZddlZddlZddlZddlZddlmZddlmZddl Z ddl m Z m Z m Z mZdefdYZde je e fdYZed kre jndS( iN(tdeepcopy(t test_support(t TestEqualityt TestHashingt LoggingResultt#ResultWithNoStartTestRunStopTestRuntTestcBsVeZdZdejfdYZdefdYZdejfdYZRS(s5Keep these TestCase classes out of the main namespacetFoocBseZdZdZRS(cCsdS(N((tself((s//usr/lib64/python2.7/unittest/test/test_case.pytrunTesttcCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest1R (t__name__t __module__R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRs tBarcBseZdZRS(cCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest2R (R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRstLoggingTestCasecBs2eZdZdZdZdZdZRS(s!A test case which logs its calls.cCs&ttj|jd||_dS(Nttest(tsuperRRt__init__tevents(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyRscCs|jjddS(NtsetUp(Rtappend(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR"scCs|jjddS(NR(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%scCs|jjddS(NttearDown(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR(s(R R t__doc__RRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs    (R R RtunittesttTestCaseRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRst Test_TestCasecBseZejdejdfgZejdejdfejdejdfejdejdfgZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZejej j!dkddZ"ejej j!dkddZ#dZ$dZ%dZ&d Z'd!Z(d"Z)d#Z*d$Z+d%Z,d&Z-d'Z.d(Z/d)Z0d*Z1d+Z2d,Z3d-Z4d.Z5d/Z6d0Z7d1Z8d2Z9d3Z:d4Z;d5Z<d6Z=d7Z>d8Z?d9Z@d:ZAd;ZBd<ZCd=ZDd>ZERS(?R R RcCs:dtjfdY}|j|jdddS(NRcBseZdZdZRS(cSs tdS(N(t TypeError(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR HR cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRIR (R R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRGs is .Test.runTest(RRt assertEqualtid(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__no_test_nameFscCs=dtjfdY}|j|djdddS(NRcBseZdZdZRS(cSs tdS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR SR cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRTR (R R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRRs Ris .Test.test(RRRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__validQscCsLdtjfdY}y|dWntk r:nX|jddS(NRcBseZdZdZRS(cSs tdS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR ^R cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR_R (R R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR]s ttestfoosFailed to raise ValueError(RRt ValueErrortfail(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__invalid\s  cCs9dtjfdY}|j|djddS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRlR (R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRksRi(RRRtcountTestCases(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_countTestCasesjscCsEdtjfdY}|j}|jt|tjdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR vs(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRus(RRtdefaultTestResultRttypet TestResult(RRtresult((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_defaultTestResulttscsjg}t|}dtjffdY|j|ddddg}|j||dS(NRcseZfdZRS(cs#t|jtddS(Nsraised by Foo.setUp(RRt RuntimeError(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRst startTestRtaddErrortstopTest(RRRtrunR(RRR*texpected((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt#test_run_call_order__error_in_setUps  csag}dtjffdY|jddddddg}|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t|jtddS(Nsraised by Foo.setUp(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs t startTestRunR-RR.R/t stopTestRun(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt2test_run_call_order__error_in_setUp_default_results   cspg}t|}dtjffdYddddddg}|j||j||dS( NRcseZfdZRS(cs#t|jtddS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsR-RRR.RR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order__error_in_tests  csgg}dtjffdYddddddd d g}|j|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t|jtddS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs R3R-RRR.RR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt1test_run_call_order__error_in_test_default_results cspg}t|}dtjffdYddddddg}|j||j||dS( NRcseZfdZRS(cs$t|j|jddS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsR-RRt addFailureRR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt$test_run_call_order__failure_in_tests  csgdtjffdYddddddd d g}g}|j|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs$t|j|jddS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs R3R-RRR8RR/R4(RRR0R(RR1R((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt3test_run_call_order__failure_in_test_default_results cspg}t|}dtjffdY|j|ddddddg}|j||dS( NRcseZfdZRS(cs#t|jtddS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsR-RRRR.R/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt&test_run_call_order__error_in_tearDowns  csgdtjffdYg}|jddddddd d g}|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t|jtddS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs R3R-RRRR.R/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt5test_run_call_order__error_in_tearDown_default_results cCs-dtjfdY}|djdS(NRcBseZdZdZRS(cSstS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs R(RRR0(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order_default_resultscCs6dtjfdY}|j|djtdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%s(R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR$sR(RRtassertIstfailureExceptiontAssertionError(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_failureException__default#scCszg}t|}dtjfdY}|j|djt|dj|dddg}|j||dS(NRcBseZdZeZRS(cSs tdS(N(R,(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR5s(R R RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyR4s RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__explicit_raise0s cCszg}t|}dtjfdY}|j|djt|dj|dddg}|j||dS(NRcBseZdZeZRS(cSs|jddS(Ntfoo(R#(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRLs(R R RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyRKs RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__implicit_raiseGs cCs*dtjfdY}|jdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR [s(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRZs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt test_setUpYscCs*dtjfdY}|jdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR ds(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRcs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt test_tearDownbscCs6dtjfdY}|j|jtdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR rs(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRqs(RRtassertIsInstanceRt basestring(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_idpscsagdtjffdY}|djddddddg}|j|dS( NRcs&eZfdZfdZRS(csjddS(NR(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRscs tS(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR's(R R RR'((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR~sRR3R-t addSuccessR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt test_run__uses_defaultTestResult{s   cCs|j|jdS(N(t assertIsNonetshortDescription(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt$testShortDescriptionWithoutDocstringsis)Docstrings are omitted with -O2 and abovecCs|j|jddS(s7Tests shortDescription() for a method with a docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt(testShortDescriptionWithOneLineDocstrings cCs|j|jddS(sTests shortDescription() for a method with a longer docstring. This method ensures that only the first line of a docstring is returned used in the short description, no matter how long the whole thing is. s>Tests shortDescription() for a method with a longer docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt*testShortDescriptionWithMultiLineDocstrings  csodtfdY}}|j||dfd}|j||j||dS(NtSadSnakecBseZdZRS(s)Dummy class for test_addTypeEqualityFunc.(R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRQscs$t|t|ko!kSS(N(R((tatbtmsg(RQ(s//usr/lib64/python2.7/unittest/test/test_case.pytAllSnakesCreatedEquals(tobjecttassertNotEqualtNonetaddTypeEqualityFuncR(Rts1ts2RU((RQs//usr/lib64/python2.7/unittest/test/test_case.pyttestAddTypeEqualityFuncs cCs<t}|j|||j|j|j|tdS(N(RVR>t assertRaisesR?(Rtthing((s//usr/lib64/python2.7/unittest/test/test_case.pyt testAssertIss cCs<t}|j|t|j|j|j||dS(N(RVt assertIsNotR]R?(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNots cCs6g}|j|t|j|j|j|tdS(N(RGtlistR]R?tdict(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsInstancescCs6g}|j|t|j|j|j|tdS(N(tassertNotIsInstanceRcR]R?Rb(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotIsInstancescCsKidd6dd6dd6}|jdd|jd d d d g|jd||jd d|jd d d d g|jd||j|j|jdd|j|j|jdd d d g|j|j|jd||j|j|jdd|j|j|jd d d d g|j|j|jd|dS(NtbananatmonkeytgrasstcowtfishtsealRRtabciiitditottertxitelephanttc(tassertInt assertNotInR]R?(Rtanimals((s//usr/lib64/python2.7/unittest/test/test_case.pyt testAssertIns%%cCs&|jii|jiidd6|jidd6idd6|jidd6idd6dd6|jidd6dd6idd6dd6|j|j|jidd6iWdQX|j|j#|jidd6idd6WdQX|j|j#|jidd6idd6WdQX|j|j*|jidd6dd6idd6WdQX|j|j*|jidd6dd6idd6WdQXtjdtf[djdtd D}|j|j#|ji|d 6id d 6WdQXWdQXdS( NiRRiRStoneRrR css|]}t|VqdS(N(tchr(t.0ti((s//usr/lib64/python2.7/unittest/test/test_case.pys siRCu�(tassertDictContainsSubsetR]R?Rtcheck_warningstUnicodeWarningtjointrange(RRw((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictContainsSubsets&%,$$++cCsd d fiifggfttfttfg}x|D]\}}y|j||Wn+|jk r|jd||fnXy|j||ddWn+|jk r|jd||fnXy|j||dWqF|jk r |jd||fqFXqFWd gfitftddgtddgftdd gtdd gftd dgtd dgfg}xq|D]i\}}|j|j|j|||j|j|j||d|j|j|j||ddqWdS(NsassertEqual(%r, %r) failedRTRCs$assertEqual(%r, %r) with msg= faileds/assertEqual(%r, %r) with third parameter failediiiii((((tsett frozensetRR?R#R](Rt equal_pairsRRRSt unequal_pairs((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEquals<      !!'cCs|jgg|jdd|jgdddgg}g}|jtjj|j|||jtjj|jt|t||jtjj|j|t||j||j|||jt|t||j|t||jt|||j|j|j|t||j|j|jt|||j|j|jd||j|j|jdt||j|j|jdt||j|j|jdd|j|j|jdd|j|j|jdd|j iiidd6}i}|jtjj|j |||j ||j ||d|d<|jtjj|j ||d|j|j|j d||j|j|j g||j|j|j dddS( NiRRiRpsThese are unequal(((( tassertListEqualtassertTupleEqualtassertSequenceEqualR]RRR?ttupletextendRXtassertDictEqualtupdate(RRRRSRrRn((s//usr/lib64/python2.7/unittest/test/test_case.pyt testEqualitysT      cCs|j|jd ddd }ddd }djtjtj|jtj|j}tj j t |df}t |d|_y|j ||Wn#|j k r}|jd }nX|jd |jt |t ||j||t |d|_y|j ||Wn#|j k rW}|jd }nX|jd |jt |t ||j||d|_y|j ||Wn#|j k r}|jd }nX|jd |jt |t ||j||dS(NiPiRRRpiRSs iis!assertSequenceEqual did not fail.iii(RtmaxDiffR~tdifflibtndifftpprinttpformatt splitlinesRtcaset DIFF_OMITTEDtlenRR?targsR#t assertLessRst assertGreaterRtRX(Rtseq1tseq2tdifftomittedteRT((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSequenceEqualMaxDiffRs<    cCsd|_|jdd}tjjtd}|j|d|d|_|jdd}|j|dd|_|jdd}|j|ddS(NiRCtbartfoobari(Rt_truncateMessageRRRRRRX(RtmessageR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestTruncateMessageys   cCs|tjd}d}||_y|jiidd6Wn,|jk rj}|jt|dnX|jddS(NRcSsdS(NRC((RTR((s//usr/lib64/python2.7/unittest/test/test_case.pyttruncatesiiRCsassertDictEqual did not fail(RRRRR?RtstrR#(RRRR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictEqualTruncatess  cCsutjd}d}||_y|jddWn,|jk rc}|jt|dnX|jddS(NRcSsdS(NRC((RTR((s//usr/lib64/python2.7/unittest/test/test_case.pyRsRCRs!assertMultiLineEqual did not fail(RRRtassertMultiLineEqualR?RRR#(RRRR((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testAssertMultiLineEqualTruncatess  csjjdd_jd_jfddd}jj}j|d|dWdQXjd t|j j|d|ddd}d }j |_ jfd |d|d}}jj}j||WdQXj d t|j jt|j d ||fj|d|ddS(NiiicstdS(Nt_diffThreshold(tsetattr((t old_thresholdR(s//usr/lib64/python2.7/unittest/test/test_case.pytR uxiRRRSt^i cSstddS(Nsthis should not be raised(t SystemError(RR((s//usr/lib64/python2.7/unittest/test/test_case.pytexplodingTruncationscstdS(NR(R((t old_truncateR(s//usr/lib64/python2.7/unittest/test/test_case.pyRR s%r != %riiii( RRRXRt addCleanupR]R?RsRt exceptionRRt(RtstcmRRZR[((RRRs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEqual_diffThresholds*        #c Csyt}|jdddgdddg|jdddgdddg|j||dddg|dd|df|jddddgddtdg|j|j|jddgdgd dgd ddg|j|j|jddddgddtdg|j|j|jd gd d g|j|j|jd d gd g|j|j|jd d d gd d g|jddgdd gd gtdd gddgg|jtddgdd gtddgdd g|j|j|jgtddddtg|jidd6idd6gidd6idd6g|jddtggtgddg|j|j|jgtgddddt g|j|j|jdggdgg|j|j|jdddgddg|j|j|jdddddgddtdg|j|j|jdidd6dtgidd6tdgdd hddhg}|ddd}|j||t t j j dd}ddddh}|j||t j j ggg}|j|dd gfgt t j jdd}ddddh}|j||dS(NiiiRCRtbazt2RRidi i iiRpy@y@RSitaaabccdtabbbcceRnR(iiRR(iiRS(iiRn(iiR(iiRR(iiRS(iiRn(iiR(RVtassertItemsEqualtTrueR]R?tFalsetitertdivmodRRRXRtutilt_count_diff_all_purposeRt_count_diff_hashable(RRRRStdiffsR1((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertItemsEqualsV "".(,":8("%-cCs*t}t}|j|||j|j|jd||j|j|jg||j|j|j|d|j|j|j|gtdg}t}|j|j|j||tdg}tdg}|j||tdg}tddg}|j|j|j||tdg}tddg}|j|j|j||tddg}tddg}|j||t}d}|j|j|j|||j|j|j||td d g}td g}|j|j|j||dS( NRRRSRCiiiiii(ii(ii(ii(RtassertSetEqualR]R?RXR(Rtset1tset2((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSetEquals:    cCs4|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdddS( Niig?g?tbugtantubuguant(RtassertGreaterEqualRtassertLessEqualR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestInequality)scCsd}d}d}d|_xddfD]w}y |j||||Wq.|jk r}t|jdjddd}|j||kq.Xq.WdS( Nsxhttp://www.python.org/doc/2.3/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] shttp://www.python.org/doc/2.4.1/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] You may provide your own implementation that does not subclass from TestCase, of course. s- http://www.python.org/doc/2.3/lib/module-unittest.html ? ^ + http://www.python.org/doc/2.4.1/lib/module-unittest.html ? ^^^ test case - A test case is the smallest unit of testing. [...] + A test case is the smallest unit of testing. [...] You may provide your ? +++++++++++++++++++++ + own implementation that does not subclass from TestCase, of course. cSs|S(N((Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyRR cSs |jdS(Ntutf8(tdecode(Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyRR Rs i(RXRRR?Rtencodetsplitt assertTrue(Rt sample_texttrevised_sample_texttsample_text_errort type_changerRterror((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertMultiLineEquals  %cCsrd}d}d}y|j||WnE|jk rm}t|jddd}|j||knXdS(Nuladen swallows fly slowlyuunladen swallows fly quicklysr- laden swallows fly slowly ? ^^^^ + unladen swallows fly quickly ? ++ ^^^^^ s i(RR?RRR(RRRRRR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAsertEqualSingleLinescCsP|jd|j|j|jt|jd|j|j|jddS(NsDjZoPloGears on Rails(RLRXR]R?RtassertIsNotNone(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNones  cCs0|jdd|j|j|jdddS(Nt asdfabasdfsab+tsaaastaaaa(tassertRegexpMatchesR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRegexpMatchesscsdtfdYfd}|j||jtf||jttddd|j|j|jdWdQX|j|jt|WdQXdS(Nt ExceptionMockcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscsddS(Ns We expect(((R(s//usr/lib64/python2.7/unittest/test/test_case.pytStubst19tbaseicSsdS(Ni((((s//usr/lib64/python2.7/unittest/test/test_case.pyRR (t ExceptionR]R"tintR?(RR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesCallablesc sdtfdYfd}|j |WdQX|jtf}|WdQX|j|j|j|jjdd|jttdddWdQX|j|j|jWdQXWdQX|j|jt|WdQXdS( NRcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscsddS(Ns We expect(((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsis We expectRRi( RR]R"RGRRRRR?(RRR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesContexts   cskdtfdYfd}|jtjd||jd||jd|dS(NRcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscsddS(Ns We expect(((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRssexpect$uexpect$(RtassertRaisesRegexptretcompile(RR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexps cCs||j|jd|jttjdd|j|jd|jtdd|j|jd|jtdddS(Ns^Exception not raised$RpcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR cSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR uxcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR (RR?RRR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotRaisesRegexps       cCs6dtfdY}|jt|j|ddS(NtMyExccBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscSstS(N(R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR (RR]RR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt#testAssertRaisesRegexpInvalidRegexpscCs|d}|j|jd|jtd||j|jd|jtd||j|jd|jttjd|dS(NcSstddS(Nt Unexpected(R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRss*"\^Expected\$" does not match "Unexpected"s ^Expected$u ^Expected$(RR?RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexpMismatchs     csdtfdYfd}d}|j}|||WdQX|j}|j||j|jd|dS(NRcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscs|dS(N((RC(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRssparticular valuei(RR]RRGRR(RRtvtctxR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesExcValues cCsQ|jdd|jdd|jdd|jdd|jtdS(sTest undocumented method name synonyms. Please do not use these methods names in your own code. This test confirms their continued existence and functionality in order to avoid breaking existing code. iig@g@g@N(tassertNotEqualst assertEqualstassertAlmostEqualstassertNotAlmostEqualstassert_R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestSynonymAssertMethodNames(s cCstjr|jdd|jdd|jdd|jdd|jt|jt d|j t WdQXdS(sTest fail* methods pending deprecation, they will warn in 3.2. Do not use these methods. They will go away in 3.3. iig@g@g@cSsddS(NgQ @uspam((t_((s//usr/lib64/python2.7/unittest/test/test_case.pyRAR N( RR|t failIfEqualtfailUnlessEqualtfailUnlessAlmostEqualtfailIfAlmostEqualt failUnlessRtfailUnlessRaisesRtfailIfR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testPendingDeprecationMethodNames6s  cCs3dtjfdY}|d}t|dS(Nt TestableTestcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyt testNothingGs(R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRFsR(RRR(RRR((s//usr/lib64/python2.7/unittest/test/test_case.pyt testDeepcopyDs csddddtjffdY}dtjffdY}dtjffdY}d tjffd Y}x@||||fD],}|jt|d jWdQXqWdS( NcSs tdS(N(tKeyboardInterrupt(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt_raisePscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pytnothingRstTest1cseZZRS((R R ttest_something((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR UstTest2cseZZZRS((R R RR ((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR XstTest3cseZZZRS((R R R R((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR \stTest4cseZfdZRS(cs|jdS(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR as(R R R ((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR`sR (RXRRR]RR0(RR R R Rtklass((RR s//usr/lib64/python2.7/unittest/test/test_case.pyttestKeyboardInterruptOs  ""csddddtjffdY}dtjffdY}dtjffdY}d tjffd Y}xe||||fD]Q}tj}|d j||jt|jd |j|jd qWdS( NcSs tdS(N(t SystemExit(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRiscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR ksR cseZZRS((R R R ((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR nsR cseZZZRS((R R RR ((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR qsR cseZZZRS((R R R R((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR usRcseZfdZRS(cs|jdS(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR zs(R R R ((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRysR i( RXRRR)R0RRterrorsttestsRun(RR R R RRR*((RR s//usr/lib64/python2.7/unittest/test/test_case.pyttestSystemExiths  "" cCsetjd}xOttjdD]:}tj|d|}tj|}|j||q#WdS(NR0itprotocol(RRRtpickletHIGHEST_PROTOCOLtdumpstloadsR(RRRt pickled_testtunpickled_test((s//usr/lib64/python2.7/unittest/test/test_case.pyt testPickles (FR R RRteq_pairsRtne_pairsRR R$R&R+R2R5R6R7R9R:R;R<R=RARBRDRERFRIRKRNRtskipIftsystflagstoptimizeRORPR\R_RaRdRfRvRRRRRRRRRRRRRRRRRRRRRRRRRRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyR,s!!                       % 4 '  $ > ( V $             t__main__(RRRRR tcopyRRRRtunittest.test.supportRRRRRVRRRR tmain(((s//usr/lib64/python2.7/unittest/test/test_case.pyts      "j PK]  test_case.pynu[import difflib import pprint import pickle import re import sys from copy import deepcopy from test import test_support import unittest from unittest.test.support import ( TestEquality, TestHashing, LoggingResult, ResultWithNoStartTestRunStopTestRun ) class Test(object): "Keep these TestCase classes out of the main namespace" class Foo(unittest.TestCase): def runTest(self): pass def test1(self): pass class Bar(Foo): def test2(self): pass class LoggingTestCase(unittest.TestCase): """A test case which logs its calls.""" def __init__(self, events): super(Test.LoggingTestCase, self).__init__('test') self.events = events def setUp(self): self.events.append('setUp') def test(self): self.events.append('test') def tearDown(self): self.events.append('tearDown') class Test_TestCase(unittest.TestCase, TestEquality, TestHashing): ### Set up attributes used by inherited tests ################################################################ # Used by TestHashing.test_hash and TestEquality.test_eq eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))] # Used by TestEquality.test_ne ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest')) ,(Test.Foo('test1'), Test.Bar('test1')) ,(Test.Foo('test1'), Test.Bar('test2'))] ################################################################ ### /Set up attributes used by inherited tests # "class TestCase([methodName])" # ... # "Each instance of TestCase will run a single test method: the # method named methodName." # ... # "methodName defaults to "runTest"." # # Make sure it really is optional, and that it defaults to the proper # thing. def test_init__no_test_name(self): class Test(unittest.TestCase): def runTest(self): raise TypeError() def test(self): pass self.assertEqual(Test().id()[-13:], '.Test.runTest') # "class TestCase([methodName])" # ... # "Each instance of TestCase will run a single test method: the # method named methodName." def test_init__test_name__valid(self): class Test(unittest.TestCase): def runTest(self): raise TypeError() def test(self): pass self.assertEqual(Test('test').id()[-10:], '.Test.test') # "class TestCase([methodName])" # ... # "Each instance of TestCase will run a single test method: the # method named methodName." def test_init__test_name__invalid(self): class Test(unittest.TestCase): def runTest(self): raise TypeError() def test(self): pass try: Test('testfoo') except ValueError: pass else: self.fail("Failed to raise ValueError") # "Return the number of tests represented by the this test object. For # TestCase instances, this will always be 1" def test_countTestCases(self): class Foo(unittest.TestCase): def test(self): pass self.assertEqual(Foo('test').countTestCases(), 1) # "Return the default type of test result object to be used to run this # test. For TestCase instances, this will always be # unittest.TestResult; subclasses of TestCase should # override this as necessary." def test_defaultTestResult(self): class Foo(unittest.TestCase): def runTest(self): pass result = Foo().defaultTestResult() self.assertEqual(type(result), unittest.TestResult) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if setUp() raises # an exception. def test_run_call_order__error_in_setUp(self): events = [] result = LoggingResult(events) class Foo(Test.LoggingTestCase): def setUp(self): super(Foo, self).setUp() raise RuntimeError('raised by Foo.setUp') Foo(events).run(result) expected = ['startTest', 'setUp', 'addError', 'stopTest'] self.assertEqual(events, expected) # "With a temporary result stopTestRun is called when setUp errors. def test_run_call_order__error_in_setUp_default_result(self): events = [] class Foo(Test.LoggingTestCase): def defaultTestResult(self): return LoggingResult(self.events) def setUp(self): super(Foo, self).setUp() raise RuntimeError('raised by Foo.setUp') Foo(events).run() expected = ['startTestRun', 'startTest', 'setUp', 'addError', 'stopTest', 'stopTestRun'] self.assertEqual(events, expected) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if the test raises # an error (as opposed to a failure). def test_run_call_order__error_in_test(self): events = [] result = LoggingResult(events) class Foo(Test.LoggingTestCase): def test(self): super(Foo, self).test() raise RuntimeError('raised by Foo.test') expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown', 'stopTest'] Foo(events).run(result) self.assertEqual(events, expected) # "With a default result, an error in the test still results in stopTestRun # being called." def test_run_call_order__error_in_test_default_result(self): events = [] class Foo(Test.LoggingTestCase): def defaultTestResult(self): return LoggingResult(self.events) def test(self): super(Foo, self).test() raise RuntimeError('raised by Foo.test') expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError', 'tearDown', 'stopTest', 'stopTestRun'] Foo(events).run() self.assertEqual(events, expected) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if the test signals # a failure (as opposed to an error). def test_run_call_order__failure_in_test(self): events = [] result = LoggingResult(events) class Foo(Test.LoggingTestCase): def test(self): super(Foo, self).test() self.fail('raised by Foo.test') expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown', 'stopTest'] Foo(events).run(result) self.assertEqual(events, expected) # "When a test fails with a default result stopTestRun is still called." def test_run_call_order__failure_in_test_default_result(self): class Foo(Test.LoggingTestCase): def defaultTestResult(self): return LoggingResult(self.events) def test(self): super(Foo, self).test() self.fail('raised by Foo.test') expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure', 'tearDown', 'stopTest', 'stopTestRun'] events = [] Foo(events).run() self.assertEqual(events, expected) # "When a setUp() method is defined, the test runner will run that method # prior to each test. Likewise, if a tearDown() method is defined, the # test runner will invoke that method after each test. In the example, # setUp() was used to create a fresh sequence for each test." # # Make sure the proper call order is maintained, even if tearDown() raises # an exception. def test_run_call_order__error_in_tearDown(self): events = [] result = LoggingResult(events) class Foo(Test.LoggingTestCase): def tearDown(self): super(Foo, self).tearDown() raise RuntimeError('raised by Foo.tearDown') Foo(events).run(result) expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError', 'stopTest'] self.assertEqual(events, expected) # "When tearDown errors with a default result stopTestRun is still called." def test_run_call_order__error_in_tearDown_default_result(self): class Foo(Test.LoggingTestCase): def defaultTestResult(self): return LoggingResult(self.events) def tearDown(self): super(Foo, self).tearDown() raise RuntimeError('raised by Foo.tearDown') events = [] Foo(events).run() expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown', 'addError', 'stopTest', 'stopTestRun'] self.assertEqual(events, expected) # "TestCase.run() still works when the defaultTestResult is a TestResult # that does not support startTestRun and stopTestRun. def test_run_call_order_default_result(self): class Foo(unittest.TestCase): def defaultTestResult(self): return ResultWithNoStartTestRunStopTestRun() def test(self): pass Foo('test').run() # "This class attribute gives the exception raised by the test() method. # If a test framework needs to use a specialized exception, possibly to # carry additional information, it must subclass this exception in # order to ``play fair'' with the framework. The initial value of this # attribute is AssertionError" def test_failureException__default(self): class Foo(unittest.TestCase): def test(self): pass self.assertIs(Foo('test').failureException, AssertionError) # "This class attribute gives the exception raised by the test() method. # If a test framework needs to use a specialized exception, possibly to # carry additional information, it must subclass this exception in # order to ``play fair'' with the framework." # # Make sure TestCase.run() respects the designated failureException def test_failureException__subclassing__explicit_raise(self): events = [] result = LoggingResult(events) class Foo(unittest.TestCase): def test(self): raise RuntimeError() failureException = RuntimeError self.assertIs(Foo('test').failureException, RuntimeError) Foo('test').run(result) expected = ['startTest', 'addFailure', 'stopTest'] self.assertEqual(events, expected) # "This class attribute gives the exception raised by the test() method. # If a test framework needs to use a specialized exception, possibly to # carry additional information, it must subclass this exception in # order to ``play fair'' with the framework." # # Make sure TestCase.run() respects the designated failureException def test_failureException__subclassing__implicit_raise(self): events = [] result = LoggingResult(events) class Foo(unittest.TestCase): def test(self): self.fail("foo") failureException = RuntimeError self.assertIs(Foo('test').failureException, RuntimeError) Foo('test').run(result) expected = ['startTest', 'addFailure', 'stopTest'] self.assertEqual(events, expected) # "The default implementation does nothing." def test_setUp(self): class Foo(unittest.TestCase): def runTest(self): pass # ... and nothing should happen Foo().setUp() # "The default implementation does nothing." def test_tearDown(self): class Foo(unittest.TestCase): def runTest(self): pass # ... and nothing should happen Foo().tearDown() # "Return a string identifying the specific test case." # # Because of the vague nature of the docs, I'm not going to lock this # test down too much. Really all that can be asserted is that the id() # will be a string (either 8-byte or unicode -- again, because the docs # just say "string") def test_id(self): class Foo(unittest.TestCase): def runTest(self): pass self.assertIsInstance(Foo().id(), basestring) # "If result is omitted or None, a temporary result object is created # and used, but is not made available to the caller. As TestCase owns the # temporary result startTestRun and stopTestRun are called. def test_run__uses_defaultTestResult(self): events = [] class Foo(unittest.TestCase): def test(self): events.append('test') def defaultTestResult(self): return LoggingResult(events) # Make run() find a result object on its own Foo('test').run() expected = ['startTestRun', 'startTest', 'test', 'addSuccess', 'stopTest', 'stopTestRun'] self.assertEqual(events, expected) def testShortDescriptionWithoutDocstring(self): self.assertIsNone(self.shortDescription()) @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def testShortDescriptionWithOneLineDocstring(self): """Tests shortDescription() for a method with a docstring.""" self.assertEqual( self.shortDescription(), 'Tests shortDescription() for a method with a docstring.') @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def testShortDescriptionWithMultiLineDocstring(self): """Tests shortDescription() for a method with a longer docstring. This method ensures that only the first line of a docstring is returned used in the short description, no matter how long the whole thing is. """ self.assertEqual( self.shortDescription(), 'Tests shortDescription() for a method with a longer ' 'docstring.') def testAddTypeEqualityFunc(self): class SadSnake(object): """Dummy class for test_addTypeEqualityFunc.""" s1, s2 = SadSnake(), SadSnake() self.assertNotEqual(s1, s2) def AllSnakesCreatedEqual(a, b, msg=None): return type(a) is type(b) is SadSnake self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual) self.assertEqual(s1, s2) # No this doesn't clean up and remove the SadSnake equality func # from this TestCase instance but since its a local nothing else # will ever notice that. def testAssertIs(self): thing = object() self.assertIs(thing, thing) self.assertRaises(self.failureException, self.assertIs, thing, object()) def testAssertIsNot(self): thing = object() self.assertIsNot(thing, object()) self.assertRaises(self.failureException, self.assertIsNot, thing, thing) def testAssertIsInstance(self): thing = [] self.assertIsInstance(thing, list) self.assertRaises(self.failureException, self.assertIsInstance, thing, dict) def testAssertNotIsInstance(self): thing = [] self.assertNotIsInstance(thing, dict) self.assertRaises(self.failureException, self.assertNotIsInstance, thing, list) def testAssertIn(self): animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'} self.assertIn('a', 'abc') self.assertIn(2, [1, 2, 3]) self.assertIn('monkey', animals) self.assertNotIn('d', 'abc') self.assertNotIn(0, [1, 2, 3]) self.assertNotIn('otter', animals) self.assertRaises(self.failureException, self.assertIn, 'x', 'abc') self.assertRaises(self.failureException, self.assertIn, 4, [1, 2, 3]) self.assertRaises(self.failureException, self.assertIn, 'elephant', animals) self.assertRaises(self.failureException, self.assertNotIn, 'c', 'abc') self.assertRaises(self.failureException, self.assertNotIn, 1, [1, 2, 3]) self.assertRaises(self.failureException, self.assertNotIn, 'cow', animals) def testAssertDictContainsSubset(self): self.assertDictContainsSubset({}, {}) self.assertDictContainsSubset({}, {'a': 1}) self.assertDictContainsSubset({'a': 1}, {'a': 1}) self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2}) self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2}) with self.assertRaises(self.failureException): self.assertDictContainsSubset({1: "one"}, {}) with self.assertRaises(self.failureException): self.assertDictContainsSubset({'a': 2}, {'a': 1}) with self.assertRaises(self.failureException): self.assertDictContainsSubset({'c': 1}, {'a': 1}) with self.assertRaises(self.failureException): self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1}) with self.assertRaises(self.failureException): self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1}) with test_support.check_warnings(("", UnicodeWarning)): one = ''.join(chr(i) for i in range(255)) # this used to cause a UnicodeDecodeError constructing the failure msg with self.assertRaises(self.failureException): self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'}) def testAssertEqual(self): equal_pairs = [ ((), ()), ({}, {}), ([], []), (set(), set()), (frozenset(), frozenset())] for a, b in equal_pairs: # This mess of try excepts is to test the assertEqual behavior # itself. try: self.assertEqual(a, b) except self.failureException: self.fail('assertEqual(%r, %r) failed' % (a, b)) try: self.assertEqual(a, b, msg='foo') except self.failureException: self.fail('assertEqual(%r, %r) with msg= failed' % (a, b)) try: self.assertEqual(a, b, 'foo') except self.failureException: self.fail('assertEqual(%r, %r) with third parameter failed' % (a, b)) unequal_pairs = [ ((), []), ({}, set()), (set([4,1]), frozenset([4,2])), (frozenset([4,5]), set([2,3])), (set([3,4]), set([5,4]))] for a, b in unequal_pairs: self.assertRaises(self.failureException, self.assertEqual, a, b) self.assertRaises(self.failureException, self.assertEqual, a, b, 'foo') self.assertRaises(self.failureException, self.assertEqual, a, b, msg='foo') def testEquality(self): self.assertListEqual([], []) self.assertTupleEqual((), ()) self.assertSequenceEqual([], ()) a = [0, 'a', []] b = [] self.assertRaises(unittest.TestCase.failureException, self.assertListEqual, a, b) self.assertRaises(unittest.TestCase.failureException, self.assertListEqual, tuple(a), tuple(b)) self.assertRaises(unittest.TestCase.failureException, self.assertSequenceEqual, a, tuple(b)) b.extend(a) self.assertListEqual(a, b) self.assertTupleEqual(tuple(a), tuple(b)) self.assertSequenceEqual(a, tuple(b)) self.assertSequenceEqual(tuple(a), b) self.assertRaises(self.failureException, self.assertListEqual, a, tuple(b)) self.assertRaises(self.failureException, self.assertTupleEqual, tuple(a), b) self.assertRaises(self.failureException, self.assertListEqual, None, b) self.assertRaises(self.failureException, self.assertTupleEqual, None, tuple(b)) self.assertRaises(self.failureException, self.assertSequenceEqual, None, tuple(b)) self.assertRaises(self.failureException, self.assertListEqual, 1, 1) self.assertRaises(self.failureException, self.assertTupleEqual, 1, 1) self.assertRaises(self.failureException, self.assertSequenceEqual, 1, 1) self.assertDictEqual({}, {}) c = { 'x': 1 } d = {} self.assertRaises(unittest.TestCase.failureException, self.assertDictEqual, c, d) d.update(c) self.assertDictEqual(c, d) d['x'] = 0 self.assertRaises(unittest.TestCase.failureException, self.assertDictEqual, c, d, 'These are unequal') self.assertRaises(self.failureException, self.assertDictEqual, None, d) self.assertRaises(self.failureException, self.assertDictEqual, [], d) self.assertRaises(self.failureException, self.assertDictEqual, 1, 1) def testAssertSequenceEqualMaxDiff(self): self.assertEqual(self.maxDiff, 80*8) seq1 = 'a' + 'x' * 80**2 seq2 = 'b' + 'x' * 80**2 diff = '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(), pprint.pformat(seq2).splitlines())) # the +1 is the leading \n added by assertSequenceEqual omitted = unittest.case.DIFF_OMITTED % (len(diff) + 1,) self.maxDiff = len(diff)//2 try: self.assertSequenceEqual(seq1, seq2) except self.failureException as e: msg = e.args[0] else: self.fail('assertSequenceEqual did not fail.') self.assertLess(len(msg), len(diff)) self.assertIn(omitted, msg) self.maxDiff = len(diff) * 2 try: self.assertSequenceEqual(seq1, seq2) except self.failureException as e: msg = e.args[0] else: self.fail('assertSequenceEqual did not fail.') self.assertGreater(len(msg), len(diff)) self.assertNotIn(omitted, msg) self.maxDiff = None try: self.assertSequenceEqual(seq1, seq2) except self.failureException as e: msg = e.args[0] else: self.fail('assertSequenceEqual did not fail.') self.assertGreater(len(msg), len(diff)) self.assertNotIn(omitted, msg) def testTruncateMessage(self): self.maxDiff = 1 message = self._truncateMessage('foo', 'bar') omitted = unittest.case.DIFF_OMITTED % len('bar') self.assertEqual(message, 'foo' + omitted) self.maxDiff = None message = self._truncateMessage('foo', 'bar') self.assertEqual(message, 'foobar') self.maxDiff = 4 message = self._truncateMessage('foo', 'bar') self.assertEqual(message, 'foobar') def testAssertDictEqualTruncates(self): test = unittest.TestCase('assertEqual') def truncate(msg, diff): return 'foo' test._truncateMessage = truncate try: test.assertDictEqual({}, {1: 0}) except self.failureException as e: self.assertEqual(str(e), 'foo') else: self.fail('assertDictEqual did not fail') def testAssertMultiLineEqualTruncates(self): test = unittest.TestCase('assertEqual') def truncate(msg, diff): return 'foo' test._truncateMessage = truncate try: test.assertMultiLineEqual('foo', 'bar') except self.failureException as e: self.assertEqual(str(e), 'foo') else: self.fail('assertMultiLineEqual did not fail') def testAssertEqual_diffThreshold(self): # check threshold value self.assertEqual(self._diffThreshold, 2**16) # disable madDiff to get diff markers self.maxDiff = None # set a lower threshold value and add a cleanup to restore it old_threshold = self._diffThreshold self._diffThreshold = 2**8 self.addCleanup(lambda: setattr(self, '_diffThreshold', old_threshold)) # under the threshold: diff marker (^) in error message s = u'x' * (2**7) with self.assertRaises(self.failureException) as cm: self.assertEqual(s + 'a', s + 'b') self.assertIn('^', str(cm.exception)) self.assertEqual(s + 'a', s + 'a') # over the threshold: diff not used and marker (^) not in error message s = u'x' * (2**9) # if the path that uses difflib is taken, _truncateMessage will be # called -- replace it with explodingTruncation to verify that this # doesn't happen def explodingTruncation(message, diff): raise SystemError('this should not be raised') old_truncate = self._truncateMessage self._truncateMessage = explodingTruncation self.addCleanup(lambda: setattr(self, '_truncateMessage', old_truncate)) s1, s2 = s + 'a', s + 'b' with self.assertRaises(self.failureException) as cm: self.assertEqual(s1, s2) self.assertNotIn('^', str(cm.exception)) self.assertEqual(str(cm.exception), '%r != %r' % (s1, s2)) self.assertEqual(s + 'a', s + 'a') def testAssertItemsEqual(self): a = object() self.assertItemsEqual([1, 2, 3], [3, 2, 1]) self.assertItemsEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo']) self.assertItemsEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2)) self.assertItemsEqual([1, "2", "a", "a"], ["a", "2", True, "a"]) self.assertRaises(self.failureException, self.assertItemsEqual, [1, 2] + [3] * 100, [1] * 100 + [2, 3]) self.assertRaises(self.failureException, self.assertItemsEqual, [1, "2", "a", "a"], ["a", "2", True, 1]) self.assertRaises(self.failureException, self.assertItemsEqual, [10], [10, 11]) self.assertRaises(self.failureException, self.assertItemsEqual, [10, 11], [10]) self.assertRaises(self.failureException, self.assertItemsEqual, [10, 11, 10], [10, 11]) # Test that sequences of unhashable objects can be tested for sameness: self.assertItemsEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]]) # Test that iterator of unhashable objects can be tested for sameness: self.assertItemsEqual(iter([1, 2, [], 3, 4]), iter([1, 2, [], 3, 4])) # hashable types, but not orderable self.assertRaises(self.failureException, self.assertItemsEqual, [], [divmod, 'x', 1, 5j, 2j, frozenset()]) # comparing dicts self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}]) # comparing heterogenous non-hashable sequences self.assertItemsEqual([1, 'x', divmod, []], [divmod, [], 'x', 1]) self.assertRaises(self.failureException, self.assertItemsEqual, [], [divmod, [], 'x', 1, 5j, 2j, set()]) self.assertRaises(self.failureException, self.assertItemsEqual, [[1]], [[2]]) # Same elements, but not same sequence length self.assertRaises(self.failureException, self.assertItemsEqual, [1, 1, 2], [2, 1]) self.assertRaises(self.failureException, self.assertItemsEqual, [1, 1, "2", "a", "a"], ["2", "2", True, "a"]) self.assertRaises(self.failureException, self.assertItemsEqual, [1, {'b': 2}, None, True], [{'b': 2}, True, None]) # Same elements which don't reliably compare, in # different order, see issue 10242 a = [{2,4}, {1,2}] b = a[::-1] self.assertItemsEqual(a, b) # test utility functions supporting assertItemsEqual() diffs = set(unittest.util._count_diff_all_purpose('aaabccd', 'abbbcce')) expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')} self.assertEqual(diffs, expected) diffs = unittest.util._count_diff_all_purpose([[]], []) self.assertEqual(diffs, [(1, 0, [])]) diffs = set(unittest.util._count_diff_hashable('aaabccd', 'abbbcce')) expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')} self.assertEqual(diffs, expected) def testAssertSetEqual(self): set1 = set() set2 = set() self.assertSetEqual(set1, set2) self.assertRaises(self.failureException, self.assertSetEqual, None, set2) self.assertRaises(self.failureException, self.assertSetEqual, [], set2) self.assertRaises(self.failureException, self.assertSetEqual, set1, None) self.assertRaises(self.failureException, self.assertSetEqual, set1, []) set1 = set(['a']) set2 = set() self.assertRaises(self.failureException, self.assertSetEqual, set1, set2) set1 = set(['a']) set2 = set(['a']) self.assertSetEqual(set1, set2) set1 = set(['a']) set2 = set(['a', 'b']) self.assertRaises(self.failureException, self.assertSetEqual, set1, set2) set1 = set(['a']) set2 = frozenset(['a', 'b']) self.assertRaises(self.failureException, self.assertSetEqual, set1, set2) set1 = set(['a', 'b']) set2 = frozenset(['a', 'b']) self.assertSetEqual(set1, set2) set1 = set() set2 = "foo" self.assertRaises(self.failureException, self.assertSetEqual, set1, set2) self.assertRaises(self.failureException, self.assertSetEqual, set2, set1) # make sure any string formatting is tuple-safe set1 = set([(0, 1), (2, 3)]) set2 = set([(4, 5)]) self.assertRaises(self.failureException, self.assertSetEqual, set1, set2) def testInequality(self): # Try ints self.assertGreater(2, 1) self.assertGreaterEqual(2, 1) self.assertGreaterEqual(1, 1) self.assertLess(1, 2) self.assertLessEqual(1, 2) self.assertLessEqual(1, 1) self.assertRaises(self.failureException, self.assertGreater, 1, 2) self.assertRaises(self.failureException, self.assertGreater, 1, 1) self.assertRaises(self.failureException, self.assertGreaterEqual, 1, 2) self.assertRaises(self.failureException, self.assertLess, 2, 1) self.assertRaises(self.failureException, self.assertLess, 1, 1) self.assertRaises(self.failureException, self.assertLessEqual, 2, 1) # Try Floats self.assertGreater(1.1, 1.0) self.assertGreaterEqual(1.1, 1.0) self.assertGreaterEqual(1.0, 1.0) self.assertLess(1.0, 1.1) self.assertLessEqual(1.0, 1.1) self.assertLessEqual(1.0, 1.0) self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.1) self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.0) self.assertRaises(self.failureException, self.assertGreaterEqual, 1.0, 1.1) self.assertRaises(self.failureException, self.assertLess, 1.1, 1.0) self.assertRaises(self.failureException, self.assertLess, 1.0, 1.0) self.assertRaises(self.failureException, self.assertLessEqual, 1.1, 1.0) # Try Strings self.assertGreater('bug', 'ant') self.assertGreaterEqual('bug', 'ant') self.assertGreaterEqual('ant', 'ant') self.assertLess('ant', 'bug') self.assertLessEqual('ant', 'bug') self.assertLessEqual('ant', 'ant') self.assertRaises(self.failureException, self.assertGreater, 'ant', 'bug') self.assertRaises(self.failureException, self.assertGreater, 'ant', 'ant') self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', 'bug') self.assertRaises(self.failureException, self.assertLess, 'bug', 'ant') self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant') self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant') # Try Unicode self.assertGreater(u'bug', u'ant') self.assertGreaterEqual(u'bug', u'ant') self.assertGreaterEqual(u'ant', u'ant') self.assertLess(u'ant', u'bug') self.assertLessEqual(u'ant', u'bug') self.assertLessEqual(u'ant', u'ant') self.assertRaises(self.failureException, self.assertGreater, u'ant', u'bug') self.assertRaises(self.failureException, self.assertGreater, u'ant', u'ant') self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant', u'bug') self.assertRaises(self.failureException, self.assertLess, u'bug', u'ant') self.assertRaises(self.failureException, self.assertLess, u'ant', u'ant') self.assertRaises(self.failureException, self.assertLessEqual, u'bug', u'ant') # Try Mixed String/Unicode self.assertGreater('bug', u'ant') self.assertGreater(u'bug', 'ant') self.assertGreaterEqual('bug', u'ant') self.assertGreaterEqual(u'bug', 'ant') self.assertGreaterEqual('ant', u'ant') self.assertGreaterEqual(u'ant', 'ant') self.assertLess('ant', u'bug') self.assertLess(u'ant', 'bug') self.assertLessEqual('ant', u'bug') self.assertLessEqual(u'ant', 'bug') self.assertLessEqual('ant', u'ant') self.assertLessEqual(u'ant', 'ant') self.assertRaises(self.failureException, self.assertGreater, 'ant', u'bug') self.assertRaises(self.failureException, self.assertGreater, u'ant', 'bug') self.assertRaises(self.failureException, self.assertGreater, 'ant', u'ant') self.assertRaises(self.failureException, self.assertGreater, u'ant', 'ant') self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', u'bug') self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant', 'bug') self.assertRaises(self.failureException, self.assertLess, 'bug', u'ant') self.assertRaises(self.failureException, self.assertLess, u'bug', 'ant') self.assertRaises(self.failureException, self.assertLess, 'ant', u'ant') self.assertRaises(self.failureException, self.assertLess, u'ant', 'ant') self.assertRaises(self.failureException, self.assertLessEqual, 'bug', u'ant') self.assertRaises(self.failureException, self.assertLessEqual, u'bug', 'ant') def testAssertMultiLineEqual(self): sample_text = b"""\ http://www.python.org/doc/2.3/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] """ revised_sample_text = b"""\ http://www.python.org/doc/2.4.1/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] You may provide your own implementation that does not subclass from TestCase, of course. """ sample_text_error = b"""\ - http://www.python.org/doc/2.3/lib/module-unittest.html ? ^ + http://www.python.org/doc/2.4.1/lib/module-unittest.html ? ^^^ test case - A test case is the smallest unit of testing. [...] + A test case is the smallest unit of testing. [...] You may provide your ? +++++++++++++++++++++ + own implementation that does not subclass from TestCase, of course. """ self.maxDiff = None for type_changer in (lambda x: x, lambda x: x.decode('utf8')): try: self.assertMultiLineEqual(type_changer(sample_text), type_changer(revised_sample_text)) except self.failureException, e: # need to remove the first line of the error message error = str(e).encode('utf8').split('\n', 1)[1] # assertMultiLineEqual is hooked up as the default for # unicode strings - so we can't use it for this check self.assertTrue(sample_text_error == error) def testAsertEqualSingleLine(self): sample_text = u"laden swallows fly slowly" revised_sample_text = u"unladen swallows fly quickly" sample_text_error = """\ - laden swallows fly slowly ? ^^^^ + unladen swallows fly quickly ? ++ ^^^^^ """ try: self.assertEqual(sample_text, revised_sample_text) except self.failureException as e: error = str(e).split('\n', 1)[1] self.assertTrue(sample_text_error == error) def testAssertIsNone(self): self.assertIsNone(None) self.assertRaises(self.failureException, self.assertIsNone, False) self.assertIsNotNone('DjZoPloGears on Rails') self.assertRaises(self.failureException, self.assertIsNotNone, None) def testAssertRegexpMatches(self): self.assertRegexpMatches('asdfabasdf', r'ab+') self.assertRaises(self.failureException, self.assertRegexpMatches, 'saaas', r'aaaa') def testAssertRaisesCallable(self): class ExceptionMock(Exception): pass def Stub(): raise ExceptionMock('We expect') self.assertRaises(ExceptionMock, Stub) # A tuple of exception classes is accepted self.assertRaises((ValueError, ExceptionMock), Stub) # *args and **kwargs also work self.assertRaises(ValueError, int, '19', base=8) # Failure when no exception is raised with self.assertRaises(self.failureException): self.assertRaises(ExceptionMock, lambda: 0) # Failure when another exception is raised with self.assertRaises(ExceptionMock): self.assertRaises(ValueError, Stub) def testAssertRaisesContext(self): class ExceptionMock(Exception): pass def Stub(): raise ExceptionMock('We expect') with self.assertRaises(ExceptionMock): Stub() # A tuple of exception classes is accepted with self.assertRaises((ValueError, ExceptionMock)) as cm: Stub() # The context manager exposes caught exception self.assertIsInstance(cm.exception, ExceptionMock) self.assertEqual(cm.exception.args[0], 'We expect') # *args and **kwargs also work with self.assertRaises(ValueError): int('19', base=8) # Failure when no exception is raised with self.assertRaises(self.failureException): with self.assertRaises(ExceptionMock): pass # Failure when another exception is raised with self.assertRaises(ExceptionMock): self.assertRaises(ValueError, Stub) def testAssertRaisesRegexp(self): class ExceptionMock(Exception): pass def Stub(): raise ExceptionMock('We expect') self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub) self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub) self.assertRaisesRegexp(ExceptionMock, u'expect$', Stub) def testAssertNotRaisesRegexp(self): self.assertRaisesRegexp( self.failureException, '^Exception not raised$', self.assertRaisesRegexp, Exception, re.compile('x'), lambda: None) self.assertRaisesRegexp( self.failureException, '^Exception not raised$', self.assertRaisesRegexp, Exception, 'x', lambda: None) self.assertRaisesRegexp( self.failureException, '^Exception not raised$', self.assertRaisesRegexp, Exception, u'x', lambda: None) def testAssertRaisesRegexpInvalidRegexp(self): # Issue 20145. class MyExc(Exception): pass self.assertRaises(TypeError, self.assertRaisesRegexp, MyExc, lambda: True) def testAssertRaisesRegexpMismatch(self): def Stub(): raise Exception('Unexpected') self.assertRaisesRegexp( self.failureException, r'"\^Expected\$" does not match "Unexpected"', self.assertRaisesRegexp, Exception, '^Expected$', Stub) self.assertRaisesRegexp( self.failureException, r'"\^Expected\$" does not match "Unexpected"', self.assertRaisesRegexp, Exception, u'^Expected$', Stub) self.assertRaisesRegexp( self.failureException, r'"\^Expected\$" does not match "Unexpected"', self.assertRaisesRegexp, Exception, re.compile('^Expected$'), Stub) def testAssertRaisesExcValue(self): class ExceptionMock(Exception): pass def Stub(foo): raise ExceptionMock(foo) v = "particular value" ctx = self.assertRaises(ExceptionMock) with ctx: Stub(v) e = ctx.exception self.assertIsInstance(e, ExceptionMock) self.assertEqual(e.args[0], v) def testSynonymAssertMethodNames(self): """Test undocumented method name synonyms. Please do not use these methods names in your own code. This test confirms their continued existence and functionality in order to avoid breaking existing code. """ self.assertNotEquals(3, 5) self.assertEquals(3, 3) self.assertAlmostEquals(2.0, 2.0) self.assertNotAlmostEquals(3.0, 5.0) self.assert_(True) def testPendingDeprecationMethodNames(self): """Test fail* methods pending deprecation, they will warn in 3.2. Do not use these methods. They will go away in 3.3. """ with test_support.check_warnings(): self.failIfEqual(3, 5) self.failUnlessEqual(3, 3) self.failUnlessAlmostEqual(2.0, 2.0) self.failIfAlmostEqual(3.0, 5.0) self.failUnless(True) self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam') self.failIf(False) def testDeepcopy(self): # Issue: 5660 class TestableTest(unittest.TestCase): def testNothing(self): pass test = TestableTest('testNothing') # This shouldn't blow up deepcopy(test) def testKeyboardInterrupt(self): def _raise(self=None): raise KeyboardInterrupt def nothing(self): pass class Test1(unittest.TestCase): test_something = _raise class Test2(unittest.TestCase): setUp = _raise test_something = nothing class Test3(unittest.TestCase): test_something = nothing tearDown = _raise class Test4(unittest.TestCase): def test_something(self): self.addCleanup(_raise) for klass in (Test1, Test2, Test3, Test4): with self.assertRaises(KeyboardInterrupt): klass('test_something').run() def testSystemExit(self): def _raise(self=None): raise SystemExit def nothing(self): pass class Test1(unittest.TestCase): test_something = _raise class Test2(unittest.TestCase): setUp = _raise test_something = nothing class Test3(unittest.TestCase): test_something = nothing tearDown = _raise class Test4(unittest.TestCase): def test_something(self): self.addCleanup(_raise) for klass in (Test1, Test2, Test3, Test4): result = unittest.TestResult() klass('test_something').run(result) self.assertEqual(len(result.errors), 1) self.assertEqual(result.testsRun, 1) def testPickle(self): # Issue 10326 # Can't use TestCase classes defined in Test class as # pickle does not work with inner classes test = unittest.TestCase('run') for protocol in range(pickle.HIGHEST_PROTOCOL + 1): # blew up prior to fix pickled_test = pickle.dumps(test, protocol=protocol) unpickled_test = pickle.loads(pickled_test) self.assertEqual(test, unpickled_test) if __name__ == '__main__': unittest.main() PK]lױœtest_loader.pyonu[ |fc@sZddlZddlZddlZdejfdYZedkrVejndS(iNtTest_TestLoadercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!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-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Z<d;Z=d<Z>d=Z?d>Z@d?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIRS(HcCscdtjfdY}tj|d|dg}tj}|j|j||dS(NtFoocBs#eZdZdZdZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_1tcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_2RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoo_barR(t__name__t __module__RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR(tunittesttTestCaset TestSuitet TestLoadert assertEqualtloadTestsFromTestCase(RRtteststloader((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_loadTestsFromTestCases! cCsNdtjfdY}tj}tj}|j|j||dS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs(R R R R R R(RRt empty_suiteR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromTestCase__no_matchess  cCs[dtjfdY}tj}y|j|Wntk rInX|jddS(Nt NotATestCasecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR1ssShould raise TypeError(R R R Rt TypeErrortfail(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromTestCase__TestSuite_subclass0s  cCsdtjfdY}tj}|jdj|j|j|}|j||j|j t ||dgdS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytrunTestDs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRCsR( R R R t assertFalset startswithttestMethodPrefixRtassertIsInstancet suiteClassR tlist(RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromTestCase__default_method_nameBs  cCstjd}dtjfdY}||_tj}|j|}|j||j|j|dgg}|j t ||dS(Ntmt MyTestCasecBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttestYs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"XsR#( ttypest ModuleTypeR R t testcase_1R tloadTestsFromModuleRRR R(RR!R"RRtexpected((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__TestCase_subclassVs  cCsWtjd}tj}|j|}|j||j|jt|gdS(NR!( R$R%R R R'RRR R(RR!RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromModule__no_TestCase_instancesgs  cCstjd}dtjfdY}||_tj}|j|}|j||j|j t ||jgdS(NR!R"cBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"ts( R$R%R R R&R R'RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__no_TestCase_testsrs  csdtjfdYdtffdY}tj}|j|}tjdgg}|jt||dS(NR"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"st NotAModulecseZZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,sR#(R R tobjectR R'R R R(RR,RRt reference((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromModule__not_a_modules  cstjd}dtjfdY}||_gfd}||_tj}|j|}j|tj j ||dgg|j|dt }j gdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"scs-j|tjj|||f|S(N(RR R textend(RRtpattern(tload_tests_argsR(s1/usr/lib64/python2.7/unittest/test/test_loader.pyt load_testsstuse_load_tests( R$R%R R R&R3R R'RR R tNonetFalse(RR!R"R3RR((R2Rs1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_loadTestsFromModule__load_testss   cCstjd}d}||_tj}|j|}|j|tj|j|j dt |d}|j t d|j dS(NR!cSstddS(Ns some failure(R(RRR1((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR3siis some failure(R$R%R3R R R'RR R tcountTestCasesRtassertRaisesRegexpRR!(RR!R3RRR#((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__faulty_load_testss   cCsZtj}y|jdWn)tk rH}|jt|dnX|jddS(NRsEmpty module names7TestLoader.loadTestsFromName failed to raise ValueError(R R tloadTestsFromNamet ValueErrorR tstrR(RRte((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_loadTestsFromName__empty_names  cCsRtj}y|jdWn!tk r0ntk r@nX|jddS(Ns abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R R R;R<t ImportErrorR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromName__malformed_names   cCsZtj}y|jdWn)tk rH}|jt|dnX|jddS(Nt sdasfasfasdfsNo module named sdasfasfasdfs8TestLoader.loadTestsFromName failed to raise ImportError(R R R;R@R R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__unknown_module_names  cCsZtj}y|jdWn)tk rH}|jt|dnX|jddS(Nsunittest.sdasfasfasdfs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R R;tAttributeErrorR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__unknown_attr_names  cCs]tj}y|jdtWn)tk rK}|jt|dnX|jddS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R R;RDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_unknown_name s  cCsEtj}y|jdtWntk r3nX|jddS(NRsFailed to raise AttributeError(R R R;RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_empty_name"s   cCsUtj}y|jdtWn!tk r3ntk rCnX|jddS(Ns abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R R R;R<RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromName__relative_malformed_name5s   cs|dtjfdYdtffdY}tj}|jd|}dg}|jt||dS(NR"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#Ms(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"LsR,cseZZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,PsRR#(R R R-R R;R R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_not_a_moduleKs  cCs`tjd}t|_tj}y|jd|Wntk rNnX|jddS(NR!R&sShould have raised TypeError( R$R%R-R&R R R;RR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_bad_object`s   cCstjd}dtjfdY}||_tj}|jd|}|j||j|j t ||dgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#qs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"psR&R#( R$R%R R R&R R;RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt2test_loadTestsFromName__relative_TestCase_subclassns  cCstjd}dtjfdY}tj|dg|_tj}|jd|}|j||j |j t ||dgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR#t testsuite( R$R%R R R RLR R;RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromName__relative_TestSuite~s cCstjd}dtjfdY}||_tj}|jd|}|j||j|j t ||dgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#( R$R%R R R&R R;RRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_testmethods  cCstjd}dtjfdY}||_tj}y|jd|Wn)tk r|}|jt |dnX|j ddS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError( R$R%R R R&R R;RDR R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__relative_invalid_testmethods  cstjd}tjdtjdfd}||_tj}|jd|}|j||j|j t |gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pytRcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRcstjgS(N(R R ((R&t testcase_2(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestSuitesRR( R$R%R tFunctionTestCaseRRR R;RRR R(RR!RRRR((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__callable__TestSuites  cstjd}tjdfd}||_tj}|jd|}|j||j|j t |gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRcsS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestCasesRU( R$R%R RSRUR R;RRR R(RR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__callable__TestCase_instances  csdtjfdY}tjd}tjdfd}||_tj}||_|jd|}|j ||j|j t |gdS(Nt SubTestSuitecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWsR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRcsS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRUsRU( R R R$R%RSRUR RR;RR R(RRWR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pytDtest_loadTestsFromName__callable__TestCase_instance_ProperSuiteClasss   cCsdtjfdY}tjd}dtjfdY}||_tj}||_|jd|}|j ||j|j t ||dgdS(NRWcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWsR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#( R R R$R%R R&R RR;RR R(RRWR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<test_loadTestsFromName__relative_testmethod_ProperSuiteClasss   cCsftjd}d}||_tj}y|jd|Wntk rTnX|jddS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt return_wrongsRZs6TestLoader.loadTestsFromName failed to raise TypeError(R$R%RZR R R;RR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromName__callable__wrong_types    cCsd}tjj|dtj}zO|j|}|j||j|j t |g|j |tjWd|tjkrtj|=nXdS(Nsunittest.test.dummy( tsystmodulestpopR5R R R;RRR RtassertIn(Rt module_nameRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__module_not_loaded s cCsHtj}|jg}|j||j|jt|gdS(N(R R tloadTestsFromNamesRRR R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_loadTestsFromNames__empty_name_list)s cCsKtj}|jgt}|j||j|jt|gdS(N(R R RbRRR R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt1test_loadTestsFromNames__relative_empty_name_list8s cCs]tj}y|jdgWn)tk rK}|jt|dnX|jddS(NRsEmpty module names8TestLoader.loadTestsFromNames failed to raise ValueError(R R RbR<R R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_loadTestsFromNames__empty_nameEs  cCsUtj}y|jdgWn!tk r3ntk rCnX|jddS(Ns abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R R RbR<R@R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt'test_loadTestsFromNames__malformed_nameUs   cCs]tj}y|jdgWn)tk rK}|jt|dnX|jddS(NRBsNo module named sdasfasfasdfs9TestLoader.loadTestsFromNames failed to raise ImportError(R R RbR@R R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__unknown_module_namehs  cCs`tj}y|jddgWn)tk rN}|jt|dnX|jddS(Nsunittest.sdasfasfasdfR s/'module' object has no attribute 'sdasfasfasdf's<TestLoader.loadTestsFromNames failed to raise AttributeError(R R RbRDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__unknown_attr_namexs  cCs`tj}y|jdgtWn)tk rN}|jt|dnX|jddS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R RbRDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_1s  cCsctj}y|jddgtWn)tk rQ}|jt|dnX|jddS(NR RBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R R RbRDR R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_2s  cCsHtj}y|jdgtWntk r6nX|jddS(NRsFailed to raise ValueError(R R RbRDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_empty_names   cCsXtj}y|jdgtWn!tk r6ntk rFnX|jddS(Ns abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R R RbRDR<R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__relative_malformed_names   csdtjfdYdtffdY}tj}|jdg|}tjdgg}|jt||dS(NR"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR,cseZZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,sRR#(R R R-R RbR R R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromNames__relative_not_a_modules  cCsctjd}t|_tj}y|jdg|Wntk rQnX|jddS(NR!R&sShould have raised TypeError( R$R%R-R&R R RbRR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_bad_objects   cCstjd}dtjfdY}||_tj}|jdg|}|j||j|j|dg}|j t ||gdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR&R#( R$R%R R R&R RbRRR R(RR!R"RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromNames__relative_TestCase_subclasss  cCstjd}dtjfdY}tj|dg|_tj}|jdg|}|j||j |j t ||jgdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR#RL( R$R%R R R RLR RbRRR R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromNames__relative_TestSuite s cCstjd}dtjfdY}||_tj}|jdg|}|j||jtj |dg}|j t ||gdS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#( R$R%R R R&R RbRRR R R(RR!R"RRt ref_suite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_testmethods  cCstjd}dtjfdY}||_tj}y|jdg|Wn)tk r}|jt |dnX|j ddS(NR!R"cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#1s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"0sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError( R$R%R R R&R RbRDR R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__relative_invalid_testmethod.s  cstjd}tjdtjdfd}||_tj}|jdg|}|j||jtj g}|j t ||gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPARcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPBRcstjgS(N(R R ((R&RQ(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRCsRR( R$R%R RSRRR RbRRR R R(RR!RRRRR(((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__callable__TestSuite?s  cstjd}tjdfd}||_tj}|jdg|}|j||jtj g}|j t ||gdS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRRcsS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRUSsRU( R$R%R RSRUR RbRRR R R(RR!RURRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__TestCase_instancePs  cstjd}dtjfdY}|ddtjffdY}||_tj}|jdg|}|j||jtj g}|j t ||gdS(NR!tTest1cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#es(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRvdsR#RcseZefdZRS(csS(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoojs(RRt staticmethodRw((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRissFoo.foo( R$R%R R RR RbRRR R R(RR!RvRRRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__call_staticmethodbs   cCsitjd}d}||_tj}y|jdg|Wntk rWnX|jddS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRZ|sRZs7TestLoader.loadTestsFromNames failed to raise TypeError(R$R%RZR R RbRR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromNames__callable__wrong_typezs    cCsd}tjj|dtj}z[|j|g}|j||j|j t |tj g|j |tjWd|tjkrtj|=nXdS(Nsunittest.test.dummy( R\R]R^R5R R RbRRR RR R_(RR`RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__module_not_loadeds cCsHdtjfdY}tj}|j|j|ddgdS(NtTestcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoobarR(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|s  RR(R R R R tgetTestCaseNames(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNamess cCsBdtjfdY}tj}|j|j|gdS(NR|cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}R(RRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|s(R R R R R~(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNames__no_testss cCsHdtfdY}tj}|j|}|j|dgdS(NtBadCasecBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_foos(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRsR(tintR R R~R (RRRtnames((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt%test_getTestCaseNames__not_a_TestCases cCsgdtjfdY}d|fdY}tj}dddg}|j|j||dS(NtTestPcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}R(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  tTestCcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_3R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RRR(R R R R R~(RRRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_getTestCaseNames__inheritances  cCsdtjfdY}tj|dg}tj|d|dg}tj}d|_|j|j||d|_|j|j||dS(NRcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RRRRwR#(R R R R RR R(RRttests_1ttests_2R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_testMethodPrefix__loadTestsFromTestCases!   cCstjd}dtjfdY}||_tj|dgg}tj|d|dgg}tj}d|_|jt |j ||d|_|jt |j ||dS( NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RRRRwR#( R$R%R R RR R RR RR'(RR!RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_testMethodPrefix__loadTestsFromModules $   cCstjd}dtjfdY}||_tj|dg}tj|d|dg}tj}d|_|j|j d||d|_|j|j d||dS( NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RRRRwR#( R$R%R R RR R RR R;(RR!RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_testMethodPrefix__loadTestsFromNames !   cCstjd}dtjfdY}||_tjtj|dgg}tj|d|dg}tj|g}tj}d|_|j|j dg||d|_|j|j dg||dS( NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR5RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR6RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR7R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR4s  RRRRwR#( R$R%R R RR R RR Rb(RR!RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_testMethodPrefix__loadTestsFromNames2s $!   cCs&tj}|j|jdkdS(NR#(R R t assertTrueR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_testMethodPrefix__default_valueFs cCsud}dtjfdY}tj}||_|j|d|dg}|j|j||dS(NcSst|| S(N(tcmp(txty((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt reversed_cmpSsRcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRXR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRVs RR(R R R tsortTestMethodsUsingRR R(RRRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_sortTestMethodsUsing__loadTestsFromTestCaseRs    !cCsd}tjd}dtjfdY}||_tj}||_|j|d|dgg}|jt |j ||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRcsR!RcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRhRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRiR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRgs RR( R$R%R R RR RRR RR'(RRR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_sortTestMethodsUsing__loadTestsFromModulebs    $cCsd}tjd}dtjfdY}||_tj}||_|j|d|dg}|j|j d||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRusR!RcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRzRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR{R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRys RR( R$R%R R RR RRR R;(RRR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_sortTestMethodsUsing__loadTestsFromNamets    !cCsd}tjd}dtjfdY}||_tj}||_|j|d|dgg}|jt |j dg||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRsR!RcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RR( R$R%R R RR RRR RRb(RRR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_sortTestMethodsUsing__loadTestsFromNamess    $cCs`d}dtjfdY}tj}||_ddg}|j|j||dS(NcSst|| S(N(R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRsRcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RR(R R R RR R~(RRRRt test_names((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_sortTestMethodsUsing__getTestCaseNamess     cCs&tj}|j|jtkdS(N(R R RRR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_sortTestMethodsUsing__default_values cCscdtjfdY}tj}d|_ddg}|jt|j|t|dS(NRcBseZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs RR(R R R R5RR tsetR~(RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_sortTestMethodsUsing__Nones    cCscdtjfdY}|d|dg}tj}t|_|j|j||dS(NRcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR(R R R RRR R(RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_suiteClass__loadTestsFromTestCases   cCs~tjd}dtjfdY}||_|d|dgg}tj}t|_|j|j ||dS(NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR( R$R%R R RR RRR R'(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_suiteClass__loadTestsFromModules   cCs~tjd}dtjfdY}||_|d|dg}tj}t|_|j|j d||dS(NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR( R$R%R R RR RRR R;(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_suiteClass__loadTestsFromNames   cCstjd}dtjfdY}||_|d|dgg}tj}t|_|j|j dg||dS(NR!RcBs#eZdZdZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRR(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs  RR( R$R%R R RR RRR Rb(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_suiteClass__loadTestsFromNamess   cCs&tj}|j|jtjdS(N(R R tassertIsRR (RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_suiteClass__default_values cCstjd}dtjfdY}||_tj}|jdg|}|j||jtj |dg}|j t ||gdS(NR!R"cBseZdZRS(cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP R(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR" sstestcase_1.testR#( R$R%R R R&R RbRRR R R(RR!R"RRRq((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt@test_loadTestsFromName__function_with_different_name_than_methods  (JRRRRRR R)R*R+R/R7R:R?RARCRERFRGRHRIRJRKRMRNRORTRVRXRYR[RaRcRdReRfRgRhRiRjRkRlRmRnRoRpRrRsRtRuRyRzR{RRRRRRRRRRRRRRRRRRRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs                                                                   t__main__(R\R$R R RRtmain(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyts    PK]D dummy.pycnu[ {fc@sdS(N((((s+/usr/lib64/python2.7/unittest/test/dummy.pyttPK]%v tt support.pycnu[ {fc@skddlZdefdYZdefdYZdejfdYZdefd YZdS( iNt TestHashingcBseZdZdZRS(sUsed as a mixin for TestCasecCs*x|jD]\}}y6t|t|ksK|jd||fnWq tk rbq tk r}|jd|||fq Xq Wx|jD]\}}y6t|t|kr|jd||fnWqtk rqtk r!}|jd|||fqXqWdS(Ns%r and %r do not hash equalsProblem hashing %r and %r: %ss#%s and %s hash equal, but shouldn'tsProblem hashing %s and %s: %s(teq_pairsthashtfailtKeyboardInterruptt Exceptiontne_pairs(tselftobj_1tobj_2te((s-/usr/lib64/python2.7/unittest/test/support.pyt test_hashs" "  (t__name__t __module__t__doc__R (((s-/usr/lib64/python2.7/unittest/test/support.pyRst TestEqualitycBs eZdZdZdZRS(sUsed as a mixin for TestCasecCs>x7|jD],\}}|j|||j||q WdS(N(Rt assertEqual(RRR ((s-/usr/lib64/python2.7/unittest/test/support.pyttest_eq!scCs>x7|jD],\}}|j|||j||q WdS(N(RtassertNotEqual(RRR ((s-/usr/lib64/python2.7/unittest/test/support.pyttest_ne's(R R RRR(((s-/usr/lib64/python2.7/unittest/test/support.pyRs t LoggingResultcBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( cCs ||_tt|jdS(N(t_eventstsuperRt__init__(Rtlog((s-/usr/lib64/python2.7/unittest/test/support.pyR.s cCs*|jjdtt|j|dS(Nt startTest(RtappendRRR(Rttest((s-/usr/lib64/python2.7/unittest/test/support.pyR2scCs'|jjdtt|jdS(Nt startTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR6scCs*|jjdtt|j|dS(NtstopTest(RRRRR(RR((s-/usr/lib64/python2.7/unittest/test/support.pyR:scCs'|jjdtt|jdS(Nt stopTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR>scGs*|jjdtt|j|dS(Nt addFailure(RRRRR(Rtargs((s-/usr/lib64/python2.7/unittest/test/support.pyRBscGs*|jjdtt|j|dS(Nt addSuccess(RRRRR!(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR!FscGs*|jjdtt|j|dS(NtaddError(RRRRR"(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR"JscGs*|jjdtt|j|dS(NtaddSkip(RRRRR#(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR#NscGs*|jjdtt|j|dS(NtaddExpectedFailure(RRRRR$(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR$RscGs*|jjdtt|j|dS(NtaddUnexpectedSuccess(RRRRR%(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR%Vs( R R RRRRRRR!R"R#R$R%(((s-/usr/lib64/python2.7/unittest/test/support.pyR-s          t#ResultWithNoStartTestRunStopTestRuncBsMeZdZdZdZdZdZdZdZdZ RS(s?An object honouring TestResult before startTestRun/stopTestRun.cCsCg|_g|_d|_g|_g|_g|_t|_dS(Ni(tfailuresterrorsttestsRuntskippedtexpectedFailurestunexpectedSuccessestFalset shouldStop(R((s-/usr/lib64/python2.7/unittest/test/support.pyR^s      cCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRgscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRjscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR"mscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRpscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR!sscCstS(N(tTrue(R((s-/usr/lib64/python2.7/unittest/test/support.pyt wasSuccessfulvs( R R RRRRR"RR!R0(((s-/usr/lib64/python2.7/unittest/test/support.pyR&[s     (tunittesttobjectRRt TestResultRR&(((s-/usr/lib64/python2.7/unittest/test/support.pyts .PK]aDϗSStest_result.pycnu[ |fc@s>ddlZddlZddlmZddlmZddlZddlZdejfdYZe ej j Z x!dddd fD] Z e e =qWeeed Zee d R(RR<R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestStackFrameTrimmings  cCstj}d|_t|_|jdd|j|jtj}d|_t|_|j dd|j|jtj}d|_t|_|j d|j|jdS(NcWsdS(Nt((t_((s1/usr/lib64/python2.7/unittest/test/test_result.pytRCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERC( RRt_exc_info_to_stringRtfailfastR4R7RR R*taddUnexpectedSuccess(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt testFailFasts          cs;tjdtdt}fd}|j|dS(NtstreamRGcsj|jdS(N(RRG(R(R(s1/usr/lib64/python2.7/unittest/test/test_result.pyR%s(RtTextTestRunnerRRtrun(RtrunnerR((Rs1/usr/lib64/python2.7/unittest/test/test_result.pyttestFailFastSetByRunner#s(RRRRRR R#R%R2R5R9RtskipIfR(tflagstoptimizeR:R;RBRIRN(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR s      ' 0    taddSkiptaddExpectedFailureRHt__init__cCs1g|_g|_d|_t|_t|_dS(Ni(R R R R R tbuffer(RRJt descriptionst verbosity((s1/usr/lib64/python2.7/unittest/test/test_result.pyRT/s     t OldResulttTest_OldTestResultcBs5eZdZdZdZdZdZRS(cCsOtjdtf4t}|j||jt|j|WdQXdS(NsTestResult has no add.+ method,(Rtcheck_warningstRuntimeWarningRXRLRRR (RRR R((s1/usr/lib64/python2.7/unittest/test/test_result.pytassertOldResultWarning;s     cCsrdtjfdY}xRdtfdtfdtffD]/\}}||}|j|t| q;WdS(NtTestcBs5eZdZejdZejdZRS(cSs|jddS(Ntfoobar(tskipTest(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestSkipDscSs tdS(N(R3(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestExpectedFailFscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestUnexpectedSuccessIs(RRR`RtexpectedFailureRaRb(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Cs R`RaRb(RRRR R\tint(RR]t test_namet should_passR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultBs    cCs3dtjfdY}|j|dddS(NR]cBseZdZdZRS(cSs|jddS(Ns no reason(R_(R((s1/usr/lib64/python2.7/unittest/test/test_result.pytsetUpUscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestFooWs(RRRhRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Ts Rii(RRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestTesultSetupSscCsBtjddtjfdY}|j|dddS(Ns no reasonR]cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRi^s(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]\sRii(RtskipRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultClass[scCsKdtjfdY}tjdtdt}|j|ddS(NR]cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRids(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]cst resultclassRJRi(RRRKRXRRL(RR]RM((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldResultWithRunnerbs (RRR\RgRjRlRn(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRY9s     t MockTracebackcBseZedZRS(cGsdgS(Ns A traceback((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pytformat_exceptionns(RRt staticmethodRp(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRomscCsttj_dS(N(t tracebackRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pytrestore_tracebackrstTestOutputBufferingcBsbeZdZdZdZdZdZdZdZdZ dZ d Z RS( cCstj|_tj|_dS(N(R(tstdoutt _real_outtstderrt _real_err(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRhxs cCs|jt_|jt_dS(N(RvR(RuRxRw(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDown|s cCs|j}|j}tj}|j|j|j|tj|j|tj |j ||j|tj|j|tj dS(N( RvRxRRR+RUR,R(RuRwR(Rtreal_outtreal_errR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferOutputOffs    cCs|j}|j}tj}|j|jt|_|j|tj |j|tj |j ||j |tj |j |tj |j tj t|j tj t|j tj tj tj }tj }t|_t|_dGHtj dIJ|j|jd|j|jd|j|jjd|j|jjd|j||j||jtj |j|jtj |j|j|jjd|j|jjd|j|jd|j|jddS(NR&tbarsfoo sbar RC(RvRxRRR+RURR,R(RuRwRt assertIsNotR-Rt_original_stdoutt_original_stderrRtgetvalueR$R(RRzR{Rt out_streamt err_stream((s1/usr/lib64/python2.7/unittest/test/test_result.pyt#testBufferOutputStartTestAddSuccesss>            cCs&tj}t|_|j||S(N(RRRRUR(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pytgetStartedResults   cCsttj_|jtxddtfddtfddtfddtfgD]U\}}}|j}t j }t j }t |_ t |_t j dIJ|rt j dIJnt||}||d |j|t||}|jt|d|d\} } tjd } d } |rCtjd } nd | | f} |j| ||j|j j| |j|jj| |j| | qPWdS(NR R4R R*R&R}iis9 Stdout: foo RCs9 Stderr: bar sA traceback%s%s(NNN(RoRRRrt addCleanupRsRR RR(RuRwRRRtgetattrR7RRRttextwraptdedentR,RtassertMultiLineEqual(Rt message_attrtadd_attrt include_errorRt buffered_outt buffered_errt addFunctiont result_listRtmessagetexpectedOutMessagetexpectedErrMessagetexpectedFullMessage((s1/usr/lib64/python2.7/unittest/test/test_result.pyt!testBufferOutputAddErrorOrFailures@               cCsmtj}t|_dtjfdY}tj|dg}|||jt|jddS(NRcBs eZedZdZRS(cSs dddS(Nii((tcls((s1/usr/lib64/python2.7/unittest/test/test_result.pyt setUpClassscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_foos(RRt classmethodRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsRi( RRRRURt TestSuiteRRR (RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetupClasss    cCsmtj}t|_dtjfdY}tj|dg}|||jt|jddS(NRcBs eZedZdZRS(cSs dddS(Nii((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyt tearDownClassscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR s(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsRi( RRRRURRRRR (RRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownClasss    cCstj}t|_dtjfdY}dtfdY}d|_|tjd<|j tjj dtj |dg}|||j t |jddS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRstModulecBseZedZRS(cSs dddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pyt setUpModules(RRRqR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsRi(RRRRURR?RR(tmodulesRtpopRRRR (RRRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetUpModules     cCstj}t|_dtjfdY}dtfdY}d|_|tjd<|j tjj dtj |dg}|||j t |jddS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR's(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR&sRcBseZedZRS(cSs dddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDownModule*s(RRRqR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR)sRi(RRRRURR?RR(RRRRRRR (RRRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownModule"s     ( RRRhRyR|RRRRRRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRtvs    0  .   t__main__(R(RRRRRrRRRtdictRt__dict__t classDicttmR7RTttypeR?RXRYRoRsRtRtmain(((s1/usr/lib64/python2.7/unittest/test/test_result.pyts(    !    4  PK]aDϗSStest_result.pyonu[ |fc@s>ddlZddlZddlmZddlmZddlZddlZdejfdYZe ej j Z x!dddd fD] Z e e =qWeeed Zee d R(RR<R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestStackFrameTrimmings  cCstj}d|_t|_|jdd|j|jtj}d|_t|_|j dd|j|jtj}d|_t|_|j d|j|jdS(NcWsdS(Nt((t_((s1/usr/lib64/python2.7/unittest/test/test_result.pytRCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERC( RRt_exc_info_to_stringRtfailfastR4R7RR R*taddUnexpectedSuccess(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt testFailFasts          cs;tjdtdt}fd}|j|dS(NtstreamRGcsj|jdS(N(RRG(R(R(s1/usr/lib64/python2.7/unittest/test/test_result.pyR%s(RtTextTestRunnerRRtrun(RtrunnerR((Rs1/usr/lib64/python2.7/unittest/test/test_result.pyttestFailFastSetByRunner#s(RRRRRR R#R%R2R5R9RtskipIfR(tflagstoptimizeR:R;RBRIRN(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR s      ' 0    taddSkiptaddExpectedFailureRHt__init__cCs1g|_g|_d|_t|_t|_dS(Ni(R R R R R tbuffer(RRJt descriptionst verbosity((s1/usr/lib64/python2.7/unittest/test/test_result.pyRT/s     t OldResulttTest_OldTestResultcBs5eZdZdZdZdZdZRS(cCsOtjdtf4t}|j||jt|j|WdQXdS(NsTestResult has no add.+ method,(Rtcheck_warningstRuntimeWarningRXRLRRR (RRR R((s1/usr/lib64/python2.7/unittest/test/test_result.pytassertOldResultWarning;s     cCsrdtjfdY}xRdtfdtfdtffD]/\}}||}|j|t| q;WdS(NtTestcBs5eZdZejdZejdZRS(cSs|jddS(Ntfoobar(tskipTest(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestSkipDscSs tdS(N(R3(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestExpectedFailFscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestUnexpectedSuccessIs(RRR`RtexpectedFailureRaRb(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Cs R`RaRb(RRRR R\tint(RR]t test_namet should_passR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultBs    cCs3dtjfdY}|j|dddS(NR]cBseZdZdZRS(cSs|jddS(Ns no reason(R_(R((s1/usr/lib64/python2.7/unittest/test/test_result.pytsetUpUscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestFooWs(RRRhRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Ts Rii(RRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestTesultSetupSscCsBtjddtjfdY}|j|dddS(Ns no reasonR]cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRi^s(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]\sRii(RtskipRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultClass[scCsKdtjfdY}tjdtdt}|j|ddS(NR]cBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRids(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]cst resultclassRJRi(RRRKRXRRL(RR]RM((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldResultWithRunnerbs (RRR\RgRjRlRn(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRY9s     t MockTracebackcBseZedZRS(cGsdgS(Ns A traceback((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pytformat_exceptionns(RRt staticmethodRp(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRomscCsttj_dS(N(t tracebackRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pytrestore_tracebackrstTestOutputBufferingcBsbeZdZdZdZdZdZdZdZdZ dZ d Z RS( cCstj|_tj|_dS(N(R(tstdoutt _real_outtstderrt _real_err(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRhxs cCs|jt_|jt_dS(N(RvR(RuRxRw(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDown|s cCs|j}|j}tj}|j|j|j|tj|j|tj |j ||j|tj|j|tj dS(N( RvRxRRR+RUR,R(RuRwR(Rtreal_outtreal_errR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferOutputOffs    cCs|j}|j}tj}|j|jt|_|j|tj |j|tj |j ||j |tj |j |tj |j tj t|j tj t|j tj tj tj }tj }t|_t|_dGHtj dIJ|j|jd|j|jd|j|jjd|j|jjd|j||j||jtj |j|jtj |j|j|jjd|j|jjd|j|jd|j|jddS(NR&tbarsfoo sbar RC(RvRxRRR+RURR,R(RuRwRt assertIsNotR-Rt_original_stdoutt_original_stderrRtgetvalueR$R(RRzR{Rt out_streamt err_stream((s1/usr/lib64/python2.7/unittest/test/test_result.pyt#testBufferOutputStartTestAddSuccesss>            cCs&tj}t|_|j||S(N(RRRRUR(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pytgetStartedResults   cCsttj_|jtxddtfddtfddtfddtfgD]U\}}}|j}t j }t j }t |_ t |_t j dIJ|rt j dIJnt||}||d |j|t||}|jt|d|d\} } tjd } d } |rCtjd } nd | | f} |j| ||j|j j| |j|jj| |j| | qPWdS(NR R4R R*R&R}iis9 Stdout: foo RCs9 Stderr: bar sA traceback%s%s(NNN(RoRRRrt addCleanupRsRR RR(RuRwRRRtgetattrR7RRRttextwraptdedentR,RtassertMultiLineEqual(Rt message_attrtadd_attrt include_errorRt buffered_outt buffered_errt addFunctiont result_listRtmessagetexpectedOutMessagetexpectedErrMessagetexpectedFullMessage((s1/usr/lib64/python2.7/unittest/test/test_result.pyt!testBufferOutputAddErrorOrFailures@               cCsmtj}t|_dtjfdY}tj|dg}|||jt|jddS(NRcBs eZedZdZRS(cSs dddS(Nii((tcls((s1/usr/lib64/python2.7/unittest/test/test_result.pyt setUpClassscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_foos(RRt classmethodRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsRi( RRRRURt TestSuiteRRR (RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetupClasss    cCsmtj}t|_dtjfdY}tj|dg}|||jt|jddS(NRcBs eZedZdZRS(cSs dddS(Nii((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyt tearDownClassscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR s(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsRi( RRRRURRRRR (RRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownClasss    cCstj}t|_dtjfdY}dtfdY}d|_|tjd<|j tjj dtj |dg}|||j t |jddS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRstModulecBseZedZRS(cSs dddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pyt setUpModules(RRRqR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsRi(RRRRURR?RR(tmodulesRtpopRRRR (RRRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetUpModules     cCstj}t|_dtjfdY}dtfdY}d|_|tjd<|j tjj dtj |dg}|||j t |jddS(NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR's(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR&sRcBseZedZRS(cSs dddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDownModule*s(RRRqR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR)sRi(RRRRURR?RR(RRRRRRR (RRRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownModule"s     ( RRRhRyR|RRRRRRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRtvs    0  .   t__main__(R(RRRRRrRRRtdictRt__dict__t classDicttmR7RTttypeR?RXRYRoRsRtRtmain(((s1/usr/lib64/python2.7/unittest/test/test_result.pyts(    !    4  PK]4-7-7test_runner.pyonu[ |fc@sddlZddlmZddlZddlmZmZdejfdYZdejfdYZ e dkrej ndS( iN(tStringIO(t LoggingResultt#ResultWithNoStartTestRunStopTestRunt TestCleanUpcBs,eZdZdZdZdZRS(c sdtjfdY}|d}|j|jggfd}fd}|j|dddd d d d |j||j|j|d td d d d f|difg|j}|j||jddifddtd d d d fgdS(Nt TestableTestcBseZdZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt testNothings(t__name__t __module__R(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR sRcsjd||fdS(Ni(tappend(targstkwargs(tcleanups(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup1scsjd||fdS(Ni(R (R R (R (s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup2siiitfourthellotfivetgoodbye(iii(((iii(tunittesttTestCaset assertEqualt _cleanupst addCleanuptdictt doCleanupst assertTrue(RRttestR Rtresult((R s1/usr/lib64/python2.7/unittest/test/test_runner.pyt testCleanUp s "    cs+dtjfdY}dtfdY}|}|d}||_tdtdfd}fd }|j||j||j|jt|j \\}\}} } \} \} } } |j ||| f|tf|j | | | f|tfdS( NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR+s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR*st MockResultcBseZgZdZRS(cSs|jj||fdS(N(terrorsR (RRtexc_info((s1/usr/lib64/python2.7/unittest/test/test_runner.pytaddError0s(RRRR!(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR.sRtfootbarcs dS(N(((texc1(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR 9scs dS(N(((texc2(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR<s( RRtobjectt_resultForDoCleanupst ExceptionRt assertFalseRtreversedRR(RRRRRR Rttest1tType1t instance1t_ttest2tType2t instance2((R$R%s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanUpWithErrors)s       3"cstgdtjffdY}|dfd}fd}j|j|fd}tj}||_j|jddd d d d gtg|dj|j|jdd gdS( NRcs8eZfdZfdZfdZRS(cs&jdr"tdndS(NtsetUpR"(R R((R(tblowUptordering(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3Ms csjddS(NR(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRscsjddS(NttearDown(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6Us(RRR3RR6((R4R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRLsRcsjddS(NR (R ((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR ZscsjddS(NR(R ((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR\scs!j|jddS(Ntsuccess(RR (t some_test(R5RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR7asR3RR6RR R7( tFalseRRRt TestResultt addSuccesstrunRtTrue(RRR RR7R((R4R5RRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanupInRunHs("         csgdtjffdY}|dfdfdj|jdddd d gdS( NRcs8eZfdZfdZfdZRS(csjd|jdS(NR3(R R(R(R R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3ws csjddS(NR(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR{scsjddS(NR6(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6~s(RRR3RR6((R R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRvsRcsjdjdS(NR (R R((RR5R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR s csjddS(NR(R ((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRsR3RR6R R(RRtdebugR(RR((R RR5Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyt!testTestCaseDebugExecutesCleanupsss"  (RRRR2R>R@(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR s   +tTest_TextTestRunnercBsVeZdZdZdZdZdZdZdZdZ dZ RS( sTests for TextTestRunner.cCsitj}|j|j|j|j|j|jd|j|j|j|j tj dS(Ni( RtTextTestRunnerR)tfailfasttbufferRt verbosityRt descriptionst resultclasstTextTestResult(Rtrunner((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt test_inits  csOdtjffdYdtjfdY}|ddddS(NtAResultcseZfdZRS(cs t|j|||dS(N(tsupert__init__(RtstreamRFRE(RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRMs(RRRM((RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRKst ATextResultcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyROsi(RR:RHtNone(RRO((RKs1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_multiple_inheritancescsdtjfdY}tjtjdtdtdt}fd|_|j|d|jj |jj dS(NtTestcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestFoos(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRsRNRCRDcsS(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyttRS( RRR:RBRR=t _makeResultR<RRCRD(RRRRI((Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestBufferAndFailfasts  csdtjfdY}tjjfd}j|tjtjdt}fd|_d_ fd}|tj_|j tj j j ddS( NRRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRSs(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRscstj_dS(N(RRItregisterResult((toriginalRegisterResult(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanupsRNcsS(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRTRUics#jd7_j|dS(Ni(t wasRegisteredR(t thisResult(RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pytfakeRegisterResultsi( RRRIRXRR:RBRRVR[R<t TestSuiteR(RRRRZRIR]((RYRRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestRunnerRegistersResults     csXdtfdYdtjffdY}|jtjdS(Nt OldTextResultcBseZdZdZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt printErrorss(RRt separator2Ra(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR`stRunnercs&eZfdZfdZRS(cst|jtdS(N(RLRMR(R(Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRMscsS(N((R(R`(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRVs(RRRMRV((R`Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRcs(RRRBR<R^(RRI((R`Rcs1/usr/lib64/python2.7/unittest/test/test_runner.pyt7test_works_with_result_without_startTestRun_stopTestRuns" cs}dtfdYdtjffdYg}|}|jtjddg}|j||dS(NtLoggingTextResultcBseZdZdZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRas(RRRbRa(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRest LoggingRunnercs&eZfdZfdZRS(cs&t|jt||_dS(N(RLRMRt_events(Rtevents(Rf(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRMscs |jS(N(Rg(R(Re(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRVs(RRRMRV((RfRe(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRfst startTestRunt stopTestRun(RRRBR<R^R(RRhRItexpected((RfRes1/usr/lib64/python2.7/unittest/test/test_runner.pyt$test_startTestRun_stopTestRun_calleds"  cCsddlm}|d}tj|}x^ttjdD]I}tj|d|}tj|}|j|j j |j q?WdS(Ni(RR"itprotocol( RRRBtrangetpickletHIGHEST_PROTOCOLtdumpstloadsRRNtgetvalue(Rt PickleableIORNRIRmtstobj((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_pickle_unpickles cCs~d}t}t}t}tj|||d|}|j|j||j||f}|j|j|dS(NcWs|S(N((R ((s1/usr/lib64/python2.7/unittest/test/test_runner.pytMockResultClasssRG(R&RRBRRGRNRV(RRxtSTREAMt DESCRIPTIONSt VERBOSITYRItexpectedresult((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_resultclasss     ( RRt__doc__RJRQRWR_RdRlRwR}(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRAs     t__main__( Rt cStringIORRotunittest.test.supportRRRRRARtmain(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyts  } PK]L test_case.pyonu[ {fc@sddlZddlZddlZddlZddlZddlmZddlmZddl Z ddl m Z m Z m Z mZdefdYZde je e fdYZed kre jndS( iN(tdeepcopy(t test_support(t TestEqualityt TestHashingt LoggingResultt#ResultWithNoStartTestRunStopTestRuntTestcBsVeZdZdejfdYZdefdYZdejfdYZRS(s5Keep these TestCase classes out of the main namespacetFoocBseZdZdZRS(cCsdS(N((tself((s//usr/lib64/python2.7/unittest/test/test_case.pytrunTesttcCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest1R (t__name__t __module__R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRs tBarcBseZdZRS(cCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest2R (R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRstLoggingTestCasecBs2eZdZdZdZdZdZRS(s!A test case which logs its calls.cCs&ttj|jd||_dS(Nttest(tsuperRRt__init__tevents(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyRscCs|jjddS(NtsetUp(Rtappend(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR"scCs|jjddS(NR(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%scCs|jjddS(NttearDown(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR(s(R R t__doc__RRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs    (R R RtunittesttTestCaseRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRst Test_TestCasecBseZejdejdfgZejdejdfejdejdfejdejdfgZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZejej j!dkddZ"ejej j!dkddZ#dZ$dZ%dZ&d Z'd!Z(d"Z)d#Z*d$Z+d%Z,d&Z-d'Z.d(Z/d)Z0d*Z1d+Z2d,Z3d-Z4d.Z5d/Z6d0Z7d1Z8d2Z9d3Z:d4Z;d5Z<d6Z=d7Z>d8Z?d9Z@d:ZAd;ZBd<ZCd=ZDd>ZERS(?R R RcCs:dtjfdY}|j|jdddS(NRcBseZdZdZRS(cSs tdS(N(t TypeError(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR HR cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRIR (R R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRGs is .Test.runTest(RRt assertEqualtid(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__no_test_nameFscCs=dtjfdY}|j|djdddS(NRcBseZdZdZRS(cSs tdS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR SR cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRTR (R R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRRs Ris .Test.test(RRRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__validQscCsLdtjfdY}y|dWntk r:nX|jddS(NRcBseZdZdZRS(cSs tdS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR ^R cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR_R (R R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR]s ttestfoosFailed to raise ValueError(RRt ValueErrortfail(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__invalid\s  cCs9dtjfdY}|j|djddS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRlR (R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRksRi(RRRtcountTestCases(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_countTestCasesjscCsEdtjfdY}|j}|jt|tjdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR vs(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRus(RRtdefaultTestResultRttypet TestResult(RRtresult((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_defaultTestResulttscsjg}t|}dtjffdY|j|ddddg}|j||dS(NRcseZfdZRS(cs#t|jtddS(Nsraised by Foo.setUp(RRt RuntimeError(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRst startTestRtaddErrortstopTest(RRRtrunR(RRR*texpected((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt#test_run_call_order__error_in_setUps  csag}dtjffdY|jddddddg}|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t|jtddS(Nsraised by Foo.setUp(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs t startTestRunR-RR.R/t stopTestRun(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt2test_run_call_order__error_in_setUp_default_results   cspg}t|}dtjffdYddddddg}|j||j||dS( NRcseZfdZRS(cs#t|jtddS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsR-RRR.RR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order__error_in_tests  csgg}dtjffdYddddddd d g}|j|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t|jtddS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs R3R-RRR.RR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt1test_run_call_order__error_in_test_default_results cspg}t|}dtjffdYddddddg}|j||j||dS( NRcseZfdZRS(cs$t|j|jddS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsR-RRt addFailureRR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt$test_run_call_order__failure_in_tests  csgdtjffdYddddddd d g}g}|j|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs$t|j|jddS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs R3R-RRR8RR/R4(RRR0R(RR1R((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt3test_run_call_order__failure_in_test_default_results cspg}t|}dtjffdY|j|ddddddg}|j||dS( NRcseZfdZRS(cs#t|jtddS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsR-RRRR.R/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt&test_run_call_order__error_in_tearDowns  csgdtjffdYg}|jddddddd d g}|j||dS( NRcs eZdZfdZRS(cSs t|jS(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t|jtddS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs R3R-RRRR.R/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt5test_run_call_order__error_in_tearDown_default_results cCs-dtjfdY}|djdS(NRcBseZdZdZRS(cSstS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRs(R R R'R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs R(RRR0(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order_default_resultscCs6dtjfdY}|j|djtdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%s(R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR$sR(RRtassertIstfailureExceptiontAssertionError(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_failureException__default#scCszg}t|}dtjfdY}|j|djt|dj|dddg}|j||dS(NRcBseZdZeZRS(cSs tdS(N(R,(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR5s(R R RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyR4s RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__explicit_raise0s cCszg}t|}dtjfdY}|j|djt|dj|dddg}|j||dS(NRcBseZdZeZRS(cSs|jddS(Ntfoo(R#(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRLs(R R RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyRKs RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__implicit_raiseGs cCs*dtjfdY}|jdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR [s(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRZs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt test_setUpYscCs*dtjfdY}|jdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR ds(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRcs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt test_tearDownbscCs6dtjfdY}|j|jtdS(NRcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR rs(R R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRqs(RRtassertIsInstanceRt basestring(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_idpscsagdtjffdY}|djddddddg}|j|dS( NRcs&eZfdZfdZRS(csjddS(NR(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRscs tS(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR's(R R RR'((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR~sRR3R-t addSuccessR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt test_run__uses_defaultTestResult{s   cCs|j|jdS(N(t assertIsNonetshortDescription(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt$testShortDescriptionWithoutDocstringsis)Docstrings are omitted with -O2 and abovecCs|j|jddS(s7Tests shortDescription() for a method with a docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt(testShortDescriptionWithOneLineDocstrings cCs|j|jddS(sTests shortDescription() for a method with a longer docstring. This method ensures that only the first line of a docstring is returned used in the short description, no matter how long the whole thing is. s>Tests shortDescription() for a method with a longer docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt*testShortDescriptionWithMultiLineDocstrings  csodtfdY}}|j||dfd}|j||j||dS(NtSadSnakecBseZdZRS(s)Dummy class for test_addTypeEqualityFunc.(R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRQscs$t|t|ko!kSS(N(R((tatbtmsg(RQ(s//usr/lib64/python2.7/unittest/test/test_case.pytAllSnakesCreatedEquals(tobjecttassertNotEqualtNonetaddTypeEqualityFuncR(Rts1ts2RU((RQs//usr/lib64/python2.7/unittest/test/test_case.pyttestAddTypeEqualityFuncs cCs<t}|j|||j|j|j|tdS(N(RVR>t assertRaisesR?(Rtthing((s//usr/lib64/python2.7/unittest/test/test_case.pyt testAssertIss cCs<t}|j|t|j|j|j||dS(N(RVt assertIsNotR]R?(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNots cCs6g}|j|t|j|j|j|tdS(N(RGtlistR]R?tdict(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsInstancescCs6g}|j|t|j|j|j|tdS(N(tassertNotIsInstanceRcR]R?Rb(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotIsInstancescCsKidd6dd6dd6}|jdd|jd d d d g|jd||jd d|jd d d d g|jd||j|j|jdd|j|j|jdd d d g|j|j|jd||j|j|jdd|j|j|jd d d d g|j|j|jd|dS(NtbananatmonkeytgrasstcowtfishtsealRRtabciiitditottertxitelephanttc(tassertInt assertNotInR]R?(Rtanimals((s//usr/lib64/python2.7/unittest/test/test_case.pyt testAssertIns%%cCs&|jii|jiidd6|jidd6idd6|jidd6idd6dd6|jidd6dd6idd6dd6|j|j|jidd6iWdQX|j|j#|jidd6idd6WdQX|j|j#|jidd6idd6WdQX|j|j*|jidd6dd6idd6WdQX|j|j*|jidd6dd6idd6WdQXtjdtf[djdtd D}|j|j#|ji|d 6id d 6WdQXWdQXdS( NiRRiRStoneRrR css|]}t|VqdS(N(tchr(t.0ti((s//usr/lib64/python2.7/unittest/test/test_case.pys siRCu�(tassertDictContainsSubsetR]R?Rtcheck_warningstUnicodeWarningtjointrange(RRw((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictContainsSubsets&%,$$++cCsd d fiifggfttfttfg}x|D]\}}y|j||Wn+|jk r|jd||fnXy|j||ddWn+|jk r|jd||fnXy|j||dWqF|jk r |jd||fqFXqFWd gfitftddgtddgftdd gtdd gftd dgtd dgfg}xq|D]i\}}|j|j|j|||j|j|j||d|j|j|j||ddqWdS(NsassertEqual(%r, %r) failedRTRCs$assertEqual(%r, %r) with msg= faileds/assertEqual(%r, %r) with third parameter failediiiii((((tsett frozensetRR?R#R](Rt equal_pairsRRRSt unequal_pairs((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEquals<      !!'cCs|jgg|jdd|jgdddgg}g}|jtjj|j|||jtjj|jt|t||jtjj|j|t||j||j|||jt|t||j|t||jt|||j|j|j|t||j|j|jt|||j|j|jd||j|j|jdt||j|j|jdt||j|j|jdd|j|j|jdd|j|j|jdd|j iiidd6}i}|jtjj|j |||j ||j ||d|d<|jtjj|j ||d|j|j|j d||j|j|j g||j|j|j dddS( NiRRiRpsThese are unequal(((( tassertListEqualtassertTupleEqualtassertSequenceEqualR]RRR?ttupletextendRXtassertDictEqualtupdate(RRRRSRrRn((s//usr/lib64/python2.7/unittest/test/test_case.pyt testEqualitysT      cCs|j|jd ddd }ddd }djtjtj|jtj|j}tj j t |df}t |d|_y|j ||Wn#|j k r}|jd }nX|jd |jt |t ||j||t |d|_y|j ||Wn#|j k rW}|jd }nX|jd |jt |t ||j||d|_y|j ||Wn#|j k r}|jd }nX|jd |jt |t ||j||dS(NiPiRRRpiRSs iis!assertSequenceEqual did not fail.iii(RtmaxDiffR~tdifflibtndifftpprinttpformatt splitlinesRtcaset DIFF_OMITTEDtlenRR?targsR#t assertLessRst assertGreaterRtRX(Rtseq1tseq2tdifftomittedteRT((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSequenceEqualMaxDiffRs<    cCsd|_|jdd}tjjtd}|j|d|d|_|jdd}|j|dd|_|jdd}|j|ddS(NiRCtbartfoobari(Rt_truncateMessageRRRRRRX(RtmessageR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestTruncateMessageys   cCs|tjd}d}||_y|jiidd6Wn,|jk rj}|jt|dnX|jddS(NRcSsdS(NRC((RTR((s//usr/lib64/python2.7/unittest/test/test_case.pyttruncatesiiRCsassertDictEqual did not fail(RRRRR?RtstrR#(RRRR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictEqualTruncatess  cCsutjd}d}||_y|jddWn,|jk rc}|jt|dnX|jddS(NRcSsdS(NRC((RTR((s//usr/lib64/python2.7/unittest/test/test_case.pyRsRCRs!assertMultiLineEqual did not fail(RRRtassertMultiLineEqualR?RRR#(RRRR((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testAssertMultiLineEqualTruncatess  csjjdd_jd_jfddd}jj}j|d|dWdQXjd t|j j|d|ddd}d }j |_ jfd |d|d}}jj}j||WdQXj d t|j jt|j d ||fj|d|ddS(NiiicstdS(Nt_diffThreshold(tsetattr((t old_thresholdR(s//usr/lib64/python2.7/unittest/test/test_case.pytR uxiRRRSt^i cSstddS(Nsthis should not be raised(t SystemError(RR((s//usr/lib64/python2.7/unittest/test/test_case.pytexplodingTruncationscstdS(NR(R((t old_truncateR(s//usr/lib64/python2.7/unittest/test/test_case.pyRR s%r != %riiii( RRRXRt addCleanupR]R?RsRt exceptionRRt(RtstcmRRZR[((RRRs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEqual_diffThresholds*        #c Csyt}|jdddgdddg|jdddgdddg|j||dddg|dd|df|jddddgddtdg|j|j|jddgdgd dgd ddg|j|j|jddddgddtdg|j|j|jd gd d g|j|j|jd d gd g|j|j|jd d d gd d g|jddgdd gd gtdd gddgg|jtddgdd gtddgdd g|j|j|jgtddddtg|jidd6idd6gidd6idd6g|jddtggtgddg|j|j|jgtgddddt g|j|j|jdggdgg|j|j|jdddgddg|j|j|jdddddgddtdg|j|j|jdidd6dtgidd6tdgdd hddhg}|ddd}|j||t t j j dd}ddddh}|j||t j j ggg}|j|dd gfgt t j jdd}ddddh}|j||dS(NiiiRCRtbazt2RRidi i iiRpy@y@RSitaaabccdtabbbcceRnR(iiRR(iiRS(iiRn(iiR(iiRR(iiRS(iiRn(iiR(RVtassertItemsEqualtTrueR]R?tFalsetitertdivmodRRRXRtutilt_count_diff_all_purposeRt_count_diff_hashable(RRRRStdiffsR1((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertItemsEqualsV "".(,":8("%-cCs*t}t}|j|||j|j|jd||j|j|jg||j|j|j|d|j|j|j|gtdg}t}|j|j|j||tdg}tdg}|j||tdg}tddg}|j|j|j||tdg}tddg}|j|j|j||tddg}tddg}|j||t}d}|j|j|j|||j|j|j||td d g}td g}|j|j|j||dS( NRRRSRCiiiiii(ii(ii(ii(RtassertSetEqualR]R?RXR(Rtset1tset2((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSetEquals:    cCs4|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdd|j|j|jdddS( Niig?g?tbugtantubuguant(RtassertGreaterEqualRtassertLessEqualR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestInequality)scCsd}d}d}d|_xddfD]w}y |j||||Wq.|jk r}t|jdjddd}|j||kq.Xq.WdS( Nsxhttp://www.python.org/doc/2.3/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] shttp://www.python.org/doc/2.4.1/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] You may provide your own implementation that does not subclass from TestCase, of course. s- http://www.python.org/doc/2.3/lib/module-unittest.html ? ^ + http://www.python.org/doc/2.4.1/lib/module-unittest.html ? ^^^ test case - A test case is the smallest unit of testing. [...] + A test case is the smallest unit of testing. [...] You may provide your ? +++++++++++++++++++++ + own implementation that does not subclass from TestCase, of course. cSs|S(N((Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyRR cSs |jdS(Ntutf8(tdecode(Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyRR Rs i(RXRRR?Rtencodetsplitt assertTrue(Rt sample_texttrevised_sample_texttsample_text_errort type_changerRterror((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertMultiLineEquals  %cCsrd}d}d}y|j||WnE|jk rm}t|jddd}|j||knXdS(Nuladen swallows fly slowlyuunladen swallows fly quicklysr- laden swallows fly slowly ? ^^^^ + unladen swallows fly quickly ? ++ ^^^^^ s i(RR?RRR(RRRRRR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAsertEqualSingleLinescCsP|jd|j|j|jt|jd|j|j|jddS(NsDjZoPloGears on Rails(RLRXR]R?RtassertIsNotNone(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNones  cCs0|jdd|j|j|jdddS(Nt asdfabasdfsab+tsaaastaaaa(tassertRegexpMatchesR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRegexpMatchesscsdtfdYfd}|j||jtf||jttddd|j|j|jdWdQX|j|jt|WdQXdS(Nt ExceptionMockcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscsddS(Ns We expect(((R(s//usr/lib64/python2.7/unittest/test/test_case.pytStubst19tbaseicSsdS(Ni((((s//usr/lib64/python2.7/unittest/test/test_case.pyRR (t ExceptionR]R"tintR?(RR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesCallablesc sdtfdYfd}|j |WdQX|jtf}|WdQX|j|j|j|jjdd|jttdddWdQX|j|j|jWdQXWdQX|j|jt|WdQXdS( NRcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscsddS(Ns We expect(((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRsis We expectRRi( RR]R"RGRRRRR?(RRR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesContexts   cskdtfdYfd}|jtjd||jd||jd|dS(NRcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscsddS(Ns We expect(((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRssexpect$uexpect$(RtassertRaisesRegexptretcompile(RR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexps cCs||j|jd|jttjdd|j|jd|jtdd|j|jd|jtdddS(Ns^Exception not raised$RpcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR cSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR uxcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR (RR?RRR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotRaisesRegexps       cCs6dtfdY}|jt|j|ddS(NtMyExccBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscSstS(N(R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRR (RR]RR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt#testAssertRaisesRegexpInvalidRegexpscCs|d}|j|jd|jtd||j|jd|jtd||j|jd|jttjd|dS(NcSstddS(Nt Unexpected(R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRss*"\^Expected\$" does not match "Unexpected"s ^Expected$u ^Expected$(RR?RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexpMismatchs     csdtfdYfd}d}|j}|||WdQX|j}|j||j|jd|dS(NRcBseZRS((R R (((s//usr/lib64/python2.7/unittest/test/test_case.pyRscs|dS(N((RC(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRssparticular valuei(RR]RRGRR(RRtvtctxR((Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesExcValues cCsQ|jdd|jdd|jdd|jdd|jtdS(sTest undocumented method name synonyms. Please do not use these methods names in your own code. This test confirms their continued existence and functionality in order to avoid breaking existing code. iig@g@g@N(tassertNotEqualst assertEqualstassertAlmostEqualstassertNotAlmostEqualstassert_R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestSynonymAssertMethodNames(s cCstjr|jdd|jdd|jdd|jdd|jt|jt d|j t WdQXdS(sTest fail* methods pending deprecation, they will warn in 3.2. Do not use these methods. They will go away in 3.3. iig@g@g@cSsddS(NgQ @uspam((t_((s//usr/lib64/python2.7/unittest/test/test_case.pyRAR N( RR|t failIfEqualtfailUnlessEqualtfailUnlessAlmostEqualtfailIfAlmostEqualt failUnlessRtfailUnlessRaisesRtfailIfR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testPendingDeprecationMethodNames6s  cCs3dtjfdY}|d}t|dS(Nt TestableTestcBseZdZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyt testNothingGs(R R R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRFsR(RRR(RRR((s//usr/lib64/python2.7/unittest/test/test_case.pyt testDeepcopyDs csddddtjffdY}dtjffdY}dtjffdY}d tjffd Y}x@||||fD],}|jt|d jWdQXqWdS( NcSs tdS(N(tKeyboardInterrupt(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt_raisePscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pytnothingRstTest1cseZZRS((R R ttest_something((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR UstTest2cseZZZRS((R R RR ((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR XstTest3cseZZZRS((R R R R((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR \stTest4cseZfdZRS(cs|jdS(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR as(R R R ((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR`sR (RXRRR]RR0(RR R R Rtklass((RR s//usr/lib64/python2.7/unittest/test/test_case.pyttestKeyboardInterruptOs  ""csddddtjffdY}dtjffdY}dtjffdY}d tjffd Y}xe||||fD]Q}tj}|d j||jt|jd |j|jd qWdS( NcSs tdS(N(t SystemExit(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRiscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR ksR cseZZRS((R R R ((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR nsR cseZZZRS((R R RR ((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR qsR cseZZZRS((R R R R((RR (s//usr/lib64/python2.7/unittest/test/test_case.pyR usRcseZfdZRS(cs|jdS(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR zs(R R R ((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRysR i( RXRRR)R0RRterrorsttestsRun(RR R R RRR*((RR s//usr/lib64/python2.7/unittest/test/test_case.pyttestSystemExiths  "" cCsetjd}xOttjdD]:}tj|d|}tj|}|j||q#WdS(NR0itprotocol(RRRtpickletHIGHEST_PROTOCOLtdumpstloadsR(RRRt pickled_testtunpickled_test((s//usr/lib64/python2.7/unittest/test/test_case.pyt testPickles (FR R RRteq_pairsRtne_pairsRR R$R&R+R2R5R6R7R9R:R;R<R=RARBRDRERFRIRKRNRtskipIftsystflagstoptimizeRORPR\R_RaRdRfRvRRRRRRRRRRRRRRRRRRRRRRRRRRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyR,s!!                       % 4 '  $ > ( V $             t__main__(RRRRR tcopyRRRRtunittest.test.supportRRRRRVRRRR tmain(((s//usr/lib64/python2.7/unittest/test/test_case.pyts      "j PK]r= support.pynu[import unittest class TestHashing(object): """Used as a mixin for TestCase""" # Check for a valid __hash__ implementation def test_hash(self): for obj_1, obj_2 in self.eq_pairs: try: if not hash(obj_1) == hash(obj_2): self.fail("%r and %r do not hash equal" % (obj_1, obj_2)) except KeyboardInterrupt: raise except Exception, e: self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e)) for obj_1, obj_2 in self.ne_pairs: try: if hash(obj_1) == hash(obj_2): self.fail("%s and %s hash equal, but shouldn't" % (obj_1, obj_2)) except KeyboardInterrupt: raise except Exception, e: self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e)) class TestEquality(object): """Used as a mixin for TestCase""" # Check for a valid __eq__ implementation def test_eq(self): for obj_1, obj_2 in self.eq_pairs: self.assertEqual(obj_1, obj_2) self.assertEqual(obj_2, obj_1) # Check for a valid __ne__ implementation def test_ne(self): for obj_1, obj_2 in self.ne_pairs: self.assertNotEqual(obj_1, obj_2) self.assertNotEqual(obj_2, obj_1) class LoggingResult(unittest.TestResult): def __init__(self, log): self._events = log super(LoggingResult, self).__init__() def startTest(self, test): self._events.append('startTest') super(LoggingResult, self).startTest(test) def startTestRun(self): self._events.append('startTestRun') super(LoggingResult, self).startTestRun() def stopTest(self, test): self._events.append('stopTest') super(LoggingResult, self).stopTest(test) def stopTestRun(self): self._events.append('stopTestRun') super(LoggingResult, self).stopTestRun() def addFailure(self, *args): self._events.append('addFailure') super(LoggingResult, self).addFailure(*args) def addSuccess(self, *args): self._events.append('addSuccess') super(LoggingResult, self).addSuccess(*args) def addError(self, *args): self._events.append('addError') super(LoggingResult, self).addError(*args) def addSkip(self, *args): self._events.append('addSkip') super(LoggingResult, self).addSkip(*args) def addExpectedFailure(self, *args): self._events.append('addExpectedFailure') super(LoggingResult, self).addExpectedFailure(*args) def addUnexpectedSuccess(self, *args): self._events.append('addUnexpectedSuccess') super(LoggingResult, self).addUnexpectedSuccess(*args) class ResultWithNoStartTestRunStopTestRun(object): """An object honouring TestResult before startTestRun/stopTestRun.""" def __init__(self): self.failures = [] self.errors = [] self.testsRun = 0 self.skipped = [] self.expectedFailures = [] self.unexpectedSuccesses = [] self.shouldStop = False def startTest(self, test): pass def stopTest(self, test): pass def addError(self, test): pass def addFailure(self, test): pass def addSuccess(self, test): pass def wasSuccessful(self): return True PK]%v tt support.pyonu[ {fc@skddlZdefdYZdefdYZdejfdYZdefd YZdS( iNt TestHashingcBseZdZdZRS(sUsed as a mixin for TestCasecCs*x|jD]\}}y6t|t|ksK|jd||fnWq tk rbq tk r}|jd|||fq Xq Wx|jD]\}}y6t|t|kr|jd||fnWqtk rqtk r!}|jd|||fqXqWdS(Ns%r and %r do not hash equalsProblem hashing %r and %r: %ss#%s and %s hash equal, but shouldn'tsProblem hashing %s and %s: %s(teq_pairsthashtfailtKeyboardInterruptt Exceptiontne_pairs(tselftobj_1tobj_2te((s-/usr/lib64/python2.7/unittest/test/support.pyt test_hashs" "  (t__name__t __module__t__doc__R (((s-/usr/lib64/python2.7/unittest/test/support.pyRst TestEqualitycBs eZdZdZdZRS(sUsed as a mixin for TestCasecCs>x7|jD],\}}|j|||j||q WdS(N(Rt assertEqual(RRR ((s-/usr/lib64/python2.7/unittest/test/support.pyttest_eq!scCs>x7|jD],\}}|j|||j||q WdS(N(RtassertNotEqual(RRR ((s-/usr/lib64/python2.7/unittest/test/support.pyttest_ne's(R R RRR(((s-/usr/lib64/python2.7/unittest/test/support.pyRs t LoggingResultcBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( cCs ||_tt|jdS(N(t_eventstsuperRt__init__(Rtlog((s-/usr/lib64/python2.7/unittest/test/support.pyR.s cCs*|jjdtt|j|dS(Nt startTest(RtappendRRR(Rttest((s-/usr/lib64/python2.7/unittest/test/support.pyR2scCs'|jjdtt|jdS(Nt startTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR6scCs*|jjdtt|j|dS(NtstopTest(RRRRR(RR((s-/usr/lib64/python2.7/unittest/test/support.pyR:scCs'|jjdtt|jdS(Nt stopTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR>scGs*|jjdtt|j|dS(Nt addFailure(RRRRR(Rtargs((s-/usr/lib64/python2.7/unittest/test/support.pyRBscGs*|jjdtt|j|dS(Nt addSuccess(RRRRR!(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR!FscGs*|jjdtt|j|dS(NtaddError(RRRRR"(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR"JscGs*|jjdtt|j|dS(NtaddSkip(RRRRR#(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR#NscGs*|jjdtt|j|dS(NtaddExpectedFailure(RRRRR$(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR$RscGs*|jjdtt|j|dS(NtaddUnexpectedSuccess(RRRRR%(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR%Vs( R R RRRRRRR!R"R#R$R%(((s-/usr/lib64/python2.7/unittest/test/support.pyR-s          t#ResultWithNoStartTestRunStopTestRuncBsMeZdZdZdZdZdZdZdZdZ RS(s?An object honouring TestResult before startTestRun/stopTestRun.cCsCg|_g|_d|_g|_g|_g|_t|_dS(Ni(tfailuresterrorsttestsRuntskippedtexpectedFailurestunexpectedSuccessestFalset shouldStop(R((s-/usr/lib64/python2.7/unittest/test/support.pyR^s      cCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRgscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRjscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR"mscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRpscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR!sscCstS(N(tTrue(R((s-/usr/lib64/python2.7/unittest/test/support.pyt wasSuccessfulvs( R R RRRRR"RR!R0(((s-/usr/lib64/python2.7/unittest/test/support.pyR&[s     (tunittesttobjectRRt TestResultRR&(((s-/usr/lib64/python2.7/unittest/test/support.pyts .PK]Ij̟''test_break.pyonu[ {fc@sddlZddlZddlZddlZddlZddlmZddlZeje eddej ej dkdej ej dkdd ej fd YZ eje eddej ej dkdej ej dkdd e fd YZeje eddej ej dkdej ej dkdd e fdYZeje eddej ej dkdej ej dkdde fdYZdS(iN(tStringIOtkillsTest requires os.killtwin32sTest cannot run on Windowstfreebsd6s9Test kills regrtest on freebsd6 if threads have been usedt TestBreakcBseZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZRS(cCsAtjtj|_|jdk r=tjtj|jndS(N(tsignalt getsignaltSIGINTt_default_handlert int_handlertNone(tself((s0/usr/lib64/python2.7/unittest/test/test_break.pytsetUpscCs8tjtj|jtjtj_dtj_ dS(N( RRRtweakreftWeakKeyDictionarytunittesttsignalst_resultsR t_interrupt_handler(R ((s0/usr/lib64/python2.7/unittest/test/test_break.pyttearDownscCstjtj}tj|jtjtj|y#tj}tj|tjWnt k r{|j dnX|j tj j jdS(NsKeyboardInterrupt not handled(RRRRtinstallHandlertassertNotEqualtostgetpidRtKeyboardInterrupttfailt assertTrueRRtcalled(R tdefault_handlertpid((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestInstallHandlers   cCsmtj}tj|xMtjjD]2}||kr<Pq&||k r&|jdq&q&W|jddS(Nsodd object in result setsresult not found(Rt TestResulttregisterResultRRR(R tresulttref((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRegisterResult,s    cstjtj}tj}tjtj|jtjtj|fd}y||Wntk rj dnXj |j dS(Ncs<tj}tj|tjt|_j|jdS(N( RRRRRtTruet breakCaughtRt shouldStop(R!R(R (s0/usr/lib64/python2.7/unittest/test/test_break.pyttestBs  sKeyboardInterrupt not handled( RRRRRRR RRRRR%(R RR!R'((R s0/usr/lib64/python2.7/unittest/test/test_break.pyttestInterruptCaught9s    cstjtjtjkr+jdntj}tjtj|fd}y||Wnt k r~nXj dj |j dS(Ns&test requires SIGINT to not be ignoredcs\tj}tj|tjt|_j|jtj|tjj ddS(Ns#Second KeyboardInterrupt not raised( RRRRRR$R%RR&R(R!R(R (s0/usr/lib64/python2.7/unittest/test/test_break.pyR'Xs   s#Second KeyboardInterrupt not raised( RRRtSIG_IGNtskipTestRRRR RRRR%(R R!R'((R s0/usr/lib64/python2.7/unittest/test/test_break.pyttestSecondInterruptOs     cCstjtj}tj|tjtj}tj}tj||jtjtj|tj}d}y||Wntk r|j dnX|j |j |j |j |j |j dS(NcSs#tj}tj|tjdS(N(RRRRR(R!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyR'vs sKeyboardInterrupt not handled( RRRR RRRt assertEqualRRRR&t assertFalse(R R!t new_handlertresult2tresult3R'((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestTwoResultsis         cstjtjtjkr+|jdntjtjtjfd}tjtj|y#tj}tj |tjWnt k rnX|j ddS(Ns&test requires SIGINT to not be ignoredcs||dS(N((tframetsignum(thandler(s0/usr/lib64/python2.7/unittest/test/test_break.pyR.ss6replaced but delegated handler doesn't raise interrupt( RRRR)R*RRRRRRR(R R.R((R4s0/usr/lib64/python2.7/unittest/test/test_break.pyttestHandlerReplacedButCalleds   cCsDtjdt}|jtj}|j|tjjdS(Ntstream(RtTextTestRunnerRtrunt TestSuitetassertInRR(R trunnerR!((s0/usr/lib64/python2.7/unittest/test/test_break.pyt testRunnerscCsStj}tj|tj|}~tjtj|j|dS(N(RRR R R"tgctcollectt assertIsNone(R R!R"((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestWeakReferencess   cCstj}tj|tj|jtj||jtjtjy#tj}tj |t j Wnt k rnX|j|j dS(N(RRR RRt removeResultR-RRRRRRR&(R R!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveResults     cstttttjtj}dtffdYdtjffdY}|t}|j|jj didd6d6d6fg|jj g|j|j |jtjtj|g_ g_ |t }|j|jj d idd6d6d6fg|jj g|j|j |jtjtj|dS( Nt FakeRunnercs,eZgZgZdZfdZRS(c_s|jj||fdS(N(tinitArgstappend(R targstkwargs((s0/usr/lib64/python2.7/unittest/test/test_break.pyt__init__scs|jj|S(N(trunArgsRE(R R'(R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyR8s(t__name__t __module__RDRIRHR8((R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyRCs tProgramcs eZfdZRS(csCt|_|_|_||_|_|_d|_dS(N( tFalsetexitt verbositytfailfastt catchbreakR<R'R R!(R RQ(RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRHs      (RJRKRH((RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRLstbufferRORP(((tobjectRRRRt TestProgramRMtrunTestsR,RDR RIR!R$R(R RRLtp((RCRPR!R'ROs0/usr/lib64/python2.7/unittest/test/test_break.pyttestMainInstallsHandlers2     (      cCsltjtj}tjtj|jtjtj|tj|jtjtj|dS(N(RRRRRt removeHandlerR,(R R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandlers    cs^tjtjtjtjfd}|jtjtjdS(Ncs jtjtjdS(N(R,RRR((RR (s0/usr/lib64/python2.7/unittest/test/test_break.pyR's(RRRRRRXR(R R'((RR s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandlerAsDecorators  N(RJRKR R R RRR#R(R+R1R5R<R@RBRWRYRZ(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR s         2 tTestBreakDefaultIntHandlercBseZejZRS((RJRKRtdefault_int_handlerR (((s0/usr/lib64/python2.7/unittest/test/test_break.pyR[ stTestBreakSignalIgnoredcBseZejZRS((RJRKRR)R (((s0/usr/lib64/python2.7/unittest/test/test_break.pyR]stTestBreakSignalDefaultcBseZejZRS((RJRKRtSIG_DFLR (((s0/usr/lib64/python2.7/unittest/test/test_break.pyR^s(R=RtsysRR t cStringIORRt skipUnlessthasattrtskipIftplatformtTestCaseRR[R]R^(((s0/usr/lib64/python2.7/unittest/test/test_break.pyts,      PK]pV'..test_assertions.pynu[import datetime import unittest class Test_Assertions(unittest.TestCase): def test_AlmostEqual(self): self.assertAlmostEqual(1.00000001, 1.0) self.assertNotAlmostEqual(1.0000001, 1.0) self.assertRaises(self.failureException, self.assertAlmostEqual, 1.0000001, 1.0) self.assertRaises(self.failureException, self.assertNotAlmostEqual, 1.00000001, 1.0) self.assertAlmostEqual(1.1, 1.0, places=0) self.assertRaises(self.failureException, self.assertAlmostEqual, 1.1, 1.0, places=1) self.assertAlmostEqual(0, .1+.1j, places=0) self.assertNotAlmostEqual(0, .1+.1j, places=1) self.assertRaises(self.failureException, self.assertAlmostEqual, 0, .1+.1j, places=1) self.assertRaises(self.failureException, self.assertNotAlmostEqual, 0, .1+.1j, places=0) self.assertAlmostEqual(float('inf'), float('inf')) self.assertRaises(self.failureException, self.assertNotAlmostEqual, float('inf'), float('inf')) def test_AmostEqualWithDelta(self): self.assertAlmostEqual(1.1, 1.0, delta=0.5) self.assertAlmostEqual(1.0, 1.1, delta=0.5) self.assertNotAlmostEqual(1.1, 1.0, delta=0.05) self.assertNotAlmostEqual(1.0, 1.1, delta=0.05) self.assertAlmostEqual(1.0, 1.0, delta=0.5) self.assertRaises(self.failureException, self.assertNotAlmostEqual, 1.0, 1.0, delta=0.5) self.assertRaises(self.failureException, self.assertAlmostEqual, 1.1, 1.0, delta=0.05) self.assertRaises(self.failureException, self.assertNotAlmostEqual, 1.1, 1.0, delta=0.5) self.assertRaises(TypeError, self.assertAlmostEqual, 1.1, 1.0, places=2, delta=2) self.assertRaises(TypeError, self.assertNotAlmostEqual, 1.1, 1.0, places=2, delta=2) first = datetime.datetime.now() second = first + datetime.timedelta(seconds=10) self.assertAlmostEqual(first, second, delta=datetime.timedelta(seconds=20)) self.assertNotAlmostEqual(first, second, delta=datetime.timedelta(seconds=5)) def test_assertRaises(self): def _raise(e): raise e self.assertRaises(KeyError, _raise, KeyError) self.assertRaises(KeyError, _raise, KeyError("key")) try: self.assertRaises(KeyError, lambda: None) except self.failureException as e: self.assertIn("KeyError not raised", e.args) else: self.fail("assertRaises() didn't fail") try: self.assertRaises(KeyError, _raise, ValueError) except ValueError: pass else: self.fail("assertRaises() didn't let exception pass through") with self.assertRaises(KeyError) as cm: try: raise KeyError except Exception, e: raise self.assertIs(cm.exception, e) with self.assertRaises(KeyError): raise KeyError("key") try: with self.assertRaises(KeyError): pass except self.failureException as e: self.assertIn("KeyError not raised", e.args) else: self.fail("assertRaises() didn't fail") try: with self.assertRaises(KeyError): raise ValueError except ValueError: pass else: self.fail("assertRaises() didn't let exception pass through") def testAssertNotRegexpMatches(self): self.assertNotRegexpMatches('Ala ma kota', r'r+') try: self.assertNotRegexpMatches('Ala ma kota', r'k.t', 'Message') except self.failureException, e: self.assertIn("'kot'", e.args[0]) self.assertIn('Message', e.args[0]) else: self.fail('assertNotRegexpMatches should have failed.') class TestLongMessage(unittest.TestCase): """Test that the individual asserts honour longMessage. This actually tests all the message behaviour for asserts that use longMessage.""" def setUp(self): class TestableTestFalse(unittest.TestCase): longMessage = False failureException = self.failureException def testTest(self): pass class TestableTestTrue(unittest.TestCase): longMessage = True failureException = self.failureException def testTest(self): pass self.testableTrue = TestableTestTrue('testTest') self.testableFalse = TestableTestFalse('testTest') def testDefault(self): self.assertFalse(unittest.TestCase.longMessage) def test_formatMsg(self): self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo") self.assertEqual(self.testableFalse._formatMessage("foo", "bar"), "foo") self.assertEqual(self.testableTrue._formatMessage(None, "foo"), "foo") self.assertEqual(self.testableTrue._formatMessage("foo", "bar"), "bar : foo") # This blows up if _formatMessage uses string concatenation self.testableTrue._formatMessage(object(), 'foo') def test_formatMessage_unicode_error(self): one = ''.join(chr(i) for i in range(255)) # this used to cause a UnicodeDecodeError constructing msg self.testableTrue._formatMessage(one, u'\uFFFD') def assertMessages(self, methodName, args, errors): def getMethod(i): useTestableFalse = i < 2 if useTestableFalse: test = self.testableFalse else: test = self.testableTrue return getattr(test, methodName) for i, expected_regexp in enumerate(errors): testMethod = getMethod(i) kwargs = {} withMsg = i % 2 if withMsg: kwargs = {"msg": "oops"} with self.assertRaisesRegexp(self.failureException, expected_regexp=expected_regexp): testMethod(*args, **kwargs) def testAssertTrue(self): self.assertMessages('assertTrue', (False,), ["^False is not true$", "^oops$", "^False is not true$", "^False is not true : oops$"]) def testAssertFalse(self): self.assertMessages('assertFalse', (True,), ["^True is not false$", "^oops$", "^True is not false$", "^True is not false : oops$"]) def testNotEqual(self): self.assertMessages('assertNotEqual', (1, 1), ["^1 == 1$", "^oops$", "^1 == 1$", "^1 == 1 : oops$"]) def testAlmostEqual(self): self.assertMessages('assertAlmostEqual', (1, 2), ["^1 != 2 within 7 places$", "^oops$", "^1 != 2 within 7 places$", "^1 != 2 within 7 places : oops$"]) def testNotAlmostEqual(self): self.assertMessages('assertNotAlmostEqual', (1, 1), ["^1 == 1 within 7 places$", "^oops$", "^1 == 1 within 7 places$", "^1 == 1 within 7 places : oops$"]) def test_baseAssertEqual(self): self.assertMessages('_baseAssertEqual', (1, 2), ["^1 != 2$", "^oops$", "^1 != 2$", "^1 != 2 : oops$"]) def testAssertSequenceEqual(self): # Error messages are multiline so not testing on full message # assertTupleEqual and assertListEqual delegate to this method self.assertMessages('assertSequenceEqual', ([], [None]), ["\+ \[None\]$", "^oops$", r"\+ \[None\]$", r"\+ \[None\] : oops$"]) def testAssertSetEqual(self): self.assertMessages('assertSetEqual', (set(), set([None])), ["None$", "^oops$", "None$", "None : oops$"]) def testAssertIn(self): self.assertMessages('assertIn', (None, []), ['^None not found in \[\]$', "^oops$", '^None not found in \[\]$', '^None not found in \[\] : oops$']) def testAssertNotIn(self): self.assertMessages('assertNotIn', (None, [None]), ['^None unexpectedly found in \[None\]$', "^oops$", '^None unexpectedly found in \[None\]$', '^None unexpectedly found in \[None\] : oops$']) def testAssertDictEqual(self): self.assertMessages('assertDictEqual', ({}, {'key': 'value'}), [r"\+ \{'key': 'value'\}$", "^oops$", "\+ \{'key': 'value'\}$", "\+ \{'key': 'value'\} : oops$"]) def testAssertDictContainsSubset(self): self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}), ["^Missing: 'key'$", "^oops$", "^Missing: 'key'$", "^Missing: 'key' : oops$"]) def testAssertMultiLineEqual(self): self.assertMessages('assertMultiLineEqual', ("", "foo"), [r"\+ foo$", "^oops$", r"\+ foo$", r"\+ foo : oops$"]) def testAssertLess(self): self.assertMessages('assertLess', (2, 1), ["^2 not less than 1$", "^oops$", "^2 not less than 1$", "^2 not less than 1 : oops$"]) def testAssertLessEqual(self): self.assertMessages('assertLessEqual', (2, 1), ["^2 not less than or equal to 1$", "^oops$", "^2 not less than or equal to 1$", "^2 not less than or equal to 1 : oops$"]) def testAssertGreater(self): self.assertMessages('assertGreater', (1, 2), ["^1 not greater than 2$", "^oops$", "^1 not greater than 2$", "^1 not greater than 2 : oops$"]) def testAssertGreaterEqual(self): self.assertMessages('assertGreaterEqual', (1, 2), ["^1 not greater than or equal to 2$", "^oops$", "^1 not greater than or equal to 2$", "^1 not greater than or equal to 2 : oops$"]) def testAssertIsNone(self): self.assertMessages('assertIsNone', ('not None',), ["^'not None' is not None$", "^oops$", "^'not None' is not None$", "^'not None' is not None : oops$"]) def testAssertIsNotNone(self): self.assertMessages('assertIsNotNone', (None,), ["^unexpectedly None$", "^oops$", "^unexpectedly None$", "^unexpectedly None : oops$"]) def testAssertIs(self): self.assertMessages('assertIs', (None, 'foo'), ["^None is not 'foo'$", "^oops$", "^None is not 'foo'$", "^None is not 'foo' : oops$"]) def testAssertIsNot(self): self.assertMessages('assertIsNot', (None, None), ["^unexpectedly identical: None$", "^oops$", "^unexpectedly identical: None$", "^unexpectedly identical: None : oops$"]) if __name__ == '__main__': unittest.main() PK]4-7-7test_runner.pycnu[ |fc@sddlZddlmZddlZddlmZmZdejfdYZdejfdYZ e dkrej ndS( iN(tStringIO(t LoggingResultt#ResultWithNoStartTestRunStopTestRunt TestCleanUpcBs,eZdZdZdZdZRS(c sdtjfdY}|d}|j|jggfd}fd}|j|dddd d d d |j||j|j|d td d d d f|difg|j}|j||jddifddtd d d d fgdS(Nt TestableTestcBseZdZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt testNothings(t__name__t __module__R(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR sRcsjd||fdS(Ni(tappend(targstkwargs(tcleanups(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup1scsjd||fdS(Ni(R (R R (R (s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup2siiitfourthellotfivetgoodbye(iii(((iii(tunittesttTestCaset assertEqualt _cleanupst addCleanuptdictt doCleanupst assertTrue(RRttestR Rtresult((R s1/usr/lib64/python2.7/unittest/test/test_runner.pyt testCleanUp s "    cs+dtjfdY}dtfdY}|}|d}||_tdtdfd}fd }|j||j||j|jt|j \\}\}} } \} \} } } |j ||| f|tf|j | | | f|tfdS( NRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR+s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR*st MockResultcBseZgZdZRS(cSs|jj||fdS(N(terrorsR (RRtexc_info((s1/usr/lib64/python2.7/unittest/test/test_runner.pytaddError0s(RRRR!(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR.sRtfootbarcs dS(N(((texc1(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR 9scs dS(N(((texc2(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR<s( RRtobjectt_resultForDoCleanupst ExceptionRt assertFalseRtreversedRR(RRRRRR Rttest1tType1t instance1t_ttest2tType2t instance2((R$R%s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanUpWithErrors)s       3"cstgdtjffdY}|dfd}fd}j|j|fd}tj}||_j|jddd d d d gtg|dj|j|jdd gdS( NRcs8eZfdZfdZfdZRS(cs&jdr"tdndS(NtsetUpR"(R R((R(tblowUptordering(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3Ms csjddS(NR(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRscsjddS(NttearDown(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6Us(RRR3RR6((R4R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRLsRcsjddS(NR (R ((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR ZscsjddS(NR(R ((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR\scs!j|jddS(Ntsuccess(RR (t some_test(R5RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR7asR3RR6RR R7( tFalseRRRt TestResultt addSuccesstrunRtTrue(RRR RR7R((R4R5RRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanupInRunHs("         csgdtjffdY}|dfdfdj|jdddd d gdS( NRcs8eZfdZfdZfdZRS(csjd|jdS(NR3(R R(R(R R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3ws csjddS(NR(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR{scsjddS(NR6(R (R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6~s(RRR3RR6((R R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRvsRcsjdjdS(NR (R R((RR5R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR s csjddS(NR(R ((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRsR3RR6R R(RRtdebugR(RR((R RR5Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyt!testTestCaseDebugExecutesCleanupsss"  (RRRR2R>R@(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR s   +tTest_TextTestRunnercBsVeZdZdZdZdZdZdZdZdZ dZ RS( sTests for TextTestRunner.cCsitj}|j|j|j|j|j|jd|j|j|j|j tj dS(Ni( RtTextTestRunnerR)tfailfasttbufferRt verbosityRt descriptionst resultclasstTextTestResult(Rtrunner((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt test_inits  csOdtjffdYdtjfdY}|ddddS(NtAResultcseZfdZRS(cs t|j|||dS(N(tsupert__init__(RtstreamRFRE(RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRMs(RRRM((RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRKst ATextResultcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyROsi(RR:RHtNone(RRO((RKs1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_multiple_inheritancescsdtjfdY}tjtjdtdtdt}fd|_|j|d|jj |jj dS(NtTestcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestFoos(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRsRNRCRDcsS(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyttRS( RRR:RBRR=t _makeResultR<RRCRD(RRRRI((Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestBufferAndFailfasts  csdtjfdY}tjjfd}j|tjtjdt}fd|_d_ fd}|tj_|j tj j j ddS( NRRcBseZdZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRSs(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRscstj_dS(N(RRItregisterResult((toriginalRegisterResult(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanupsRNcsS(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRTRUics#jd7_j|dS(Ni(t wasRegisteredR(t thisResult(RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pytfakeRegisterResultsi( RRRIRXRR:RBRRVR[R<t TestSuiteR(RRRRZRIR]((RYRRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestRunnerRegistersResults     csXdtfdYdtjffdY}|jtjdS(Nt OldTextResultcBseZdZdZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt printErrorss(RRt separator2Ra(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR`stRunnercs&eZfdZfdZRS(cst|jtdS(N(RLRMR(R(Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRMscsS(N((R(R`(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRVs(RRRMRV((R`Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRcs(RRRBR<R^(RRI((R`Rcs1/usr/lib64/python2.7/unittest/test/test_runner.pyt7test_works_with_result_without_startTestRun_stopTestRuns" cs}dtfdYdtjffdYg}|}|jtjddg}|j||dS(NtLoggingTextResultcBseZdZdZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRas(RRRbRa(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRest LoggingRunnercs&eZfdZfdZRS(cs&t|jt||_dS(N(RLRMRt_events(Rtevents(Rf(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRMscs |jS(N(Rg(R(Re(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRVs(RRRMRV((RfRe(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRfst startTestRunt stopTestRun(RRRBR<R^R(RRhRItexpected((RfRes1/usr/lib64/python2.7/unittest/test/test_runner.pyt$test_startTestRun_stopTestRun_calleds"  cCsddlm}|d}tj|}x^ttjdD]I}tj|d|}tj|}|j|j j |j q?WdS(Ni(RR"itprotocol( RRRBtrangetpickletHIGHEST_PROTOCOLtdumpstloadsRRNtgetvalue(Rt PickleableIORNRIRmtstobj((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_pickle_unpickles cCs~d}t}t}t}tj|||d|}|j|j||j||f}|j|j|dS(NcWs|S(N((R ((s1/usr/lib64/python2.7/unittest/test/test_runner.pytMockResultClasssRG(R&RRBRRGRNRV(RRxtSTREAMt DESCRIPTIONSt VERBOSITYRItexpectedresult((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_resultclasss     ( RRt__doc__RJRQRWR_RdRlRwR}(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRAs     t__main__( Rt cStringIORRotunittest.test.supportRRRRRARtmain(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyts  } PK] patest_loader.pynu[import sys import types import unittest class Test_TestLoader(unittest.TestCase): ### Tests for TestLoader.loadTestsFromTestCase ################################################################ # "Return a suite of all test cases contained in the TestCase-derived # class testCaseClass" def test_loadTestsFromTestCase(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass tests = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) loader = unittest.TestLoader() self.assertEqual(loader.loadTestsFromTestCase(Foo), tests) # "Return a suite of all test cases contained in the TestCase-derived # class testCaseClass" # # Make sure it does the right thing even if no tests were found def test_loadTestsFromTestCase__no_matches(self): class Foo(unittest.TestCase): def foo_bar(self): pass empty_suite = unittest.TestSuite() loader = unittest.TestLoader() self.assertEqual(loader.loadTestsFromTestCase(Foo), empty_suite) # "Return a suite of all test cases contained in the TestCase-derived # class testCaseClass" # # What happens if loadTestsFromTestCase() is given an object # that isn't a subclass of TestCase? Specifically, what happens # if testCaseClass is a subclass of TestSuite? # # This is checked for specifically in the code, so we better add a # test for it. def test_loadTestsFromTestCase__TestSuite_subclass(self): class NotATestCase(unittest.TestSuite): pass loader = unittest.TestLoader() try: loader.loadTestsFromTestCase(NotATestCase) except TypeError: pass else: self.fail('Should raise TypeError') # "Return a suite of all test cases contained in the TestCase-derived # class testCaseClass" # # Make sure loadTestsFromTestCase() picks up the default test method # name (as specified by TestCase), even though the method name does # not match the default TestLoader.testMethodPrefix string def test_loadTestsFromTestCase__default_method_name(self): class Foo(unittest.TestCase): def runTest(self): pass loader = unittest.TestLoader() # This has to be false for the test to succeed self.assertFalse('runTest'.startswith(loader.testMethodPrefix)) suite = loader.loadTestsFromTestCase(Foo) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [Foo('runTest')]) ################################################################ ### /Tests for TestLoader.loadTestsFromTestCase ### Tests for TestLoader.loadTestsFromModule ################################################################ # "This method searches `module` for classes derived from TestCase" def test_loadTestsFromModule__TestCase_subclass(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, loader.suiteClass) expected = [loader.suiteClass([MyTestCase('test')])] self.assertEqual(list(suite), expected) # "This method searches `module` for classes derived from TestCase" # # What happens if no tests are found (no TestCase instances)? def test_loadTestsFromModule__no_TestCase_instances(self): m = types.ModuleType('m') loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # "This method searches `module` for classes derived from TestCase" # # What happens if no tests are found (TestCases instances, but no tests)? def test_loadTestsFromModule__no_TestCase_tests(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [loader.suiteClass()]) # "This method searches `module` for classes derived from TestCase"s # # What happens if loadTestsFromModule() is given something other # than a module? # # XXX Currently, it succeeds anyway. This flexibility # should either be documented or loadTestsFromModule() should # raise a TypeError # # XXX Certain people are using this behaviour. We'll add a test for it def test_loadTestsFromModule__not_a_module(self): class MyTestCase(unittest.TestCase): def test(self): pass class NotAModule(object): test_2 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromModule(NotAModule) reference = [unittest.TestSuite([MyTestCase('test')])] self.assertEqual(list(suite), reference) # Check that loadTestsFromModule honors (or not) a module # with a load_tests function. def test_loadTestsFromModule__load_tests(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase load_tests_args = [] def load_tests(loader, tests, pattern): self.assertIsInstance(tests, unittest.TestSuite) load_tests_args.extend((loader, tests, pattern)) return tests m.load_tests = load_tests loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, unittest.TestSuite) self.assertEqual(load_tests_args, [loader, suite, None]) load_tests_args = [] suite = loader.loadTestsFromModule(m, use_load_tests=False) self.assertEqual(load_tests_args, []) def test_loadTestsFromModule__faulty_load_tests(self): m = types.ModuleType('m') def load_tests(loader, tests, pattern): raise TypeError('some failure') m.load_tests = load_tests loader = unittest.TestLoader() suite = loader.loadTestsFromModule(m) self.assertIsInstance(suite, unittest.TestSuite) self.assertEqual(suite.countTestCases(), 1) test = list(suite)[0] self.assertRaisesRegexp(TypeError, "some failure", test.m) ################################################################ ### /Tests for TestLoader.loadTestsFromModule() ### Tests for TestLoader.loadTestsFromName() ################################################################ # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Is ValueError raised in response to an empty name? def test_loadTestsFromName__empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('') except ValueError, e: self.assertEqual(str(e), "Empty module name") else: self.fail("TestLoader.loadTestsFromName failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when the name contains invalid characters? def test_loadTestsFromName__malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise ValueError or ImportError? try: loader.loadTestsFromName('abc () //') except ValueError: pass except ImportError: pass else: self.fail("TestLoader.loadTestsFromName failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve ... to a # module" # # What happens when a module by that name can't be found? def test_loadTestsFromName__unknown_module_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('sdasfasfasdf') except ImportError, e: self.assertEqual(str(e), "No module named sdasfasfasdf") else: self.fail("TestLoader.loadTestsFromName failed to raise ImportError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when the module is found, but the attribute can't? def test_loadTestsFromName__unknown_attr_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('unittest.sdasfasfasdf') except AttributeError, e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when we provide the module, but the attribute can't be # found? def test_loadTestsFromName__relative_unknown_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('sdasfasfasdf', unittest) except AttributeError, e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # Does loadTestsFromName raise ValueError when passed an empty # name relative to a provided module? # # XXX Should probably raise a ValueError instead of an AttributeError def test_loadTestsFromName__relative_empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromName('', unittest) except AttributeError: pass else: self.fail("Failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when an impossible name is given, relative to the provided # `module`? def test_loadTestsFromName__relative_malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise AttributeError or ValueError? try: loader.loadTestsFromName('abc () //', unittest) except ValueError: pass except AttributeError: pass else: self.fail("TestLoader.loadTestsFromName failed to raise ValueError") # "The method optionally resolves name relative to the given module" # # Does loadTestsFromName raise TypeError when the `module` argument # isn't a module object? # # XXX Accepts the not-a-module object, ignoring the object's type # This should raise an exception or the method name should be changed # # XXX Some people are relying on this, so keep it for now def test_loadTestsFromName__relative_not_a_module(self): class MyTestCase(unittest.TestCase): def test(self): pass class NotAModule(object): test_2 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('test_2', NotAModule) reference = [MyTestCase('test')] self.assertEqual(list(suite), reference) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Does it raise an exception if the name resolves to an invalid # object? def test_loadTestsFromName__relative_bad_object(self): m = types.ModuleType('m') m.testcase_1 = object() loader = unittest.TestLoader() try: loader.loadTestsFromName('testcase_1', m) except TypeError: pass else: self.fail("Should have raised TypeError") # "The specifier name is a ``dotted name'' that may # resolve either to ... a test case class" def test_loadTestsFromName__relative_TestCase_subclass(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('testcase_1', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." def test_loadTestsFromName__relative_TestSuite(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testsuite = unittest.TestSuite([MyTestCase('test')]) loader = unittest.TestLoader() suite = loader.loadTestsFromName('testsuite', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a test method within a test case class" def test_loadTestsFromName__relative_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('testcase_1.test', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Does loadTestsFromName() raise the proper exception when trying to # resolve "a test method within a test case class" that doesn't exist # for the given name (relative to a provided module)? def test_loadTestsFromName__relative_invalid_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() try: loader.loadTestsFromName('testcase_1.testfoo', m) except AttributeError, e: self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'") else: self.fail("Failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a ... TestSuite instance" def test_loadTestsFromName__callable__TestSuite(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) testcase_2 = unittest.FunctionTestCase(lambda: None) def return_TestSuite(): return unittest.TestSuite([testcase_1, testcase_2]) m.return_TestSuite = return_TestSuite loader = unittest.TestLoader() suite = loader.loadTestsFromName('return_TestSuite', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [testcase_1, testcase_2]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase ... instance" def test_loadTestsFromName__callable__TestCase_instance(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) def return_TestCase(): return testcase_1 m.return_TestCase = return_TestCase loader = unittest.TestLoader() suite = loader.loadTestsFromName('return_TestCase', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [testcase_1]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase ... instance" #***************************************************************** #Override the suiteClass attribute to ensure that the suiteClass #attribute is used def test_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass(self): class SubTestSuite(unittest.TestSuite): pass m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) def return_TestCase(): return testcase_1 m.return_TestCase = return_TestCase loader = unittest.TestLoader() loader.suiteClass = SubTestSuite suite = loader.loadTestsFromName('return_TestCase', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [testcase_1]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a test method within a test case class" #***************************************************************** #Override the suiteClass attribute to ensure that the suiteClass #attribute is used def test_loadTestsFromName__relative_testmethod_ProperSuiteClass(self): class SubTestSuite(unittest.TestSuite): pass m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() loader.suiteClass=SubTestSuite suite = loader.loadTestsFromName('testcase_1.test', m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [MyTestCase('test')]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase or TestSuite instance" # # What happens if the callable returns something else? def test_loadTestsFromName__callable__wrong_type(self): m = types.ModuleType('m') def return_wrong(): return 6 m.return_wrong = return_wrong loader = unittest.TestLoader() try: loader.loadTestsFromName('return_wrong', m) except TypeError: pass else: self.fail("TestLoader.loadTestsFromName failed to raise TypeError") # "The specifier can refer to modules and packages which have not been # imported; they will be imported as a side-effect" def test_loadTestsFromName__module_not_loaded(self): # We're going to try to load this module as a side-effect, so it # better not be loaded before we try. # module_name = 'unittest.test.dummy' sys.modules.pop(module_name, None) loader = unittest.TestLoader() try: suite = loader.loadTestsFromName(module_name) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # module should now be loaded, thanks to loadTestsFromName() self.assertIn(module_name, sys.modules) finally: if module_name in sys.modules: del sys.modules[module_name] ################################################################ ### Tests for TestLoader.loadTestsFromName() ### Tests for TestLoader.loadTestsFromNames() ################################################################ # "Similar to loadTestsFromName(), but takes a sequence of names rather # than a single name." # # What happens if that sequence of names is empty? def test_loadTestsFromNames__empty_name_list(self): loader = unittest.TestLoader() suite = loader.loadTestsFromNames([]) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # "Similar to loadTestsFromName(), but takes a sequence of names rather # than a single name." # ... # "The method optionally resolves name relative to the given module" # # What happens if that sequence of names is empty? # # XXX Should this raise a ValueError or just return an empty TestSuite? def test_loadTestsFromNames__relative_empty_name_list(self): loader = unittest.TestLoader() suite = loader.loadTestsFromNames([], unittest) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), []) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Is ValueError raised in response to an empty name? def test_loadTestsFromNames__empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['']) except ValueError, e: self.assertEqual(str(e), "Empty module name") else: self.fail("TestLoader.loadTestsFromNames failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when presented with an impossible module name? def test_loadTestsFromNames__malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise ValueError or ImportError? try: loader.loadTestsFromNames(['abc () //']) except ValueError: pass except ImportError: pass else: self.fail("TestLoader.loadTestsFromNames failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when no module can be found for the given name? def test_loadTestsFromNames__unknown_module_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['sdasfasfasdf']) except ImportError, e: self.assertEqual(str(e), "No module named sdasfasfasdf") else: self.fail("TestLoader.loadTestsFromNames failed to raise ImportError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # What happens when the module can be found, but not the attribute? def test_loadTestsFromNames__unknown_attr_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['unittest.sdasfasfasdf', 'unittest']) except AttributeError, e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when given an unknown attribute on a specified `module` # argument? def test_loadTestsFromNames__unknown_name_relative_1(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['sdasfasfasdf'], unittest) except AttributeError, e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # Do unknown attributes (relative to a provided module) still raise an # exception even in the presence of valid attribute names? def test_loadTestsFromNames__unknown_name_relative_2(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest) except AttributeError, e: self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'") else: self.fail("TestLoader.loadTestsFromName failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when faced with the empty string? # # XXX This currently raises AttributeError, though ValueError is probably # more appropriate def test_loadTestsFromNames__relative_empty_name(self): loader = unittest.TestLoader() try: loader.loadTestsFromNames([''], unittest) except AttributeError: pass else: self.fail("Failed to raise ValueError") # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # ... # "The method optionally resolves name relative to the given module" # # What happens when presented with an impossible attribute name? def test_loadTestsFromNames__relative_malformed_name(self): loader = unittest.TestLoader() # XXX Should this raise AttributeError or ValueError? try: loader.loadTestsFromNames(['abc () //'], unittest) except AttributeError: pass except ValueError: pass else: self.fail("TestLoader.loadTestsFromNames failed to raise ValueError") # "The method optionally resolves name relative to the given module" # # Does loadTestsFromNames() make sure the provided `module` is in fact # a module? # # XXX This validation is currently not done. This flexibility should # either be documented or a TypeError should be raised. def test_loadTestsFromNames__relative_not_a_module(self): class MyTestCase(unittest.TestCase): def test(self): pass class NotAModule(object): test_2 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['test_2'], NotAModule) reference = [unittest.TestSuite([MyTestCase('test')])] self.assertEqual(list(suite), reference) # "The specifier name is a ``dotted name'' that may resolve either to # a module, a test case class, a TestSuite instance, a test method # within a test case class, or a callable object which returns a # TestCase or TestSuite instance." # # Does it raise an exception if the name resolves to an invalid # object? def test_loadTestsFromNames__relative_bad_object(self): m = types.ModuleType('m') m.testcase_1 = object() loader = unittest.TestLoader() try: loader.loadTestsFromNames(['testcase_1'], m) except TypeError: pass else: self.fail("Should have raised TypeError") # "The specifier name is a ``dotted name'' that may resolve ... to # ... a test case class" def test_loadTestsFromNames__relative_TestCase_subclass(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['testcase_1'], m) self.assertIsInstance(suite, loader.suiteClass) expected = loader.suiteClass([MyTestCase('test')]) self.assertEqual(list(suite), [expected]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a TestSuite instance" def test_loadTestsFromNames__relative_TestSuite(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testsuite = unittest.TestSuite([MyTestCase('test')]) loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['testsuite'], m) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [m.testsuite]) # "The specifier name is a ``dotted name'' that may resolve ... to ... a # test method within a test case class" def test_loadTestsFromNames__relative_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['testcase_1.test'], m) self.assertIsInstance(suite, loader.suiteClass) ref_suite = unittest.TestSuite([MyTestCase('test')]) self.assertEqual(list(suite), [ref_suite]) # "The specifier name is a ``dotted name'' that may resolve ... to ... a # test method within a test case class" # # Does the method gracefully handle names that initially look like they # resolve to "a test method within a test case class" but don't? def test_loadTestsFromNames__relative_invalid_testmethod(self): m = types.ModuleType('m') class MyTestCase(unittest.TestCase): def test(self): pass m.testcase_1 = MyTestCase loader = unittest.TestLoader() try: loader.loadTestsFromNames(['testcase_1.testfoo'], m) except AttributeError, e: self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'") else: self.fail("Failed to raise AttributeError") # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a ... TestSuite instance" def test_loadTestsFromNames__callable__TestSuite(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) testcase_2 = unittest.FunctionTestCase(lambda: None) def return_TestSuite(): return unittest.TestSuite([testcase_1, testcase_2]) m.return_TestSuite = return_TestSuite loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['return_TestSuite'], m) self.assertIsInstance(suite, loader.suiteClass) expected = unittest.TestSuite([testcase_1, testcase_2]) self.assertEqual(list(suite), [expected]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase ... instance" def test_loadTestsFromNames__callable__TestCase_instance(self): m = types.ModuleType('m') testcase_1 = unittest.FunctionTestCase(lambda: None) def return_TestCase(): return testcase_1 m.return_TestCase = return_TestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['return_TestCase'], m) self.assertIsInstance(suite, loader.suiteClass) ref_suite = unittest.TestSuite([testcase_1]) self.assertEqual(list(suite), [ref_suite]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase or TestSuite instance" # # Are staticmethods handled correctly? def test_loadTestsFromNames__callable__call_staticmethod(self): m = types.ModuleType('m') class Test1(unittest.TestCase): def test(self): pass testcase_1 = Test1('test') class Foo(unittest.TestCase): @staticmethod def foo(): return testcase_1 m.Foo = Foo loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['Foo.foo'], m) self.assertIsInstance(suite, loader.suiteClass) ref_suite = unittest.TestSuite([testcase_1]) self.assertEqual(list(suite), [ref_suite]) # "The specifier name is a ``dotted name'' that may resolve ... to # ... a callable object which returns a TestCase or TestSuite instance" # # What happens when the callable returns something else? def test_loadTestsFromNames__callable__wrong_type(self): m = types.ModuleType('m') def return_wrong(): return 6 m.return_wrong = return_wrong loader = unittest.TestLoader() try: loader.loadTestsFromNames(['return_wrong'], m) except TypeError: pass else: self.fail("TestLoader.loadTestsFromNames failed to raise TypeError") # "The specifier can refer to modules and packages which have not been # imported; they will be imported as a side-effect" def test_loadTestsFromNames__module_not_loaded(self): # We're going to try to load this module as a side-effect, so it # better not be loaded before we try. # module_name = 'unittest.test.dummy' sys.modules.pop(module_name, None) loader = unittest.TestLoader() try: suite = loader.loadTestsFromNames([module_name]) self.assertIsInstance(suite, loader.suiteClass) self.assertEqual(list(suite), [unittest.TestSuite()]) # module should now be loaded, thanks to loadTestsFromName() self.assertIn(module_name, sys.modules) finally: if module_name in sys.modules: del sys.modules[module_name] ################################################################ ### /Tests for TestLoader.loadTestsFromNames() ### Tests for TestLoader.getTestCaseNames() ################################################################ # "Return a sorted sequence of method names found within testCaseClass" # # Test.foobar is defined to make sure getTestCaseNames() respects # loader.testMethodPrefix def test_getTestCaseNames(self): class Test(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foobar(self): pass loader = unittest.TestLoader() self.assertEqual(loader.getTestCaseNames(Test), ['test_1', 'test_2']) # "Return a sorted sequence of method names found within testCaseClass" # # Does getTestCaseNames() behave appropriately if no tests are found? def test_getTestCaseNames__no_tests(self): class Test(unittest.TestCase): def foobar(self): pass loader = unittest.TestLoader() self.assertEqual(loader.getTestCaseNames(Test), []) # "Return a sorted sequence of method names found within testCaseClass" # # Are not-TestCases handled gracefully? # # XXX This should raise a TypeError, not return a list # # XXX It's too late in the 2.5 release cycle to fix this, but it should # probably be revisited for 2.6 def test_getTestCaseNames__not_a_TestCase(self): class BadCase(int): def test_foo(self): pass loader = unittest.TestLoader() names = loader.getTestCaseNames(BadCase) self.assertEqual(names, ['test_foo']) # "Return a sorted sequence of method names found within testCaseClass" # # Make sure inherited names are handled. # # TestP.foobar is defined to make sure getTestCaseNames() respects # loader.testMethodPrefix def test_getTestCaseNames__inheritance(self): class TestP(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foobar(self): pass class TestC(TestP): def test_1(self): pass def test_3(self): pass loader = unittest.TestLoader() names = ['test_1', 'test_2', 'test_3'] self.assertEqual(loader.getTestCaseNames(TestC), names) ################################################################ ### /Tests for TestLoader.getTestCaseNames() ### Tests for TestLoader.testMethodPrefix ################################################################ # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromTestCase(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass tests_1 = unittest.TestSuite([Foo('foo_bar')]) tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_2) # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromModule(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests_1 = [unittest.TestSuite([Foo('foo_bar')])] tests_2 = [unittest.TestSuite([Foo('test_1'), Foo('test_2')])] loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(list(loader.loadTestsFromModule(m)), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(list(loader.loadTestsFromModule(m)), tests_2) # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromName(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests_1 = unittest.TestSuite([Foo('foo_bar')]) tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(loader.loadTestsFromName('Foo', m), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(loader.loadTestsFromName('Foo', m), tests_2) # "String giving the prefix of method names which will be interpreted as # test methods" # # Implicit in the documentation is that testMethodPrefix is respected by # all loadTestsFrom* methods. def test_testMethodPrefix__loadTestsFromNames(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests_1 = unittest.TestSuite([unittest.TestSuite([Foo('foo_bar')])]) tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')]) tests_2 = unittest.TestSuite([tests_2]) loader = unittest.TestLoader() loader.testMethodPrefix = 'foo' self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_1) loader.testMethodPrefix = 'test' self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_2) # "The default value is 'test'" def test_testMethodPrefix__default_value(self): loader = unittest.TestLoader() self.assertTrue(loader.testMethodPrefix == 'test') ################################################################ ### /Tests for TestLoader.testMethodPrefix ### Tests for TestLoader.sortTestMethodsUsing ################################################################ # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromTestCase(self): def reversed_cmp(x, y): return -cmp(x, y) class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = loader.suiteClass([Foo('test_2'), Foo('test_1')]) self.assertEqual(loader.loadTestsFromTestCase(Foo), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromModule(self): def reversed_cmp(x, y): return -cmp(x, y) m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass m.Foo = Foo loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])] self.assertEqual(list(loader.loadTestsFromModule(m)), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromName(self): def reversed_cmp(x, y): return -cmp(x, y) m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass m.Foo = Foo loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = loader.suiteClass([Foo('test_2'), Foo('test_1')]) self.assertEqual(loader.loadTestsFromName('Foo', m), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromNames(self): def reversed_cmp(x, y): return -cmp(x, y) m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass m.Foo = Foo loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])] self.assertEqual(list(loader.loadTestsFromNames(['Foo'], m)), tests) # "Function to be used to compare method names when sorting them in # getTestCaseNames()" # # Does it actually affect getTestCaseNames()? def test_sortTestMethodsUsing__getTestCaseNames(self): def reversed_cmp(x, y): return -cmp(x, y) class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass loader = unittest.TestLoader() loader.sortTestMethodsUsing = reversed_cmp test_names = ['test_2', 'test_1'] self.assertEqual(loader.getTestCaseNames(Foo), test_names) # "The default value is the built-in cmp() function" def test_sortTestMethodsUsing__default_value(self): loader = unittest.TestLoader() self.assertTrue(loader.sortTestMethodsUsing is cmp) # "it can be set to None to disable the sort." # # XXX How is this different from reassigning cmp? Are the tests returned # in a random order or something? This behaviour should die def test_sortTestMethodsUsing__None(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass loader = unittest.TestLoader() loader.sortTestMethodsUsing = None test_names = ['test_2', 'test_1'] self.assertEqual(set(loader.getTestCaseNames(Foo)), set(test_names)) ################################################################ ### /Tests for TestLoader.sortTestMethodsUsing ### Tests for TestLoader.suiteClass ################################################################ # "Callable object that constructs a test suite from a list of tests." def test_suiteClass__loadTestsFromTestCase(self): class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass tests = [Foo('test_1'), Foo('test_2')] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromTestCase(Foo), tests) # It is implicit in the documentation for TestLoader.suiteClass that # all TestLoader.loadTestsFrom* methods respect it. Let's make sure def test_suiteClass__loadTestsFromModule(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests = [[Foo('test_1'), Foo('test_2')]] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromModule(m), tests) # It is implicit in the documentation for TestLoader.suiteClass that # all TestLoader.loadTestsFrom* methods respect it. Let's make sure def test_suiteClass__loadTestsFromName(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests = [Foo('test_1'), Foo('test_2')] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromName('Foo', m), tests) # It is implicit in the documentation for TestLoader.suiteClass that # all TestLoader.loadTestsFrom* methods respect it. Let's make sure def test_suiteClass__loadTestsFromNames(self): m = types.ModuleType('m') class Foo(unittest.TestCase): def test_1(self): pass def test_2(self): pass def foo_bar(self): pass m.Foo = Foo tests = [[Foo('test_1'), Foo('test_2')]] loader = unittest.TestLoader() loader.suiteClass = list self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests) # "The default value is the TestSuite class" def test_suiteClass__default_value(self): loader = unittest.TestLoader() self.assertIs(loader.suiteClass, unittest.TestSuite) # Make sure the dotted name resolution works even if the actual # function doesn't have the same name as is used to find it. def test_loadTestsFromName__function_with_different_name_than_method(self): # lambdas have the name ''. m = types.ModuleType('m') class MyTestCase(unittest.TestCase): test = lambda: 1 m.testcase_1 = MyTestCase loader = unittest.TestLoader() suite = loader.loadTestsFromNames(['testcase_1.test'], m) self.assertIsInstance(suite, loader.suiteClass) ref_suite = unittest.TestSuite([MyTestCase('test')]) self.assertEqual(list(suite), [ref_suite]) if __name__ == '__main__': unittest.main() PK] runtktests.pynu[""" Use this module to get and run all tk tests. Tkinter tests should live in a package inside the directory where this file lives, like test_tkinter. Extensions also should live in packages following the same rule as above. """ import os import sys import unittest import importlib import test.test_support this_dir_path = os.path.abspath(os.path.dirname(__file__)) def is_package(path): for name in os.listdir(path): if name in ('__init__.py', '__init__.pyc', '__init.pyo'): return True return False def get_tests_modules(basepath=this_dir_path, gui=True, packages=None): """This will import and yield modules whose names start with test_ and are inside packages found in the path starting at basepath. If packages is specified it should contain package names that want their tests collected. """ py_ext = '.py' for dirpath, dirnames, filenames in os.walk(basepath): for dirname in list(dirnames): if dirname[0] == '.': dirnames.remove(dirname) if is_package(dirpath) and filenames: pkg_name = dirpath[len(basepath) + len(os.sep):].replace('/', '.') if packages and pkg_name not in packages: continue filenames = filter( lambda x: x.startswith('test_') and x.endswith(py_ext), filenames) for name in filenames: try: yield importlib.import_module( ".%s" % name[:-len(py_ext)], pkg_name) except test.test_support.ResourceDenied: if gui: raise def get_tests(text=True, gui=True, packages=None): """Yield all the tests in the modules found by get_tests_modules. If nogui is True, only tests that do not require a GUI will be returned.""" attrs = [] if text: attrs.append('tests_nogui') if gui: attrs.append('tests_gui') for module in get_tests_modules(gui=gui, packages=packages): for attr in attrs: for test in getattr(module, attr, ()): yield test if __name__ == "__main__": test.test_support.run_unittest(*get_tests()) PK]Mf}g}gwidget_tests.pycnu[ zfc@sVddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z ddl ZeZZe dddfkreZneoeeZdZeZe d dddfkreZneZd efd YZd efd YZd efdYZdefdYZdZdZdS(iN(tScale(tAbstractTkTestt tcl_versiont requires_tcltget_tk_patchlevelt pixels_convt tcl_obj_eqiii cCstt|S(N(tinttround(tx((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt int_roundsitAbstractWidgetTestcBseZeeZdZeZe dZ dZ de j dZeeddZdedZdZdZdZdZdd Zd Zd Zd Zd ZdZdZdZdZdZ RS(cCsEy |jSWn3tk r@t|jjdd|_|jSXdS(Nttktscaling(t_scalingtAttributeErrortfloattroottcall(tself((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR "s   cCsU|j r#|jr#tdkr#|St|trKdjt|j|St|S(Niit (ii( t _stringifyt wantobjectsRt isinstancettupletjointmapt_strtstr(Rtvalue((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR*s cCs*|||rdS|j|||dS(N(t assertEqual(Rtactualtexpectedtmsgteq((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt assertEqual21scCs|||<|tkr|}n|r4||}n|jsG|j rwt|trhtj|}qwt|}n|dkrt }n|j |||d||j |j ||d|t|t s|j |}|jt|d|j |d|d|ndS(NR"ii(t _sentinelRRRRttkintert_joinRtNoneRR#tcgetRt configureRtlen(RtwidgettnameRR tconvR"tt((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt checkParam6s"     c Cs||}|dk r(|j|}n|jtj}|||RARJRRRWR[R`RdRkRpRrRxR(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR s0            tStandardOptionsTestsc*BseZdbZd*Zd+Zd,Zd-Zd.Zd/Zd0Z d1Z d2Z d3Z d4Z d5Zd6Zd7Zd8Zd9Zejejd:kd;d<Zd=Zd>Zd?Zd@ZdAZdBZdCZdDZdEZ dFZ!dGZ"dHZ#dIZ$dJZ%dKZ&dLZ'dMZ(dNZ)dOZ*dPZ+dQZ,dRZ-dSZ.dTZ/dUZ0dVZ1dWZ2dXZ3dYZ4dZZ5d[Z6d\Z7e8d]d^d_Z9e8d]d^d`Z:daZ;RS(ctactivebackgroundtactiveborderwidthtactiveforegroundtanchorR{tbitmapRytcompoundtcursortdisabledforegroundtexportselectiontfontR}thighlightbackgroundthighlightcolorthighlightthicknessRotinsertbackgroundtinsertborderwidtht insertofftimet insertontimet insertwidthtjumptjustifytorienttpadxtpadytrelieft repeatdelaytrepeatintervaltselectbackgroundtselectborderwidthtselectforegroundtsetgridt takefocusttextt textvariablet troughcolort underlinet wraplengthtxscrollcommandtyscrollcommandcCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_activebackground s c Cs2|j}|j|ddddddddS(NRig?g333333@iiR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_activeborderwidths  cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_activeforegrounds c Cs;|j}|j|ddddddddd d dS( NRtntnetetsetstswtwtnwtcenter(RR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_anchors  cCsB|j}|j|dd|jkr>|j|dndS(NR{R|(RRRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_backgrounds cCs|j}|j|dd|j|ddtjjddd}|j|dd|d|jjjd d kod |jjks|j |dd d dndS(NRt questheadtgray50s python.xbmtsubdirt imghdrdatat@taquaR twindowingsystemtAppKitR?R4sbitmap "spam" not defined( RR/RRtfindfileRR Rt winfo_serverR8(RR+tfilename((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_bitmap%s c Csf|j}|j|dddddddd|jkrb|j|dddddddndS( NRyig?g@iiR=Rz(RRdR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_borderwidth2s   c Cs2|j}|j|ddddddddS(NRtbottomRtleftRVtrightttop(RR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_compound9s  cCs |j}|j|ddS(NR(RRW(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_cursor>s cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_disabledforegroundBs cCs |j}|j|ddS(NR(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_exportselectionFs cCs<|j}|j|dd|j|dddddS(NRs3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*R<R4sfont "" doesn't exist(RR/R8(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_fontJs   cCsB|j}|j|dd|jkr>|j|dndS(NR}R~(RRRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_foregroundQs cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_highlightbackgroundWs cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_highlightcolor[s cCsQ|j}|j|dddddd|j|ddddd |jdS( NRig?g@iR=iR R-(RRdR/Rb(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_highlightthickness_s   tdarwins"crashes with Cocoa Tk (issue19733)cCs |j}|j|ddS(NRo(RRp(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_imagefs cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertbackgroundls c Cs2|j}|j|ddddddddS(NRig?g@iiR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertborderwidthps  cCs#|j}|j|dddS(NRid(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertofftimeus cCs#|j}|j|dddS(NRid(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertontimeys cCs,|j}|j|ddddddS(NRg?g@iR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertwidth}s cCs |j}|j|ddS(NR(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_jumps cCsH|j}|j|dddddd|j|dddddS( NRRRRR4s6bad justification "{}": must be left, right, or centerR<s:ambiguous justification "": must be left, right, or center(RR`R8(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_justifys  cCsC|j}|jt|d|j|j|ddddS(NRt horizontaltvertical(RRRtdefault_orientR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_orients c Cs8|j}|j|ddddddd|jdS(NRig@gffffff@it12mR-(RRdR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_padxs c Cs8|j}|j|ddddddd|jdS(NRig@gffffff@iRR-(RRdR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_padys cCs |j}|j|ddS(NR(RRk(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_reliefs cCs&|j}|j|ddddS(NRi i(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_repeatdelays cCs&|j}|j|ddddS(NRi i(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_repeatintervals cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectbackgrounds cCs,|j}|j|ddddddS(NRg?g@iR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectborderwidths cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectforegrounds cCs |j}|j|ddS(NR(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_setgrids cCs)|j}|j|dddddS(Ntstatetactivetdisabledtnormal(RR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_states cCs)|j}|j|dddddS(NRt0t1R<(RR;(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_takefocuss cCs&|j}|j|ddddS(NRR<s any string(RR;(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_texts cCs5|j}tj|j}|j|d|dS(NR(RR%t StringVarRRr(RR+Rq((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_textvariables cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_troughcolors cCs)|j}|j|dddddS(NRiii (RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_underlines cCs#|j}|j|dddS(NRid(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_wraplengths cCs |j}|j|ddS(NR(RR[(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_xscrollcommands cCs |j}|j|ddS(NR(RR[(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_yscrollcommands cCs |j}|j|ddS(NRY(RR[(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_commands cCs |j}|j|ddS(Nt indicatoron(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_indicatorons cCs |j}|j|ddS(Nt offrelief(RRk(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_offreliefs cCs |j}|j|ddS(Nt overrelief(RRk(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_overreliefs cCs |j}|j|ddS(Nt selectcolor(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectcolors cCs |j}|j|ddS(Nt selectimage(RRp(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectimages iicCs |j}|j|ddS(Nt tristateimage(RRp(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_tristateimages cCs#|j}|j|dddS(Nt tristatevaluet unknowable(RR/(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_tristatevalues cCs5|j}tj|j}|j|d|dS(Ntvariable(RR%t DoubleVarRRr(RR+Rq((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_variables (*RRRRR{RRyRRRRRR}RRRRoRRRRRRRRRRRRRRRRRRRRRRRRR(<RRtSTANDARD_OPTIONSRRRRRRRRRRRRRRRRtunittesttskipIftsystplatformRRRRRRRRRRRRRRRRRRRRRRRR R R R R RRRRRRRRR(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyRs                                              tIntegerSizeTestscBseZdZdZRS(cCs)|j}|j|dddddS(Ntheightidii(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_height s cCs)|j}|j|dddddS(Ntwidthiini(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_width s (RRR'R)(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR%s tPixelSizeTestscBseZdZdZRS(c Cs2|j}|j|ddddddddS(NR&idgLY@gfffffY@iit3c(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR's c Cs2|j}|j|ddddddddS(NR(igfffff6y@gIy@init5i(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR)s (RRR'R)(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR*s csfd}|S(NcsxjD]}d|}t|s xkD]5}t||r0t|t||jPq0q0W|fd}||_t||q q WS(Nttest_cs1|j}||td|jfdS(NsOption "%s" is not tested in %s(RtAssertionErrorR(RtoptionR+(tcls(s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR)s (Rthasattrtsetattrtgetattrtim_funcR(R0R/t methodnamet source_classR(tsource_classes(R0s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt decorators    ((R7R8((R7s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pytadd_standard_optionsscCs4tjjr0tj}dG|jddGHndS(Ns patchlevel =tinfot patchlevel(RRRR%tTclR(ttcl((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt setUpModule3s  (R!R#tTkinterR%tttkRttest_ttk.supportRRRRRRttest.test_supportRRHtnoconvt noconv_methRRR RRRR$R RR%R*R9R>(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyts*   .         PK]66READMEnu[Writing new tests ================= Precaution ---------- New tests should always use only one Tk window at once, like all the current tests do. This means that you have to destroy the current window before creating another one, and clean up after the test. The motivation behind this is that some tests may depend on having its window focused while it is running to work properly, and it may be hard to force focus on your window across platforms (right now only test_traversal at test_ttk.test_widgets.NotebookTest depends on this). PK]T+ + runtktests.pyonu[ zfc@sdZddlZddlZddlZddlZddlZejjejj e Z dZ e e ddZe e ddZedkrejjendS(s Use this module to get and run all tk tests. Tkinter tests should live in a package inside the directory where this file lives, like test_tkinter. Extensions also should live in packages following the same rule as above. iNcCs.x'tj|D]}|dkrtSqWtS(Ns __init__.pys __init__.pycs __init.pyo(s __init__.pys __init__.pycs __init.pyo(tostlistdirtTruetFalse(tpathtname((s./usr/lib64/python2.7/lib-tk/test/runtktests.pyt is_packages c #s-dx tj|D]\}}}x4t|D]&}|ddkr2|j|q2q2Wt|r|r|t|ttjjdd}|r||krqntfd|}x[|D]P}y$t j d|t |VWqt j j k r|rqqXqWqqWdS(sThis will import and yield modules whose names start with test_ and are inside packages found in the path starting at basepath. If packages is specified it should contain package names that want their tests collected. s.pyit.t/cs|jdo|jS(Nttest_(t startswithtendswith(tx(tpy_ext(s./usr/lib64/python2.7/lib-tk/test/runtktests.pyt+ts.%sN(RtwalktlisttremoveRtlentseptreplacetfiltert importlibt import_modulettestt test_supporttResourceDenied( tbasepathtguitpackagestdirpathtdirnamest filenamestdirnametpkg_nameR((R s./usr/lib64/python2.7/lib-tk/test/runtktests.pytget_tests_moduless&)   ccsg}|r|jdn|r2|jdnxPtd|d|D]9}x0|D](}xt||dD] }|VqnWqUWqHWdS(sYield all the tests in the modules found by get_tests_modules. If nogui is True, only tests that do not require a GUI will be returned.t tests_noguit tests_guiRRN((tappendR$tgetattr(ttextRRtattrstmoduletattrR((s./usr/lib64/python2.7/lib-tk/test/runtktests.pyt get_tests6s t__main__(t__doc__RtsystunittestRttest.test_supportRRtabspathR"t__file__t this_dir_pathRRtNoneR$R-t__name__Rt run_unittest(((s./usr/lib64/python2.7/lib-tk/test/runtktests.pyts       PK]ptest_ttk/__init__.pycnu[ zfc@sdS(N((((s5/usr/lib64/python2.7/lib-tk/test/test_ttk/__init__.pyttPK]ž''test_ttk/test_extensions.pyonu[ zfc@sddlZddlZddlZddlZddlmZmZmZddl m Z m Z edde ej fdYZ de ej fdYZe efZed kreendS( iN(trequirest run_unittestt swap_attr(tAbstractTkTesttdestroy_default_roottguitLabeledScaleTestcBsGeZdZdZdZdZdZdZdZRS(cCs$|jjtt|jdS(N(troottupdate_idletaskstsuperRttearDown(tself((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR s cCsltj|j}|jj}|j|jtj|j j |tj |j}|j}tj|jd|}|j|j r|j |j j ||jn(|j t|j j ||j~|jtj|j j |tj|j}tj|jd|}|jtj|jd|ttdrh|jtjtjndS(Ntvariablet last_type(tttkt LabeledScaleRt _variablet_nametdestroyt assertRaisesttkintertTclErrorttkt globalgetvart DoubleVart wantobjectst assertEqualtgettfloattIntVarthasattrtsystassertNotEqualR (R txtvartmyvartname((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_widget_destroys&     %( c CsttddttdtizYtj}|jtj|j|j tj|j|j tjj |j Wdt XWdQXWdQXdS(Nt _default_roott_support_default_root( RRtNonetTrueRRtassertIsNotNoneR&RtmasterRRR(R R!((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_initialization_no_master2s cstjj}tj|}j|j||jddddtj dtj dff}j r}|d7}nxK|D]C}tjjd|d}j|j |d|jqWtjjdd }j t |jj|jtjjdd}j t |jj|jtjjd d }tjjd |}j|j d|jtjjd |dd }j|j d j|jj|j|jfd}tjjdd}||jd|jd|jtjjdd}||jd|jd|jtjjdd}||jd|jd|jtjj}||jd|jd|jj tjtj|dddS(Nt0ii iig@itfrom_s2.5tvalueiR g?cs8j|jd|j|jd|dS(Ntsidetanchor(Rt pack_infot place_info(tscalet scale_postlabelt label_pos(R (s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pytcheck_positionsastcompoundttoptbottomtntstunknowntatb(R-i(ii(i i (ii(g@i((g@i(RtFrameRRRRR+RRtmaxintRR/Rt ValueErrorRRR(RRR4R6R(R R+R!tpassed_expectedtpairR#R8((R s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_initialization?sP              cCs^tj|jdddd}|j|j|j|jj}|jj d}|j |t |d|jj dddd|j|jj d}|j |||jj}|j |jd|jrdnd |j |t |d|jj dddd|j |||j |t |d|jdS( NR.ittoi R!iittextR-(RRRtpacktwait_visibilitytupdateR6R3R4tcoordsRtintt configureR RR(R tlscaletlinfo_1t prev_xcoordt curr_xcoordtlinfo_2((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_horizontal_rangevs$    &cCsvtj|j}|j|j|j|jjd}|jd}||_|j|j |j d|j r|n t ||j |jjd||j |jjdt|j jd|j rd}nt}||jdd|_|j|j ||j d||j |jjdt|j jd|jdS(NiiRHR!cSs|S(N((R!((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttRG(RRRRIRJRKR4RLR/RR6Rtstrt assertGreaterRMR3R(R R!RRtnewvaltconv((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_variable_changes,         cCstj|j}|jdtdd|j|j|jj|jj }}|d|d}}d|_ |j|jj d||f|j t |jjd|jjd|jj d||f|jdS( Ntexpandtfilltbothiis%dx%dR!i(RRRRIR)RJRKR+t winfo_widtht winfo_heightR/t wm_geometryRRMR6R3R4RLR(R R!twidththeightt width_newt height_new((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyt test_resizes    ( t__name__t __module__R R%R,RFRTR[Rf(((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR s  " 7  tOptionMenuTestcBs>eZdZdZdZdZdZdZRS(cCs,tt|jtj|j|_dS(N(R RitsetUpRt StringVarRttextvar(R ((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyRjscCs|`tt|jdS(N(RlR RiR (R ((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR scCstj|j}tj|j|}|j}|j|j|j|j j ||j ~|j tj |j j |dS(N(RRkRRt OptionMenuRRRRRRRRR(R R"toptmenuR$((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR%s   "cCs|jtjtj|j|jddtj|j|jddd}|j|jj d|j |d|j |d|j dS(NtinvalidtthingR@R?tmenut textvariable( RRRRRmRRlRRRt assertTrueR(R Rn((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyRFs !c s7d d}tjjj|}t}xYttD]E}|dj|d}j||||krCt }qCqCWj ||j d}tjjj|}d}d}xQt r&||dj |d}}||kr Pnj|||d7}qWj|t|j|j|djdj|jjdjtj|djd j|jjd|j gfd }tjjjdd |}|djds)jd n|j dS(NR?R@tcRqR/tdiiics%j|djtdS(Ni(RtappendR)(titem(titemsR tsuccess(s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pytcb_teststcommandsMenu callback not invoked(R?R@Rt(RRmRRltFalsetrangetlent entrycgetRR)RsRR(tentryconfigureR RIRJtinvokeRRRRRtfail( R tdefaultRnt found_defaulttiR/tcurrtlastRz((RxR Rys</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyt test_menusJ          cCs;d }d}tj|j|j||}tj|j}tj|j|||}|j|j|j|j|djd|djd|dj dd}|dj dd}|j |||j |jj j ||d|j |jj j ||d|j|jdS( NR?R@RtRqiiiR (R?R@Rt(RRmRRlRRkRIRJRRR RRRR(R RxRRnttextvar2toptmenu2toptmenu_stringvar_nametoptmenu2_stringvar_name((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_unique_radiobuttonss*        (RgRhRjR R%RFRR(((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyRis    4t__main__(RtunittesttTkinterRRttest.test_supportRRRttest_ttk.supportRRtTestCaseRRit tests_guiRg(((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyts     q  PK]ptest_ttk/__init__.pyonu[ zfc@sdS(N((((s5/usr/lib64/python2.7/lib-tk/test/test_ttk/__init__.pyttPK]8test_ttk/test_widgets.pycnu[ zfc@sUddlZddlZddlmZddlZddlmZmZmZm Z ddl Z ddl m Z ddl mZmZmZmZddlmZmZmZmZmZmZmZmZeddefd YZd eejfd YZd eefd YZeedeejfdYZeedeejfdYZ defdYZ!eede!ejfdYZ"eede!ejfdYZ#eede!ejfdYZ$eeedeejfdYZ%eeede%ejfdYZ&eeedeejfdYZ'eed e!ejfd!YZ(d"e!ejfd#YZ)eed$eejfd%YZ*eed&eejfd'YZ+ej,e j-d(kd)eed*eejfd+YZ.eeed,eejfd-YZ/eed.eejfd/YZ0eed0eejfd1YZ1eed2eejfd3YZ2e#e$e&e%ee e"e)e/e'e+e(e*e.e1e2e0efZ3e4d4krQee3ndS(5iN(tTclError(trequirest run_unittestt have_unicodetu(t MockTclObj(tAbstractTkTestt tcl_versiontget_tk_patchleveltsimulate_mouse_click(tadd_standard_optionstnoconvt noconv_methtAbstractWidgetTesttStandardOptionsTeststIntegerSizeTeststPixelSizeTestst setUpModuletguitStandardTtkOptionsTestscBs#eZdZdZdZRS(cCs|j}|j|ddd}td kr>d }n|j|dd d ||jd d }|j|dd dS(Ntclassts"attempt to change read-only optioniiitbetais"Attempt to change read-only optiontFooterrmsgtclass_(iiiRi(tcreatet assertEqualRtcheckInvalidParam(tselftwidgetRtwidget2((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_classs  c Cs|j}|j|dddd|j|dddd|j|dddd|j|dddd|j|dddd|j|dd|j|dddddS(Ntpaddingitexpectedt0it5it6it7it8t5pt6pt7pt8pR(R#(R$(ii(R$R%(iii(R$R%R&(iiii(R$R%R&R'(R(R)R*R+((Rt checkParam(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_paddings cCs|j}|j|ddd}t|drQdt|dj}n|j|ddd||jdd}|j|d ddS( NtstyleRsLayout Foo not foundtdefault_orientsLayout %s.Foo not foundRRRR(RRthasattrtgetattrttitleR(RRRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_style+s (t__name__t __module__R R-R3(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs t WidgetTestcBs)eZdZdZdZdZRS(s,Tests methods available in every ttk widget.cCsRtt|jtj|jdddd|_|jj|jjdS(NtwidthittexttText( tsuperR6tsetUptttktButtontrootRtpacktwait_visibility(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;=s! cCs|jj|j|jj|jjd|jjdd|j|jjddd|jtj|jjdd|jtj|jjdd|jtj|jjdddS(NitlabeliRi( Rtupdate_idletasksRtidentifyt winfo_widtht winfo_heightt assertRaisesttkinterRtNone(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_identifyDs cCs|j|jjd |j|jjdgt|j|jjdgd |j|jjdgd |j|jjddgd |j|jjddgd|j|jjddgdd}|j|jjdg|didd6didd6f|jj}|jtj|jjd g|jtj|jjdd g|j||jj|jjddg|j|jjddS(Ns !disabledtdisabledtactives!activec[s ||fS(N((targ1tkw((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_cbasthittheretmsgtbadstate((s !disabled((s!activeRJ(((RK(RRtstatetinstatetTrueRFRGR(RRNt currstate((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_widget_stateQs(""   (R4R5t__doc__R;RIRW(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR6:s  tAbstractToplevelTestcBseZeZRS((R4R5R t _conv_pixels(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRYust FrameTestc BseZd Zd ZRS( t borderwidthRtcursortheightR!treliefR.t takefocusR7cKstj|j|S(N(R<tFrameR>(Rtkwargs((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs( R\RR]R^R!R_R.R`R7(R4R5tOPTIONSR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR[ystLabelFrameTestc Bs)eZdZd ZdZdZRS(R\RR]R^t labelanchort labelwidgetR!R_R.R`R8t underlineR7cKstj|j|S(N(R<t LabelFrameR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs]|j}|j|ddddddddd d d d d dd|j|dddS(NRetetentestntnetnwtstsetswtwtwntwsRs!Bad label anchor specification {}tcenter(RtcheckEnumParamR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_labelanchors   'cCsQ|j}tj|jdddd}|j|d|dd|jdS(NR8tMupptnametfooRfR"s.foo(RR<tLabelR>R,tdestroy(RRRA((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_labelwidgets ( R\RR]R^ReRfR!R_R.R`R8RgR7(R4R5RcRRwR}(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRds  tAbstractLabelTestcBs,eZdZdZdZdZRS(cCstjd|jdd}tjd|jdd}|j|||dd |j||ddd |j|||fdd |j|||d|fdd|j||ddd|j||dd d dS(NtmasterRytimage1timage2R"RKsimage1 active image2tspamRsimage "spam" doesn't exist(R(R(R(RRKR(RRKR(RGt PhotoImageR>R,R(RRRytimageR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytcheckImageParamsc Cs8|j}|j|ddddddddd dS( NtcompoundtnoneR8RRuttoptbottomtlefttright(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_compounds   cCs)|j}|j|dddddS(NRSRKRJtnormal(Rt checkParams(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_states cCs)|j}|j|dddddS(NR7iini(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_widths (R4R5RRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR~s  t LabelTestcBs&eZdZeZdZdZRS(tanchort backgroundR\RRR]tfontt foregroundRtjustifyR!R_RSR.R`R8t textvariableRgR7t wraplengthcKstj|j|S(N(R<R{R>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs#|j}|j|dddS(NRs3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*(RR,(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_fonts  (RRR\RRR]RRRRR!R_RSR.R`R8RRgR7R(R4R5RcR RZRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs t ButtonTestcBs)eZdZdZdZdZRS(RtcommandRR]tdefaultRR!RSR.R`R8RRgR7cKstj|j|S(N(R<R=R>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs)|j}|j|dddddS(NRRRKRJ(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_defaults csBgtj|jdfd}|j|jdS(NRcs jdS(Ni(tappend((tsuccess(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytR(R<R=R>tinvoket assertTrue(Rtbtn((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_invokes! (RRRR]RRR!RSR.R`R8RRgR7(R4R5RcRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs  tCheckbuttonTestcBs2eZdZdZdZdZdZRS(RRRR]RtoffvaluetonvalueR!RSR.R`R8RRgtvariableR7cKstj|j|S(N(R<t CheckbuttonR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs,|j}|j|ddddddS(NRigffffff@Rs any string(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_offvalues cCs,|j}|j|ddddddS(NRigffffff@Rs any string(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_onvalues csgfd}tj|jd|}|j|jd |jtj|jj |d|j }|j|d|j|d|jj |d|j d|d<|j }|j t ||jtd|j|d |jj |ddS( NcsjddS(Niscb test called(R((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytcb_tests Rt alternateRscb test calledRRiR(R(R<RR>RRSRFRGRttkt globalgetvarRRt assertFalsetstrtassertLessEqualtlen(RRtcbtntres((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs"       (RRRR]RRRR!RSR.R`R8RRgRR7(R4R5RcRRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs   t EntryTestcBszeZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZRS(RRR]texportselectionRRtinvalidcommandRtshowRSR.R`RtvalidatetvalidatecommandR7txscrollcommandcCs&tt|j|j|_dS(N(R:RR;Rtentry(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;#scKstj|j|S(N(R<tEntryR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR'scCs |j}|j|ddS(NR(RtcheckCommandParam(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_invalidcommand*s cCsI|j}|j|dd|j|dd|j|dddS(NRt*Rt (RR,(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_show.s cCs)|j}|j|dddddS(NRSRJRtreadonly(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR4s  c Cs2|j}|j|ddddddddS(NRtalltkeytfocustfocusintfocusoutR(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_validate9s  cCs |j}|j|ddS(NR(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_validatecommand>s cCsU|j|jjd|jtj|jjd|jtj|jjddS(Nitnoindex(tassertIsBoundingBoxRtbboxRFRGRRH(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_bboxCscCs|jj|jj|jjtjdkrX|j|jjdddn|j|jjddd|j|jjddd|j t j |jjdd|j t j |jjdd|j t j |jjdddS(NtdarwinittextareasCombobox.buttoniR(RsCombobox.button( RR?R@RBtsystplatformtassertInRCRRFRGRRH(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRIIs    cs#gfd}d|jd(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRsc Cs2|j}|j|ddddddddS(NR^idgLY@gfffffY@iit1i(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_heights cCs`|jj}|jjdd|ddd|jjdd|ddd|jjdS(Nstxitys(RRDtevent_generateRB(RR7((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt_show_drop_down_listboxs  csgdg|jd<|jjdfd|jj|jj|jj}|j|jj|jjd|jj|jdS(NiRs<>cs jtS(N(RRU(tevt(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRs( RtbindR?R@RERtupdateRR(RR^((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_virtual_events      cs~gfd|jd<|jj|jj|j|jd|jd<|j|jtddS(Ncs jtS(N(RRU((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRRRi(RR?R@RRRR(R((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_postcommands      c sfd}jjdtd#kr1d$nd|ddjjdddd%jjdd&jjdd'jjdtd(krd)nddddgjd<jjd|ddjjd|ddjjd|ddjjdd*jd<|ddjjddddgjjdjrd+nddddgjd<jjdjrd,ndddd gjd<jjdjrd-nd!jt j jjt jdjt j jjdt j jddddg}j|djrd.nd"|jdS(/Ncs6jjj|jjj|dS(N(RRRtcurrent(tgetvaltcurrval(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytcheck_get_currentsRiiRismon tue wed thurR"tmonttuetwedtthuri*gQ @s any stringRitciitdit1t2s1 {} 2sa bsa bsa bs{a b} {a b} {a b}sa\tbs"a"s} {sa\\tb {"a"} \}\ \{s1 2 {}(ii((RRRR(RRRR(i*gQ @Rs any string(ii((iiRi(RRR(sa bsa bsa b(sa\tbs"a"s} {(RRR(RRRR,tsetRt configuret wantobjectsRFRGRRR<RR>R|(RRtcombo2((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_valuessL (     ! (RRR]RRRR^RRRRRSR.R`RRRRR7R( R4R5RcR;RRRRRR (((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs      tPanedWindowTestcBsVeZdZdZdZd Zd Zd Zd Zd Z dZ RS(RR]R^torientR.R`R7cCs&tt|j|j|_dS(N(R:R R;Rtpaned(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;&scKstj|j|S(N(R<t PanedWindowR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR*scCs|j}|jt|ddd}td krDd }n|j|dd d ||jdd }|jt|dd dS( NR tverticals"attempt to change read-only optioniiiRis"Attempt to change read-only optiont horizontalR(iiiRi(RRRRR(RRRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_orient-s  cCsztj|j}tj|}|jtj|jj||j|jtj|j}tj|}|jtj|jj||j|jtj|j}|jj||jtj|jj|tj|j}|jj||j |jj d|jj d|jtj|jj d|j|j|jtj|jj ddS(Niii( R<R{R RFRGRtaddR|R>Rtpane(RRAtchildt good_childt other_child((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_add8s(    (  cCs|jtj|jjd|jtj|jjd|jjtj|j |jjd|jtj|jjddS(Ni( RFRGRR tforgetRHRR<R{R>(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_forgetTs cCs|jtj|jjdd|jtj|jjdd|jtj|jjddtj|j}tj|j}tj|j}|jtj|jjd||jjd||jjd||j |jj t |t |f|jjd||j |jj t |t |f|jjd||j |jj t |t |t |f|jj }|jjd||j ||jj |jj|||j |jj t |t |t |fdS(NiR( RFRGRR RRHR<R{R>RtpanesR(RRtchild2tchild3R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_insert]s*++"cCs |jtj|jjdtj|j}|jj||j |jjdt |j |jjddd|j rdnd|j |jjdd|j rdnd|j |jjd|jjt||jtj|jjddddS(NitweightR#t badoptiont somevalue(RFRGRR RR<R{R>RtassertIsInstancetdictRRHRR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_panes.cCsi|jtj|jjd|jtj|jjd|jtj|jjdtj|jdd}|jj|dd|jtj|jjdtj|jdd}|jj||jtj|jjd|jj dt d d |jj |jjd}|jjdd |j ||jjd|j |jjdtdS( NRiR8RRitbtexpandtfilltbothi(RFRGRR tsashposRHR<R{RR?RUR@tassertNotEqualR tint(RRRtcurr_pos((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_sashposs (RR]R^R R.R`R7( R4R5RcR;RRRRRR"R+(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR s    # tRadiobuttonTestcBs)eZdZdZdZdZRS(RRRR]RR!RSR.R`R8RRgtvalueRR7cKstj|j|S(N(R<t RadiobuttonR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs,|j}|j|ddddddS(NR-igffffff@Rs any string(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_values csgfd}tj|j}tj|jd|d|dd}tj|jd|d|dd}|jrd}nt}|j}|j|d|j||d|j |j|j ||j j |d|j d |d<|j}|jt |d |jtd|j||d|j |j|j ||j j |d|jt |dt |ddS( NcsjddS(Niscb test called(R((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs RRR-iicSs|S(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRscb test calledR(RGtIntVarR>R<R.RR)RRRRRRRRR(RRtmyvarRtcbtn2tconvR((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs0        (RRRR]RR!RSR.R`R8RRgR-RR7(R4R5RcRR/R(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR,s  tMenubuttonTestcBs)eZdZdZdZdZRS(RRR]t directionRtmenuR!RSR.R`R8RRgR7cKstj|j|S(N(R<t MenubuttonR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs/|j}|j|dddddddS(NR5tabovetbelowRRtflush(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_directions  cCsH|j}tj|dd}|j|d|dt|jdS(NRyR6R3(RRGtMenuR,RR|(RRR6((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_menus (RRR]R5RR6R!RSR.R`R8RRgR7(R4R5RcRR;R=(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR4s  t ScaleTestc BskeZdZeZd Zd Zd ZdZdZ dZ dZ dZ dZ dZRS(RRR]tfromtlengthR R.R`ttoR-RRcCs@tt|j|j|_|jj|jjdS(N(R:R>R;RtscaleR?R(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;s cKstj|j|S(N(R<tScaleR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs/|j}|j|dddddtdS(NR?idg-@g333333.@R3(RtcheckFloatParamR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_froms cCs,|j}|j|ddddddS(NR@igffffff`@g33333`@t5i(RtcheckPixelsParam(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_lengths c Cs2|j}|j|ddddddtdS(NRAi,g-@g333333.@iR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_to s c Cs2|j}|j|ddddddtdS(NR-i,g-@g333333.@iR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR/s csdddg|jjdfd}d|jd>cs jS(N(tpop(R(tfailure(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRi R?tfrom_iRAiiii(RBRRR(Rtfuncid((RKs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_custom_events    cCs|jrd}nt}|jj}|j|jj|d|jd|j||jjdd||jd|j|jj|jdd|jd<|j|jj|jd|jtj|jjdd|jtj|jjdddS(NcSs|S(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR(RiRAR?R-iR( RtfloatRBRDRRRFRGR(RR3t scale_width((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_get&s  &2   cCs|jrd}nt}||jd}|d}|jj||j||jj|||jd}|jj|d|j||jj|tj|j}||jd<|j|d|j||jj|j|j||jj|d~|d|jd<|j||jj|d|j||jj||jd|j||jjd d ||j||jj|jj d ||j tj |jjddS( NcSs|S(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR:RRAi R?iRiR-i( RRORBRRRRGt DoubleVarR>RDRFRRH(RR3tmaxtnew_maxtmintvar((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_set8s,    %##,%.( RRR]R?R@R R.R`RAR-R(R4R5RcR RZR/R;RRERHRIR/RNRQRW(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR>s        tProgressbarTestc BsPeZdZeZd Zd Zd ZdZdZ dZ dZ RS(RR]R R@tmodetmaximumtphaseR.R`R-RRcKstj|j|S(N(R<t ProgressbarR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRfscCs)|j}|j|dddddS(NR@gfffffY@gYL@t2i(RRG(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRHis c Cs2|j}|j|ddddddtdS(NRZgfffffb@glS@iiR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_maximumms cCs&|j}|j|ddddS(NRYt determinatet indeterminate(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_modeqs cCsdS(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_phaseusc Cs2|j}|j|ddddddtdS(NR-gfffffb@glS@iiR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR/ys ( RR]R R@RYRZR[R.R`R-R( R4R5RcR RZR/RRHR^RaRbR/(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRX\s     Rs"ttk.Scrollbar is special on MacOSXt ScrollbarTestcBseZdZdZdZRS( RRR]R R.R`RcKstj|j|S(N(R<t ScrollbarR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs(RRR]R R.R`(R4R5RcR/R(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRcst NotebookTestcBsqeZdZdZdZd Zd Zd Zd Zd Z dZ dZ dZ dZ RS(RR]R^R!R.R`R7cCstt|j|jdd|_tj|j|_tj|j|_ |jj |jdd|jj |j dddS(NR!iR8RR#( R:ReR;RtnbR<R{R>tchild1RR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;s cKstj|j|S(N(R<tNotebookR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs|jjd|jj|j|jtj|jj|j|j |jj dd|jj |j|j |jj dd|jj |j|j |jjd|jj |jdd|jj|jjtjdkrd}nd }|j |jj||jjdxhtd d d D]G}y*|jjd |dddkrtPnWqEtjk rqEXqEW|jd dS(NiRiRR8RRs@20,5s@5,5iids@%d, 5sTab with text 'a' not found(RfRthideRRFRGRttabRgRtindexRtselectRR?R@RRtrangeRHtfail(Rttb_idxti((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_tab_identifierss,   ("cCs|jtj|jjd|jtj|jjd|jtj|jjd|jtj|jjd|jtj|jjtj|j dd|jj }|jj|j |jj|j |j |jj |tj|j }|jj|dd|jj }|jj d}|jj |j}|jj|j|jj|j|j |jj ||j |jj |j||j t|j|jj ||j |jj d|ddS( NiROtunknowntoptionR8RRi(RFRGRRfRiRHRR<R{R>ttabsRgRRkRR(RRtRtcurrt child2_index((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_add_and_hiddens*'&cCs+|jtj|jjd|jtj|jjd|jtj|jjd|jj}|jj|j}|jj|j|j t |j|jj|j t |dt |jj|jj |j|j |jj|jd|j||jj|jdS(NiROi(RFRGRRfRRHRtRkRgt assertNotInRRRRR((RRtt child1_index((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs")cCs|jtj|jjd|jtj|jjd|j|jjdt|j|jj|j d|j|jj|j d|j|jjdddS(NiRiii( RFRGRRfRkRHR R)RRgR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_indexs cCs|jj}|jjd|d|j|jj|d|df|jj|j|j|j|jj||jjd|j|j|jj|d|df|jjdd|j|jj||jtj|jjd|d|jtj|jjd|dt j |j }|jjd||j|jj|dt ||df|jj ||j|jj||jj|j||j|jjt |f||jj ||jtj|jjd||jtj|jjd||jtj|jjdd|jtj|jjdd|jtj|jjdddS(NiiRii(RfRtRRRgRRFRGRR<R{R>RRRH(RRtR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs0''##0&cs|jj|jjgg|jjdfd|jjdfd|j|jjt|j|jj|j|j |j|jjt|j|jj |j dS(Nscs jtS(N(RRU(R(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRs<>cs jtS(N(RRU(R(t tab_changed(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRR( RfR?R@RgRRRlRRRR(R((RR{s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_selects   " " cCs|jtj|jjd|jtj|jjd|jtj|jjd|j|jj|jt|j |jj|jddd|j |jj|jdd|jj|jdd|j |jj|jddd|j |jj|jdddS(NitnotabR8Rtabc( RFRGRRfRjRHR RgR!R(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_tab(s%"%cCsb|jt|jjd|jj|j|jj|j|j|jjddS(Ni((RRRfRtRRgR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_tabs6scCs|jj|jj|jjdt|jdd|jj|jjd|j|jjt|j |jj|jjd|j|jjt|j |jj|jjd|j|jjt|j |jj |j dddd|jj |jjt|jddt jdkrh|jjd n|jjd |j|jjt|j dS( Niis sR8RRgRs s(RfR?R@RlR t focus_forceRRRRRgRjtenable_traversalRR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_traversal?s*   " " "  (RR]R^R!R.R`R7(R4R5RcR;RRqRwRRzRR|RRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRes      !   t TreeviewTestc BseZd#Zd Zd ZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZd Zd!Zd"ZRS($RtcolumnsR]tdisplaycolumnsR^R!t selectmodeRR.R`RtyscrollcommandcCs,tt|j|jdd|_dS(NR!i(R:RR;Rttv(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;cscKstj|j|S(N(R<tTreeviewR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRgscCsa|j}|j|dddd |j|dd |j|dtd krVd nd dS(NRsa b cR"RR#RiiR(RR#R(RR#R(ii((RR,R(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_columnsjs  cCs|j}d|d<|j|dddd|j|dd|j|dddd|j|dd|j|ddd d|j|ddd d|j|ddd ddS(NRR#RRRsb a cR"s#alliiiRRsInvalid column index disColumn index 3 out of boundsisColumn index -2 out of bounds(RR#R(R#RR(R#RR(s#all(iii(RR#R(iii(ii(RR,R(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_displaycolumnsqs  c CsN|j}|j|ddddddt|j|ddddtdS( NR^idiit3cR3gLY@gfffffY@(RRGRR (RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs "cCs)|j}|j|dddddS(NRRtbrowsetextended(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_selectmodes  cCs|j}|j|dddd|j|dd|j|dd|j|dddd |j|dddd dS( NRs tree headingsR"ttreetheadings(RR(RR(RR(R(R(RR,(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs cCsW|jj|j|jjdd|jj|jj|jjdd}|jj}|j||jj|d}|j |dg|jd<|jj ddd|jj|dd}|jj ddd}|j st |}n|j|d|d||jj|d}|j|jj|ddS( NRRittestRR7i2s#0(RR?RRR@RRt get_childrenRRtcolumnRHRR)(Rtitem_idtchildrenRt bbox_column0t root_widthRg((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs$      cCs>|j|jjd|jjdd}|j|jjt|j|jjd||jjdd}|jjdd}|jj||||j|jj|||f|jtj |jj|||jj||j|jj|d|jjd|j|jjddS(NRRi(((( RRRRR ttuplet set_childrenRFRGR(RRRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_childrens" cCsi|j|jjdt|jrJ|j|jjdddtn|jjddd|j|jjdd|jrdnd|j|jjddd|jrdnd|jt j |jjddd|jt j |jjdidd 6id d 6id d 6id d6id d 6g}x-|D]%}|jt j |jjd|q<WdS(Ns#0R7i t10tidtXRs some valuetunknown_optiontwrongtstretchRtminwidth( R RRR!RRHR)RRFRGR(Rt invalid_kwsRM((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_columns %"$ cCs?|jtj|jjd|jjdd}|jj|d}|j|jj|f|j|jj||f|jj||j|jj|jtj|jj |dd|jjdd}|jjdd}|j|jj||f|jj|||j|jjdS(Ns#0RR( RFRGRRRRRRRtreattach(RRtitem2titem1((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_deletes cCs0|jjdd}|jj|d}|jj}|jj|j||jj|j|jj|f|j|jj||f|jj||j|jj|jj|dd|j|jj|f|j|jj||f|jj|dd|j|jj||f|j|jj|d|jt j |jjddd|jt j |jjd|jt j |jj|dd|jt j |jj|dd|jj|||j|jjd|j|jj|ddS( NRRt nonexistentt otherparentR(((( RRRtdetachRRRtmoveRFRGR(RRRtprev((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_detach_reattachs4     cCst|j|jjdt|j|jjdt|j|jjit|jtj|jjddS(Nt somethingR( RRtexistsRRURFRGRRH(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_exists'scCs|j|jjd|jjdd}|jj||j|jj||jj||j|jjd|jtj|jjddS(NRRRO(RRRRRRFRGR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_focus2scCs|j|jjdt|jjddd|j|jjddd|j|jjdddd|jtj|jjddd|jtj|jjddddS(Ns#0R8RORRi( R RtheadingR!RRHRFRGR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_headingAs"csfd}gjjjjjjddfdjjdddjj|ddsjdngjjj}jjddt jjdddj |jjj|ddsjdndS( Ncs$tj||jjdS(N(R RR(RR(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytsimulate_heading_clickRss#0Rcs jtS(N(RRU((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRZRR7idis>The command associated to the treeview heading wasn't invoked.( RR?R@RRRRnRt _tclCommandsRRHR(RRtcommands((RRs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_heading_callbackQs"    . cCs|jtj|jjd|j|jjdd|jjdd}|jjdd}|jj|d}|jj|d}|j|jj|d|j|jj|d|j|jj|d|j|jj|d|jj|dd|j|jj|d|j|jj|d|jj||j|jj|d|jj||j|jj|d|jj ||jtj|jj|dS(NtwhatRiRi( RFRGRRRkRRRRR(RRRtc1tc2((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRzss&cCs|jtj|jjdd|jtj|jjdddd|jtj|jjdddd|j|jj|jjdddt|j|jj|jjdddt|jtj|jjdd|jjddd}|j |d|jtj|jjddd|jtj|jjddt dd}|jjddd |f}|j |jj |d |j r|fn||j |jj |d d|j r|fn||jj |d |jj|jj |d d|j |jj |d d|j r@|fn||j|jj |t|jj |d d|j|jj |d d|jjddd d d |g}|j |jj |d d|j rd d|fnd||jj |d g|j|jj |d d|jj |d d|j |jj |d d|j rodnd|jjddd dd||ff}|j |jj |d d|j rdd||ffn d||f|j |jj |jjddddddd|j |jj |jjddd|dd||jjddd}|j |d|jjddd}|j |d|jtj|jjddt|jtj|jjddddS(NRRRtopentpleasetmiddles first-itemuábaRttagsiiRRs1 2 %ss1 2sa b cs%s %ss{a b c} {%s %s}R8s Label hereiR#gs0.0(ii(RR(RFRGRRRRRRURRRtitemRRHR>t splitlistR R!(RtitemidR-R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_insert_itemsh.. 4$ !!"cCs|jtj|jjd|jtj|jjd|jtj|jjd|jtj|jjd|jjdd}|jjdd}|jj|d}|jj|d}|jj|d}|j |jj d |jj||f|j |jj ||f|jj||j |jj |f|jj||f|j |jj |||f|jj||j |jj ||||f|jj||f|j |jj |||f|jj||j |jj ||f|jj||f|j |jj ||f|jj||j |jj |f|jjdddd|jjd|j |jj d |jjdddd|jjd|j |jj d t rl|jjdddt d|jjt d|j |jj t dfn|jjdddd|jjd|j |jj t rt d ndfdS( NRRRRs with spacess{braces unicode\u20acsbytes€s bytes\u20ac((s with spaces(s{brace( RFRGRRt selection_sett selection_addtselection_removetselection_toggleRRt selectionRR(RRRRRtc3((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_selectionsR"%"%cCsPddg|jd<|jjdddddg}|j|jj|idd6dd6|jj|dd|j|jj|dd|jrdnd dg|jd<|j|jj|idd6|jj|dd|j|jj|d dd|j|jj|dd|jr:dnd |jj|dd |j|jj|d|jr~d nd |j|jj|dd|jrdnd|j|jj||jrid d6n id d6|jtj |jj|d|jtj |jj|dd|jtj |jjddS(NtAtBRRRRRR#sa aRsb ai{t123s123 atnotme(RR(R#R(i{R( RRRRRRHRRFRGR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRWs,!*#"$"c sg|jjddddg}|jjddddg}|jjddfd|jjddfd|jj|jj|jjt}t}xqtd d d D]]}t|d krPn|jj |}|r||kr|j ||j |qqW|j t|d x!|D]}t |jd |qJW|j td xAt ddd ddd D]}|j |dqWdS(NRRRtcallscs jdS(Ni(R(R(tevents(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;Rscs jdS(Ni(R(R(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR=Riidi iii(ii(RRttag_bindR?R@RRRmRt identify_rowRRR tzip( RRRtpos_ytfoundRpRRR((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_tag_bind6s2       0cCs|jt|jj|jtj|jjddd|jjddd|jt|jjddd|jt|jjdddd|j |jjdt dS(NRtskytblueR( RFt TypeErrorRt tag_configureRGRRRRHR R!(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_tag_configureXs !cCs|jjddddddg}|jjddddddg}|jt|jj|jt|jjdd |j|jjd||j|jjd||j|jjd||j|jjd||j|jjd ||j|jjd ||j|jjd|f|j|jjd|f|j|jjd d dS( NRRR8sItem 1Rttag1sItem 2ttag2s non-existingttag3(( RRRFRttag_hasRRRR(RRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_tag_hasds$$( RRR]RR^R!RRR.R`RR(R4R5RcR;RRRRRRRRRRRRRRRRzRRRWRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR[s4           *   "  M 6 ! " t SeparatorTestcBseZdZdZdZRS(RR]R R.R`RcKstj|j|S(N(R<t SeparatorR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR|s(RR]R R.R`(R4R5RcR/R(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRtst SizegripTestcBseZdZdZRS(RR]R.R`cKstj|j|S(N(R<tSizegripR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs(RR]R.R`(R4R5RcR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRst__main__(5tunittesttTkinterRGRR<ttest.test_supportRRRRRttest_functionsRtsupportRRRR t widget_testsR R R R RRRRRtTestCaseR6RYR[RdR~RRRRRR R,R4R>RXtskipIfRRcReRRRt tests_guiR4(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytsr   " ": ';     0| 3 j "          PK]d67>>test_ttk/test_functions.pyonu[ zfc@sddlZddlZddlZdfdYZdefdYZdefdYZdejfd YZd ejfd YZ ee fZ e d krdd l m Z e e ndS(iNt MockTkAppcBseZdZdZRS(cCs t|tr|S|jdS(Nt:(t isinstancettupletsplit(tselftarg((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt splitlistscCstS(N(tTrue(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt wantobjects s(t__name__t __module__RR (((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRs t MockTclObjcBs eZdZdZdZRS(ttestcCs ||_dS(N(tval(RR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt__init__scCs t|jS(N(tunicodeR(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt__str__s(R R ttypenameRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyR s t MockStateSpeccBs eZdZdZdZRS(t StateSpeccGs ||_dS(N(R(Rtargs((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRscCsdj|jS(Nt (tjoinR(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyR!s(R R RRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRs tInternalFunctionsTestcBsbeZdZdZdZdZdZdZdZdZ dZ d Z RS( cs fd}jtji|tjidd6ddddgd6idd 6d d 6|tjidBd6idd6|tjiidd6d6iidd6d6|tjiddd dd gd6dd6d d6dd6dd6dd6dd6dtid d6d!d"6dd#6d$d%6d&d'6d(d)6d*d+6itd,6td-6}|j}|tj|itd.6td/6j|||tjidCd26id3d46|tjidDd26id6d46|tjidEd26id8d46|tjidFd26id:d46|tjidGd26id=d46|tjidHd26id?d46ttj|d@d-d}j|t|dttj|d@dId}j|t|djtj|d@|jdS(JNcsfxEtdt|dD]+}j|j||||dqW|rbjd|ndS(Niiisresult still got elements: %s(trangetlent assertEqualtpoptfail(tfmt_optstresultti(R(s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt check_against(s)tbluetfgiiiitpaddings-fgs1 2 3 4s-paddingtiR s1 2 {} 0s-testsas istleftit2mttest2ttest3sabc defttest4s"abc"ttest5s{}ttest6s } -spam {ttest7tscripts{1 -1 {} 2m 0}t3s-test2s-test3s {abc def}s-test4s{"abc"}s-test5s\{\}s-test6s \}\ -spam\ \{s-test7uαβγuáu-αβγu-ásone twotthreetoptions{one two} threes-optionsone twos{one two} threetones{} ones one} {twosone\}\ \{two threes"one"ttwos {"one"} twos{one}s \{one\} twotignoretb(iiR%i(sone twoR0(sone twoR0(R%R2(s one} {twoR0(s"one"R3(s{one}R3(uáR5( t assertFalsetttkt_format_optdictRtFalsetcopyRRtkeys(RR!toptst orig_optst amount_opts((Rs;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_optdict'sl&   $      cCsid!d"d#gd6}tj|}|jt|t|jd |j|d$|jtj|d td%|jtjigd 6d&id'gd6}tj|}|j|d(id)gd6}|jtj|d*id+gd6}|jttj|idgddfgd6}|jttj|iddggd6}|jtj|d,xOddt dt fD]5}i|dfgd6}|jtj|d-qWidd6}|jttj||jt tjid.gd6dS(/NR5tcRtdtothervalR%tsingletais-as{b c} val d otherval {} singleR.s {{b c} val d otherval {} single}s-2uáuvãlu üñíćódèu-üñíćódèuá vãluthitopts-opts{ } hiis valid valt2tvalues1 valueis{} valuetinvalid(R5R@R(RARB(R%RC(s-as{b c} val d otherval {} single(s-as {{b c} val d otherval {} single}(s-2R%(uáuvãl(u-üñíćódèuá vãl(R%uRE(s-opts{ } hi(iis valid val(s-opts1 value(s-opts{} value(RI( R7t_format_mapdictRRR;Rt assertRaisest TypeErrortNoneR9tsett IndexError(RR<RtvalidRItstateval((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_mapdicts4&   c Cs|jtjddd f|jttjd|jtjdtddd!f|jtjdtdd"dd#f|jtjdtdd$d d%ftjdtdd&dd dd }|j|d d |jt|ddd dd h|jtjdt dd'd ddgd(|jt tjd|jtjdtdddd)f|jtjdtddd*dd+f|jtjdtddd,dd dd-f|jtjdt ddddddgfdd d.|jttjd|jtjdtddd/f|jtjdtdddd0f|jtjdt ddd1dS(2NtimageR stest R%RDs test {} aR5R@s test {a b} ctxtyistest a bis-as-bRAiis{test {a b c} d}s-x {2 3}tvsapisa b s a b {a b} cRFsa b a bs-opts{a b {a b} {1 2}}s-opt xtfroms{a}(((R%RD((RDR5R@((RDR5(RDR5R@RA(s{test {a b c} d}s-x {2 3}((RDR5R@((RDR5(s-optRT(s{a b {a b} {1 2}}s-opt x((R5(s{a}R5( t assertTrueR7t_format_elemcreateRMRKRORR9RNRt ValueError(Rtres((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_elemcreates< & "  cCspddd}ddd}|jtjgddtjdgdd}|j|tjdgdd|j|dd|j||xRtdD]D}|j|||||j||||||qW|jttjd d g|jttjd|jttjdg|jttjd iidd6d 6fgdS(Niic Ssttjdidddgd6dididid d 6fgd 6dd 6fgd 6fgd 6fgd |d|dS(NRDiiitotherR5R@RARFtnicetchildrent somethingtindentt indent_sizei(ii(R7t_format_layoutlist(RaRb((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytsamples ;cs_dfd}d||||d||d||d||||fS(Nics d|S(NR((tamount(Ra(s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytR%si%sa -other {1 2 3} -children { %sb -children { %sc -something {1 2} -children { %sd -nice opt %s} %s} %s}ii((RaRbtspaces((Ras;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytsample_expecteds R%RDRaitbadtformatR5tnameR_(RDN(RDR%(RDR5( RR7RcRMRRKRZRLtAttributeError(RRdRhtsmallestR ((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_layoutlists$  &  cCs|jtjiidd6dd6dd6d6|jtjiidd6d6ditd6td6}|jtjii|d6d6idgd 6}|jtjii|d6d6|jt tjiid gd6d6|jtjiid dgd6d6iid ddgd6d6}|jtj|d|ddj idd6|jtj|dt dt dg|dddd<|jtj|ddS(Nt configuretmapselement createRktlayoutsttk::style layout name { null }uαβγuáuvãlu üñíćódèRStstate1tstate2RtthingsAttk::style element create thing image {name {state1 state2} val} iRFsHttk::style element create thing image {name {state1 state2} val} -opt 30iR'isLttk::style element create thing image {name {state1 state2} val} -opt {3 2m}(uáuvãl(RrRsR( R6R7t_script_from_settingsRMRRR9RXRKROtappendR (Rt configdicttmapdictRS((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_script_from_settingss4#  cCsf|jtjtdddfdg|jtjtddtdgdddgdS( NRDR5Rt1it3mi(RDR5R(RR7t _tclobj_to_pyRR (R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_tclobj_to_pyGs  !csfd}tdtdD}t|}||dd|||tdd|tdtdD}t|}||dd||d tddd dS( Ncs-jtj||f||fgdS(N(RR7t_list_from_statespec(tsspecRHt res_valuetstates(R(s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_itQs css|]}d|VqdS(sstate%dN((t.0R ((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pys UsiRcss|]}d|VqdS(sstate%dN((RR ((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pys ZsiRDR5R@(RDR5R@(RDR5R@(RRRR (RRt states_event statespect states_odd((Rs;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_list_from_statespecPs  c Cstt}|jtj|d|jtj|ddifgd}|jtj||didd6fg|jtj|dddfdigd6fgddddd ddd d ff}|jtj||didd6d id d 6d ifgd6fgd6fg|jttj|d|jttj|d|jttj|ddS(NRks-optionRHR1R`s -childrenR_tniceonetotheronetchilds -otheroptt othervaluetotheropttno_minus((Rk(Rks-optionRH((R(RkR(RkRRH(R`s -children(RR6R7t_list_from_layouttupleRRKRZ(Rttkt sample_ltupletltuple((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_list_from_layouttupleas.    $cCsddd}t}||_|jtj|ididd6|jtj|id idd6|jtj|idd6dd|jtj|idd6didd6dS( NcSs*|dkr|S|dkr dS||fS(Nstest val(RM(R[RFR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytfuncs   s-test:3R/R s-testisx:ystest val(s-testi(RMRtcallRR7t _val_or_dict(RRR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_val_or_dicts  cCs}d d d d gdfdf}x-|D]%\}}|jtj||q%Wtjdkry|jttjd ndS(Nit09i RDuáÚs[]RMtasciisá(ii(Ri (RDRD(uáÚuáÚ(NRM(RMRR7t_convert_stringvaltsystgetdefaultencodingRKtUnicodeDecodeError(Rtteststorigtexpected((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_convert_stringvals  ( R R R?RRR\RnRyR}RRRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyR%s X ) = 7 +  . tTclObjsToPyTestcBs#eZdZdZdZRS(cCseidd6}|jtj|idd6t|d|d<|jtj|idd6dS(NuvälúèRF(RR7t tclobjs_to_pyR (Rtadict((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt test_unicodes  cCsiddddgd6}|jtj|iddddgd6dddg|d<|jtj|idddgd6tddd f|d<|jtj|id gd6|jtjid gd 6id gd 6dS( NiiiiRFtxmRDR5uválũèsy zRT(RDR5uválũè(RR7RR(RR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_multivaluess,)cCs+|jtjidd6idd6dS(Ns some textttext(RR7R(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt test_nosplits(R R RRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRs  t__main__(t run_unittest(RtunittestR7RtobjectR RtTestCaseRRt tests_noguiR ttest.test_supportR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyts        PK]GCCtest_ttk/test_functions.pynu[# -*- encoding: utf-8 -*- import sys import unittest import ttk class MockTkApp: def splitlist(self, arg): if isinstance(arg, tuple): return arg return arg.split(':') def wantobjects(self): return True class MockTclObj(object): typename = 'test' def __init__(self, val): self.val = val def __str__(self): return unicode(self.val) class MockStateSpec(object): typename = 'StateSpec' def __init__(self, *args): self.val = args def __str__(self): return ' '.join(self.val) class InternalFunctionsTest(unittest.TestCase): def test_format_optdict(self): def check_against(fmt_opts, result): for i in range(0, len(fmt_opts), 2): self.assertEqual(result.pop(fmt_opts[i]), fmt_opts[i + 1]) if result: self.fail("result still got elements: %s" % result) # passing an empty dict should return an empty object (tuple here) self.assertFalse(ttk._format_optdict({})) # check list formatting check_against( ttk._format_optdict({'fg': 'blue', 'padding': [1, 2, 3, 4]}), {'-fg': 'blue', '-padding': '1 2 3 4'}) # check tuple formatting (same as list) check_against( ttk._format_optdict({'test': (1, 2, '', 0)}), {'-test': '1 2 {} 0'}) # check untouched values check_against( ttk._format_optdict({'test': {'left': 'as is'}}), {'-test': {'left': 'as is'}}) # check script formatting check_against( ttk._format_optdict( {'test': [1, -1, '', '2m', 0], 'test2': 3, 'test3': '', 'test4': 'abc def', 'test5': '"abc"', 'test6': '{}', 'test7': '} -spam {'}, script=True), {'-test': '{1 -1 {} 2m 0}', '-test2': '3', '-test3': '{}', '-test4': '{abc def}', '-test5': '{"abc"}', '-test6': r'\{\}', '-test7': r'\}\ -spam\ \{'}) opts = {u'αβγ': True, u'á': False} orig_opts = opts.copy() # check if giving unicode keys is fine check_against(ttk._format_optdict(opts), {u'-αβγ': True, u'-á': False}) # opts should remain unchanged self.assertEqual(opts, orig_opts) # passing values with spaces inside a tuple/list check_against( ttk._format_optdict( {'option': ('one two', 'three')}), {'-option': '{one two} three'}) check_against( ttk._format_optdict( {'option': ('one\ttwo', 'three')}), {'-option': '{one\ttwo} three'}) # passing empty strings inside a tuple/list check_against( ttk._format_optdict( {'option': ('', 'one')}), {'-option': '{} one'}) # passing values with braces inside a tuple/list check_against( ttk._format_optdict( {'option': ('one} {two', 'three')}), {'-option': r'one\}\ \{two three'}) # passing quoted strings inside a tuple/list check_against( ttk._format_optdict( {'option': ('"one"', 'two')}), {'-option': '{"one"} two'}) check_against( ttk._format_optdict( {'option': ('{one}', 'two')}), {'-option': r'\{one\} two'}) # ignore an option amount_opts = len(ttk._format_optdict(opts, ignore=(u'á'))) // 2 self.assertEqual(amount_opts, len(opts) - 1) # ignore non-existing options amount_opts = len(ttk._format_optdict(opts, ignore=(u'á', 'b'))) // 2 self.assertEqual(amount_opts, len(opts) - 1) # ignore every option self.assertFalse(ttk._format_optdict(opts, ignore=opts.keys())) def test_format_mapdict(self): opts = {'a': [('b', 'c', 'val'), ('d', 'otherval'), ('', 'single')]} result = ttk._format_mapdict(opts) self.assertEqual(len(result), len(opts.keys()) * 2) self.assertEqual(result, ('-a', '{b c} val d otherval {} single')) self.assertEqual(ttk._format_mapdict(opts, script=True), ('-a', '{{b c} val d otherval {} single}')) self.assertEqual(ttk._format_mapdict({2: []}), ('-2', '')) opts = {u'üñíćódè': [(u'á', u'vãl')]} result = ttk._format_mapdict(opts) self.assertEqual(result, (u'-üñíćódè', u'á vãl')) # empty states valid = {'opt': [('', u'', 'hi')]} self.assertEqual(ttk._format_mapdict(valid), ('-opt', '{ } hi')) # when passing multiple states, they all must be strings invalid = {'opt': [(1, 2, 'valid val')]} self.assertRaises(TypeError, ttk._format_mapdict, invalid) invalid = {'opt': [([1], '2', 'valid val')]} self.assertRaises(TypeError, ttk._format_mapdict, invalid) # but when passing a single state, it can be anything valid = {'opt': [[1, 'value']]} self.assertEqual(ttk._format_mapdict(valid), ('-opt', '1 value')) # special attention to single states which evalute to False for stateval in (None, 0, False, '', set()): # just some samples valid = {'opt': [(stateval, 'value')]} self.assertEqual(ttk._format_mapdict(valid), ('-opt', '{} value')) # values must be iterable opts = {'a': None} self.assertRaises(TypeError, ttk._format_mapdict, opts) # items in the value must have size >= 2 self.assertRaises(IndexError, ttk._format_mapdict, {'a': [('invalid', )]}) def test_format_elemcreate(self): self.assertTrue(ttk._format_elemcreate(None), (None, ())) ## Testing type = image # image type expects at least an image name, so this should raise # IndexError since it tries to access the index 0 of an empty tuple self.assertRaises(IndexError, ttk._format_elemcreate, 'image') # don't format returned values as a tcl script # minimum acceptable for image type self.assertEqual(ttk._format_elemcreate('image', False, 'test'), ("test ", ())) # specifying a state spec self.assertEqual(ttk._format_elemcreate('image', False, 'test', ('', 'a')), ("test {} a", ())) # state spec with multiple states self.assertEqual(ttk._format_elemcreate('image', False, 'test', ('a', 'b', 'c')), ("test {a b} c", ())) # state spec and options res = ttk._format_elemcreate('image', False, 'test', ('a', 'b'), a='x', b='y') self.assertEqual(res[0], "test a b") self.assertEqual(set(res[1]), {"-a", "x", "-b", "y"}) # format returned values as a tcl script # state spec with multiple states and an option with a multivalue self.assertEqual(ttk._format_elemcreate('image', True, 'test', ('a', 'b', 'c', 'd'), x=[2, 3]), ("{test {a b c} d}", "-x {2 3}")) ## Testing type = vsapi # vsapi type expects at least a class name and a part_id, so this # should raise a ValueError since it tries to get two elements from # an empty tuple self.assertRaises(ValueError, ttk._format_elemcreate, 'vsapi') # don't format returned values as a tcl script # minimum acceptable for vsapi self.assertEqual(ttk._format_elemcreate('vsapi', False, 'a', 'b'), ("a b ", ())) # now with a state spec with multiple states self.assertEqual(ttk._format_elemcreate('vsapi', False, 'a', 'b', ('a', 'b', 'c')), ("a b {a b} c", ())) # state spec and option self.assertEqual(ttk._format_elemcreate('vsapi', False, 'a', 'b', ('a', 'b'), opt='x'), ("a b a b", ("-opt", "x"))) # format returned values as a tcl script # state spec with a multivalue and an option self.assertEqual(ttk._format_elemcreate('vsapi', True, 'a', 'b', ('a', 'b', [1, 2]), opt='x'), ("{a b {a b} {1 2}}", "-opt x")) # Testing type = from # from type expects at least a type name self.assertRaises(IndexError, ttk._format_elemcreate, 'from') self.assertEqual(ttk._format_elemcreate('from', False, 'a'), ('a', ())) self.assertEqual(ttk._format_elemcreate('from', False, 'a', 'b'), ('a', ('b', ))) self.assertEqual(ttk._format_elemcreate('from', True, 'a', 'b'), ('{a}', 'b')) def test_format_layoutlist(self): def sample(indent=0, indent_size=2): return ttk._format_layoutlist( [('a', {'other': [1, 2, 3], 'children': [('b', {'children': [('c', {'children': [('d', {'nice': 'opt'})], 'something': (1, 2) })] })] })], indent=indent, indent_size=indent_size)[0] def sample_expected(indent=0, indent_size=2): spaces = lambda amount=0: ' ' * (amount + indent) return ( "%sa -other {1 2 3} -children {\n" "%sb -children {\n" "%sc -something {1 2} -children {\n" "%sd -nice opt\n" "%s}\n" "%s}\n" "%s}" % (spaces(), spaces(indent_size), spaces(2 * indent_size), spaces(3 * indent_size), spaces(2 * indent_size), spaces(indent_size), spaces())) # empty layout self.assertEqual(ttk._format_layoutlist([])[0], '') # smallest (after an empty one) acceptable layout smallest = ttk._format_layoutlist([('a', None)], indent=0) self.assertEqual(smallest, ttk._format_layoutlist([('a', '')], indent=0)) self.assertEqual(smallest[0], 'a') # testing indentation levels self.assertEqual(sample(), sample_expected()) for i in range(4): self.assertEqual(sample(i), sample_expected(i)) self.assertEqual(sample(i, i), sample_expected(i, i)) # invalid layout format, different kind of exceptions will be # raised # plain wrong format self.assertRaises(ValueError, ttk._format_layoutlist, ['bad', 'format']) self.assertRaises(TypeError, ttk._format_layoutlist, None) # _format_layoutlist always expects the second item (in every item) # to act like a dict (except when the value evalutes to False). self.assertRaises(AttributeError, ttk._format_layoutlist, [('a', 'b')]) # bad children formatting self.assertRaises(ValueError, ttk._format_layoutlist, [('name', {'children': {'a': None}})]) def test_script_from_settings(self): # empty options self.assertFalse(ttk._script_from_settings({'name': {'configure': None, 'map': None, 'element create': None}})) # empty layout self.assertEqual( ttk._script_from_settings({'name': {'layout': None}}), "ttk::style layout name {\nnull\n}") configdict = {u'αβγ': True, u'á': False} self.assertTrue( ttk._script_from_settings({'name': {'configure': configdict}})) mapdict = {u'üñíćódè': [(u'á', u'vãl')]} self.assertTrue( ttk._script_from_settings({'name': {'map': mapdict}})) # invalid image element self.assertRaises(IndexError, ttk._script_from_settings, {'name': {'element create': ['image']}}) # minimal valid image self.assertTrue(ttk._script_from_settings({'name': {'element create': ['image', 'name']}})) image = {'thing': {'element create': ['image', 'name', ('state1', 'state2', 'val')]}} self.assertEqual(ttk._script_from_settings(image), "ttk::style element create thing image {name {state1 state2} val} ") image['thing']['element create'].append({'opt': 30}) self.assertEqual(ttk._script_from_settings(image), "ttk::style element create thing image {name {state1 state2} val} " "-opt 30") image['thing']['element create'][-1]['opt'] = [MockTclObj(3), MockTclObj('2m')] self.assertEqual(ttk._script_from_settings(image), "ttk::style element create thing image {name {state1 state2} val} " "-opt {3 2m}") def test_tclobj_to_py(self): self.assertEqual( ttk._tclobj_to_py((MockStateSpec('a', 'b'), 'val')), [('a', 'b', 'val')]) self.assertEqual( ttk._tclobj_to_py([MockTclObj('1'), 2, MockTclObj('3m')]), [1, 2, '3m']) def test_list_from_statespec(self): def test_it(sspec, value, res_value, states): self.assertEqual(ttk._list_from_statespec( (sspec, value)), [states + (res_value, )]) states_even = tuple('state%d' % i for i in range(6)) statespec = MockStateSpec(*states_even) test_it(statespec, 'val', 'val', states_even) test_it(statespec, MockTclObj('val'), 'val', states_even) states_odd = tuple('state%d' % i for i in range(5)) statespec = MockStateSpec(*states_odd) test_it(statespec, 'val', 'val', states_odd) test_it(('a', 'b', 'c'), MockTclObj('val'), 'val', ('a', 'b', 'c')) def test_list_from_layouttuple(self): tk = MockTkApp() # empty layout tuple self.assertFalse(ttk._list_from_layouttuple(tk, ())) # shortest layout tuple self.assertEqual(ttk._list_from_layouttuple(tk, ('name', )), [('name', {})]) # not so interesting ltuple sample_ltuple = ('name', '-option', 'value') self.assertEqual(ttk._list_from_layouttuple(tk, sample_ltuple), [('name', {'option': 'value'})]) # empty children self.assertEqual(ttk._list_from_layouttuple(tk, ('something', '-children', ())), [('something', {'children': []})] ) # more interesting ltuple ltuple = ( 'name', '-option', 'niceone', '-children', ( ('otherone', '-children', ( ('child', )), '-otheropt', 'othervalue' ) ) ) self.assertEqual(ttk._list_from_layouttuple(tk, ltuple), [('name', {'option': 'niceone', 'children': [('otherone', {'otheropt': 'othervalue', 'children': [('child', {})] })] })] ) # bad tuples self.assertRaises(ValueError, ttk._list_from_layouttuple, tk, ('name', 'no_minus')) self.assertRaises(ValueError, ttk._list_from_layouttuple, tk, ('name', 'no_minus', 'value')) self.assertRaises(ValueError, ttk._list_from_layouttuple, tk, ('something', '-children')) # no children def test_val_or_dict(self): def func(res, opt=None, val=None): if opt is None: return res if val is None: return "test val" return (opt, val) tk = MockTkApp() tk.call = func self.assertEqual(ttk._val_or_dict(tk, {}, '-test:3'), {'test': '3'}) self.assertEqual(ttk._val_or_dict(tk, {}, ('-test', 3)), {'test': 3}) self.assertEqual(ttk._val_or_dict(tk, {'test': None}, 'x:y'), 'test val') self.assertEqual(ttk._val_or_dict(tk, {'test': 3}, 'x:y'), {'test': 3}) def test_convert_stringval(self): tests = ( (0, 0), ('09', 9), ('a', 'a'), (u'áÚ', u'áÚ'), ([], '[]'), (None, 'None') ) for orig, expected in tests: self.assertEqual(ttk._convert_stringval(orig), expected) if sys.getdefaultencoding() == 'ascii': self.assertRaises(UnicodeDecodeError, ttk._convert_stringval, 'á') class TclObjsToPyTest(unittest.TestCase): def test_unicode(self): adict = {'opt': u'välúè'} self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': u'välúè'}) adict['opt'] = MockTclObj(adict['opt']) self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': u'välúè'}) def test_multivalues(self): adict = {'opt': [1, 2, 3, 4]} self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': [1, 2, 3, 4]}) adict['opt'] = [1, 'xm', 3] self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': [1, 'xm', 3]}) adict['opt'] = (MockStateSpec('a', 'b'), u'válũè') self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': [('a', 'b', u'válũè')]}) self.assertEqual(ttk.tclobjs_to_py({'x': ['y z']}), {'x': ['y z']}) def test_nosplit(self): self.assertEqual(ttk.tclobjs_to_py({'text': 'some text'}), {'text': 'some text'}) tests_nogui = (InternalFunctionsTest, TclObjsToPyTest) if __name__ == "__main__": from test.test_support import run_unittest run_unittest(*tests_nogui) PK]d67>>test_ttk/test_functions.pycnu[ zfc@sddlZddlZddlZdfdYZdefdYZdefdYZdejfd YZd ejfd YZ ee fZ e d krdd l m Z e e ndS(iNt MockTkAppcBseZdZdZRS(cCs t|tr|S|jdS(Nt:(t isinstancettupletsplit(tselftarg((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt splitlistscCstS(N(tTrue(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt wantobjects s(t__name__t __module__RR (((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRs t MockTclObjcBs eZdZdZdZRS(ttestcCs ||_dS(N(tval(RR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt__init__scCs t|jS(N(tunicodeR(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt__str__s(R R ttypenameRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyR s t MockStateSpeccBs eZdZdZdZRS(t StateSpeccGs ||_dS(N(R(Rtargs((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRscCsdj|jS(Nt (tjoinR(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyR!s(R R RRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRs tInternalFunctionsTestcBsbeZdZdZdZdZdZdZdZdZ dZ d Z RS( cs fd}jtji|tjidd6ddddgd6idd 6d d 6|tjidBd6idd6|tjiidd6d6iidd6d6|tjiddd dd gd6dd6d d6dd6dd6dd6dd6dtid d6d!d"6dd#6d$d%6d&d'6d(d)6d*d+6itd,6td-6}|j}|tj|itd.6td/6j|||tjidCd26id3d46|tjidDd26id6d46|tjidEd26id8d46|tjidFd26id:d46|tjidGd26id=d46|tjidHd26id?d46ttj|d@d-d}j|t|dttj|d@dId}j|t|djtj|d@|jdS(JNcsfxEtdt|dD]+}j|j||||dqW|rbjd|ndS(Niiisresult still got elements: %s(trangetlent assertEqualtpoptfail(tfmt_optstresultti(R(s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt check_against(s)tbluetfgiiiitpaddings-fgs1 2 3 4s-paddingtiR s1 2 {} 0s-testsas istleftit2mttest2ttest3sabc defttest4s"abc"ttest5s{}ttest6s } -spam {ttest7tscripts{1 -1 {} 2m 0}t3s-test2s-test3s {abc def}s-test4s{"abc"}s-test5s\{\}s-test6s \}\ -spam\ \{s-test7uαβγuáu-αβγu-ásone twotthreetoptions{one two} threes-optionsone twos{one two} threetones{} ones one} {twosone\}\ \{two threes"one"ttwos {"one"} twos{one}s \{one\} twotignoretb(iiR%i(sone twoR0(sone twoR0(R%R2(s one} {twoR0(s"one"R3(s{one}R3(uáR5( t assertFalsetttkt_format_optdictRtFalsetcopyRRtkeys(RR!toptst orig_optst amount_opts((Rs;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_optdict'sl&   $      cCsid!d"d#gd6}tj|}|jt|t|jd |j|d$|jtj|d td%|jtjigd 6d&id'gd6}tj|}|j|d(id)gd6}|jtj|d*id+gd6}|jttj|idgddfgd6}|jttj|iddggd6}|jtj|d,xOddt dt fD]5}i|dfgd6}|jtj|d-qWidd6}|jttj||jt tjid.gd6dS(/NR5tcRtdtothervalR%tsingletais-as{b c} val d otherval {} singleR.s {{b c} val d otherval {} single}s-2uáuvãlu üñíćódèu-üñíćódèuá vãluthitopts-opts{ } hiis valid valt2tvalues1 valueis{} valuetinvalid(R5R@R(RARB(R%RC(s-as{b c} val d otherval {} single(s-as {{b c} val d otherval {} single}(s-2R%(uáuvãl(u-üñíćódèuá vãl(R%uRE(s-opts{ } hi(iis valid val(s-opts1 value(s-opts{} value(RI( R7t_format_mapdictRRR;Rt assertRaisest TypeErrortNoneR9tsett IndexError(RR<RtvalidRItstateval((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_mapdicts4&   c Cs|jtjddd f|jttjd|jtjdtddd!f|jtjdtdd"dd#f|jtjdtdd$d d%ftjdtdd&dd dd }|j|d d |jt|ddd dd h|jtjdt dd'd ddgd(|jt tjd|jtjdtdddd)f|jtjdtddd*dd+f|jtjdtddd,dd dd-f|jtjdt ddddddgfdd d.|jttjd|jtjdtddd/f|jtjdtdddd0f|jtjdt ddd1dS(2NtimageR stest R%RDs test {} aR5R@s test {a b} ctxtyistest a bis-as-bRAiis{test {a b c} d}s-x {2 3}tvsapisa b s a b {a b} cRFsa b a bs-opts{a b {a b} {1 2}}s-opt xtfroms{a}(((R%RD((RDR5R@((RDR5(RDR5R@RA(s{test {a b c} d}s-x {2 3}((RDR5R@((RDR5(s-optRT(s{a b {a b} {1 2}}s-opt x((R5(s{a}R5( t assertTrueR7t_format_elemcreateRMRKRORR9RNRt ValueError(Rtres((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_elemcreates< & "  cCspddd}ddd}|jtjgddtjdgdd}|j|tjdgdd|j|dd|j||xRtdD]D}|j|||||j||||||qW|jttjd d g|jttjd|jttjdg|jttjd iidd6d 6fgdS(Niic Ssttjdidddgd6dididid d 6fgd 6dd 6fgd 6fgd 6fgd |d|dS(NRDiiitotherR5R@RARFtnicetchildrent somethingtindentt indent_sizei(ii(R7t_format_layoutlist(RaRb((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytsamples ;cs_dfd}d||||d||d||d||||fS(Nics d|S(NR((tamount(Ra(s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytR%si%sa -other {1 2 3} -children { %sb -children { %sc -something {1 2} -children { %sd -nice opt %s} %s} %s}ii((RaRbtspaces((Ras;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytsample_expecteds R%RDRaitbadtformatR5tnameR_(RDN(RDR%(RDR5( RR7RcRMRRKRZRLtAttributeError(RRdRhtsmallestR ((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_format_layoutlists$  &  cCs|jtjiidd6dd6dd6d6|jtjiidd6d6ditd6td6}|jtjii|d6d6idgd 6}|jtjii|d6d6|jt tjiid gd6d6|jtjiid dgd6d6iid ddgd6d6}|jtj|d|ddj idd6|jtj|dt dt dg|dddd<|jtj|ddS(Nt configuretmapselement createRktlayoutsttk::style layout name { null }uαβγuáuvãlu üñíćódèRStstate1tstate2RtthingsAttk::style element create thing image {name {state1 state2} val} iRFsHttk::style element create thing image {name {state1 state2} val} -opt 30iR'isLttk::style element create thing image {name {state1 state2} val} -opt {3 2m}(uáuvãl(RrRsR( R6R7t_script_from_settingsRMRRR9RXRKROtappendR (Rt configdicttmapdictRS((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_script_from_settingss4#  cCsf|jtjtdddfdg|jtjtddtdgdddgdS( NRDR5Rt1it3mi(RDR5R(RR7t _tclobj_to_pyRR (R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_tclobj_to_pyGs  !csfd}tdtdD}t|}||dd|||tdd|tdtdD}t|}||dd||d tddd dS( Ncs-jtj||f||fgdS(N(RR7t_list_from_statespec(tsspecRHt res_valuetstates(R(s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_itQs css|]}d|VqdS(sstate%dN((t.0R ((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pys UsiRcss|]}d|VqdS(sstate%dN((RR ((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pys ZsiRDR5R@(RDR5R@(RDR5R@(RRRR (RRt states_event statespect states_odd((Rs;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_list_from_statespecPs  c Cstt}|jtj|d|jtj|ddifgd}|jtj||didd6fg|jtj|dddfdigd6fgddddd ddd d ff}|jtj||didd6d id d 6d ifgd6fgd6fg|jttj|d|jttj|d|jttj|ddS(NRks-optionRHR1R`s -childrenR_tniceonetotheronetchilds -otheroptt othervaluetotheropttno_minus((Rk(Rks-optionRH((R(RkR(RkRRH(R`s -children(RR6R7t_list_from_layouttupleRRKRZ(Rttkt sample_ltupletltuple((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_list_from_layouttupleas.    $cCsddd}t}||_|jtj|ididd6|jtj|id idd6|jtj|idd6dd|jtj|idd6didd6dS( NcSs*|dkr|S|dkr dS||fS(Nstest val(RM(R[RFR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pytfuncs   s-test:3R/R s-testisx:ystest val(s-testi(RMRtcallRR7t _val_or_dict(RRR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_val_or_dicts  cCs}d d d d gdfdf}x-|D]%\}}|jtj||q%Wtjdkry|jttjd ndS(Nit09i RDuáÚs[]RMtasciisá(ii(Ri (RDRD(uáÚuáÚ(NRM(RMRR7t_convert_stringvaltsystgetdefaultencodingRKtUnicodeDecodeError(Rtteststorigtexpected((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_convert_stringvals  ( R R R?RRR\RnRyR}RRRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyR%s X ) = 7 +  . tTclObjsToPyTestcBs#eZdZdZdZRS(cCseidd6}|jtj|idd6t|d|d<|jtj|idd6dS(NuvälúèRF(RR7t tclobjs_to_pyR (Rtadict((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt test_unicodes  cCsiddddgd6}|jtj|iddddgd6dddg|d<|jtj|idddgd6tddd f|d<|jtj|id gd6|jtjid gd 6id gd 6dS( NiiiiRFtxmRDR5uválũèsy zRT(RDR5uválũè(RR7RR(RR((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyttest_multivaluess,)cCs+|jtjidd6idd6dS(Ns some textttext(RR7R(R((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyt test_nosplits(R R RRR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyRs  t__main__(t run_unittest(RtunittestR7RtobjectR RtTestCaseRRt tests_noguiR ttest.test_supportR(((s;/usr/lib64/python2.7/lib-tk/test/test_ttk/test_functions.pyts        PK]M3 test_ttk/test_style.pycnu[ zfc@sddlZddlZddlZddlmZmZddlmZeddeej fdYZ e fZ e dkree ndS(iN(trequirest run_unittest(tAbstractTkTesttguit StyleTestcBs>eZdZdZdZdZdZdZRS(cCs,tt|jtj|j|_dS(N(tsuperRtsetUptttktStyletroottstyle(tself((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyR scCsU|j}|jddd|j|jddd|j|jdtdS(NtTButtont backgroundtyellow(R t configuret assertEqualtassertIsInstancetdict(R R ((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyttest_configures  cCsm|j}|jdddg|j|jdd|jrFdgndg|j|jdtdS( NR R tactivetbluesactive background(RR R(RR R(sactive backgroundR(R tmapRt wantobjectsRR(R R ((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyttest_maps   cCs|j}|jddd|jddd g|j|jddd|j|jddddgd|j|jddddddS( NR R RRRtoptionnotdefinedtdefaulttiknewit(RR R(R RRRtlookup(R R ((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyt test_lookup!s cCs|j}|jtj|jd|jd}|jdd|j|jddidd6fg|jd||j|jd||j|jdt|jtj|jddid d 6fgdS( Nt NotALayouttTreeviewttnulltnswetstickyR tnamet inexistenttoption(R t assertRaisesttkintertTclErrortlayoutRRtlist(R R ttv_style((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyt test_layout-s cCs|jtj|jjd|jj}d}xA|jjD],}||krA|}|jj|PqAqAWdS|j||k|j||jjk|jj|dS(Ntnonexistingname(R'R(R)R t theme_usetNonet theme_namest assertFalse(R t curr_themet new_themettheme((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyttest_theme_useDs (t__name__t __module__RRRRR-R6(((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyR s    t__main__( tunittesttTkinterR(Rttest.test_supportRRttest_ttk.supportRtTestCaseRt tests_guiR7(((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyts    P  PK]ž''test_ttk/test_extensions.pycnu[ zfc@sddlZddlZddlZddlZddlmZmZmZddl m Z m Z edde ej fdYZ de ej fdYZe efZed kreendS( iN(trequirest run_unittestt swap_attr(tAbstractTkTesttdestroy_default_roottguitLabeledScaleTestcBsGeZdZdZdZdZdZdZdZRS(cCs$|jjtt|jdS(N(troottupdate_idletaskstsuperRttearDown(tself((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR s cCsltj|j}|jj}|j|jtj|j j |tj |j}|j}tj|jd|}|j|j r|j |j j ||jn(|j t|j j ||j~|jtj|j j |tj|j}tj|jd|}|jtj|jd|ttdrh|jtjtjndS(Ntvariablet last_type(tttkt LabeledScaleRt _variablet_nametdestroyt assertRaisesttkintertTclErrorttkt globalgetvart DoubleVart wantobjectst assertEqualtgettfloattIntVarthasattrtsystassertNotEqualR (R txtvartmyvartname((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_widget_destroys&     %( c CsttddttdtizYtj}|jtj|j|j tj|j|j tjj |j Wdt XWdQXWdQXdS(Nt _default_roott_support_default_root( RRtNonetTrueRRtassertIsNotNoneR&RtmasterRRR(R R!((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_initialization_no_master2s cstjj}tj|}j|j||jddddtj dtj dff}j r}|d7}nxK|D]C}tjjd|d}j|j |d|jqWtjjdd }j t |jj|jtjjdd}j t |jj|jtjjd d }tjjd |}j|j d|jtjjd |dd }j|j d j|jj|j|jfd}tjjdd}||jd|jd|jtjjdd}||jd|jd|jtjjdd}||jd|jd|jtjj}||jd|jd|jj tjtj|dddS(Nt0ii iig@itfrom_s2.5tvalueiR g?cs8j|jd|j|jd|dS(Ntsidetanchor(Rt pack_infot place_info(tscalet scale_postlabelt label_pos(R (s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pytcheck_positionsastcompoundttoptbottomtntstunknowntatb(R-i(ii(i i (ii(g@i((g@i(RtFrameRRRRR+RRtmaxintRR/Rt ValueErrorRRR(RRR4R6R(R R+R!tpassed_expectedtpairR#R8((R s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_initialization?sP              cCs^tj|jdddd}|j|j|j|jj}|jj d}|j |t |d|jj dddd|j|jj d}|j |||jj}|j |jd|jrdnd |j |t |d|jj dddd|j |||j |t |d|jdS( NR.ittoi R!iittextR-(RRRtpacktwait_visibilitytupdateR6R3R4tcoordsRtintt configureR RR(R tlscaletlinfo_1t prev_xcoordt curr_xcoordtlinfo_2((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_horizontal_rangevs$    &cCsvtj|j}|j|j|j|jjd}|jd}||_|j|j |j d|j r|n t ||j |jjd||j |jjdt|j jd|j rd}nt}||jdd|_|j|j ||j d||j |jjdt|j jd|jdS(NiiRHR!cSs|S(N((R!((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttRG(RRRRIRJRKR4RLR/RR6Rtstrt assertGreaterRMR3R(R R!RRtnewvaltconv((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_variable_changes,         cCstj|j}|jdtdd|j|j|jj|jj }}|d|d}}d|_ |j|jj d||f|j t |jjd|jjd|jj d||f|jdS( Ntexpandtfilltbothiis%dx%dR!i(RRRRIR)RJRKR+t winfo_widtht winfo_heightR/t wm_geometryRRMR6R3R4RLR(R R!twidththeightt width_newt height_new((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyt test_resizes    ( t__name__t __module__R R%R,RFRTR[Rf(((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR s  " 7  tOptionMenuTestcBs>eZdZdZdZdZdZdZRS(cCs,tt|jtj|j|_dS(N(R RitsetUpRt StringVarRttextvar(R ((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyRjscCs|`tt|jdS(N(RlR RiR (R ((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR scCstj|j}tj|j|}|j}|j|j|j|j j ||j ~|j tj |j j |dS(N(RRkRRt OptionMenuRRRRRRRRR(R R"toptmenuR$((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyR%s   "cCs|jtjtj|j|jddtj|j|jddd}|j|jj d|j |d|j |d|j dS(NtinvalidtthingR@R?tmenut textvariable( RRRRRmRRlRRRt assertTrueR(R Rn((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyRFs !c s7d d}tjjj|}t}xYttD]E}|dj|d}j||||krCt }qCqCWj ||j d}tjjj|}d}d}xQt r&||dj |d}}||kr Pnj|||d7}qWj|t|j|j|djdj|jjdjtj|djd j|jjd|j gfd }tjjjdd |}|djds)jd n|j dS(NR?R@tcRqR/tdiiics%j|djtdS(Ni(RtappendR)(titem(titemsR tsuccess(s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pytcb_teststcommandsMenu callback not invoked(R?R@Rt(RRmRRltFalsetrangetlent entrycgetRR)RsRR(tentryconfigureR RIRJtinvokeRRRRRtfail( R tdefaultRnt found_defaulttiR/tcurrtlastRz((RxR Rys</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyt test_menusJ          cCs;d }d}tj|j|j||}tj|j}tj|j|||}|j|j|j|j|djd|djd|dj dd}|dj dd}|j |||j |jj j ||d|j |jj j ||d|j|jdS( NR?R@RtRqiiiR (R?R@Rt(RRmRRlRRkRIRJRRR RRRR(R RxRRnttextvar2toptmenu2toptmenu_stringvar_nametoptmenu2_stringvar_name((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyttest_unique_radiobuttonss*        (RgRhRjR R%RFRR(((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyRis    4t__main__(RtunittesttTkinterRRttest.test_supportRRRttest_ttk.supportRRtTestCaseRRit tests_guiRg(((s</usr/lib64/python2.7/lib-tk/test/test_ttk/test_extensions.pyts     q  PK]M3 test_ttk/test_style.pyonu[ zfc@sddlZddlZddlZddlmZmZddlmZeddeej fdYZ e fZ e dkree ndS(iN(trequirest run_unittest(tAbstractTkTesttguit StyleTestcBs>eZdZdZdZdZdZdZRS(cCs,tt|jtj|j|_dS(N(tsuperRtsetUptttktStyletroottstyle(tself((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyR scCsU|j}|jddd|j|jddd|j|jdtdS(NtTButtont backgroundtyellow(R t configuret assertEqualtassertIsInstancetdict(R R ((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyttest_configures  cCsm|j}|jdddg|j|jdd|jrFdgndg|j|jdtdS( NR R tactivetbluesactive background(RR R(RR R(sactive backgroundR(R tmapRt wantobjectsRR(R R ((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyttest_maps   cCs|j}|jddd|jddd g|j|jddd|j|jddddgd|j|jddddddS( NR R RRRtoptionnotdefinedtdefaulttiknewit(RR R(R RRRtlookup(R R ((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyt test_lookup!s cCs|j}|jtj|jd|jd}|jdd|j|jddidd6fg|jd||j|jd||j|jdt|jtj|jddid d 6fgdS( Nt NotALayouttTreeviewttnulltnswetstickyR tnamet inexistenttoption(R t assertRaisesttkintertTclErrortlayoutRRtlist(R R ttv_style((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyt test_layout-s cCs|jtj|jjd|jj}d}xA|jjD],}||krA|}|jj|PqAqAWdS|j||k|j||jjk|jj|dS(Ntnonexistingname(R'R(R)R t theme_usetNonet theme_namest assertFalse(R t curr_themet new_themettheme((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyttest_theme_useDs (t__name__t __module__RRRRR-R6(((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyR s    t__main__( tunittesttTkinterR(Rttest.test_supportRRttest_ttk.supportRtTestCaseRt tests_guiR7(((s7/usr/lib64/python2.7/lib-tk/test/test_ttk/test_style.pyts    P  PK]8test_ttk/test_widgets.pyonu[ zfc@sUddlZddlZddlmZddlZddlmZmZmZm Z ddl Z ddl m Z ddl mZmZmZmZddlmZmZmZmZmZmZmZmZeddefd YZd eejfd YZd eefd YZeedeejfdYZeedeejfdYZ defdYZ!eede!ejfdYZ"eede!ejfdYZ#eede!ejfdYZ$eeedeejfdYZ%eeede%ejfdYZ&eeedeejfdYZ'eed e!ejfd!YZ(d"e!ejfd#YZ)eed$eejfd%YZ*eed&eejfd'YZ+ej,e j-d(kd)eed*eejfd+YZ.eeed,eejfd-YZ/eed.eejfd/YZ0eed0eejfd1YZ1eed2eejfd3YZ2e#e$e&e%ee e"e)e/e'e+e(e*e.e1e2e0efZ3e4d4krQee3ndS(5iN(tTclError(trequirest run_unittestt have_unicodetu(t MockTclObj(tAbstractTkTestt tcl_versiontget_tk_patchleveltsimulate_mouse_click(tadd_standard_optionstnoconvt noconv_methtAbstractWidgetTesttStandardOptionsTeststIntegerSizeTeststPixelSizeTestst setUpModuletguitStandardTtkOptionsTestscBs#eZdZdZdZRS(cCs|j}|j|ddd}td kr>d }n|j|dd d ||jd d }|j|dd dS(Ntclassts"attempt to change read-only optioniiitbetais"Attempt to change read-only optiontFooterrmsgtclass_(iiiRi(tcreatet assertEqualRtcheckInvalidParam(tselftwidgetRtwidget2((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_classs  c Cs|j}|j|dddd|j|dddd|j|dddd|j|dddd|j|dddd|j|dd|j|dddddS(Ntpaddingitexpectedt0it5it6it7it8t5pt6pt7pt8pR(R#(R$(ii(R$R%(iii(R$R%R&(iiii(R$R%R&R'(R(R)R*R+((Rt checkParam(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_paddings cCs|j}|j|ddd}t|drQdt|dj}n|j|ddd||jdd}|j|d ddS( NtstyleRsLayout Foo not foundtdefault_orientsLayout %s.Foo not foundRRRR(RRthasattrtgetattrttitleR(RRRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_style+s (t__name__t __module__R R-R3(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs t WidgetTestcBs)eZdZdZdZdZRS(s,Tests methods available in every ttk widget.cCsRtt|jtj|jdddd|_|jj|jjdS(NtwidthittexttText( tsuperR6tsetUptttktButtontrootRtpacktwait_visibility(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;=s! cCs|jj|j|jj|jjd|jjdd|j|jjddd|jtj|jjdd|jtj|jjdd|jtj|jjdddS(NitlabeliRi( Rtupdate_idletasksRtidentifyt winfo_widtht winfo_heightt assertRaisesttkinterRtNone(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_identifyDs cCs|j|jjd |j|jjdgt|j|jjdgd |j|jjdgd |j|jjddgd |j|jjddgd|j|jjddgdd}|j|jjdg|didd6didd6f|jj}|jtj|jjd g|jtj|jjdd g|j||jj|jjddg|j|jjddS(Ns !disabledtdisabledtactives!activec[s ||fS(N((targ1tkw((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_cbasthittheretmsgtbadstate((s !disabled((s!activeRJ(((RK(RRtstatetinstatetTrueRFRGR(RRNt currstate((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_widget_stateQs(""   (R4R5t__doc__R;RIRW(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR6:s  tAbstractToplevelTestcBseZeZRS((R4R5R t _conv_pixels(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRYust FrameTestc BseZd Zd ZRS( t borderwidthRtcursortheightR!treliefR.t takefocusR7cKstj|j|S(N(R<tFrameR>(Rtkwargs((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs( R\RR]R^R!R_R.R`R7(R4R5tOPTIONSR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR[ystLabelFrameTestc Bs)eZdZd ZdZdZRS(R\RR]R^t labelanchort labelwidgetR!R_R.R`R8t underlineR7cKstj|j|S(N(R<t LabelFrameR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs]|j}|j|ddddddddd d d d d dd|j|dddS(NRetetentestntnetnwtstsetswtwtwntwsRs!Bad label anchor specification {}tcenter(RtcheckEnumParamR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_labelanchors   'cCsQ|j}tj|jdddd}|j|d|dd|jdS(NR8tMupptnametfooRfR"s.foo(RR<tLabelR>R,tdestroy(RRRA((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_labelwidgets ( R\RR]R^ReRfR!R_R.R`R8RgR7(R4R5RcRRwR}(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRds  tAbstractLabelTestcBs,eZdZdZdZdZRS(cCstjd|jdd}tjd|jdd}|j|||dd |j||ddd |j|||fdd |j|||d|fdd|j||ddd|j||dd d dS(NtmasterRytimage1timage2R"RKsimage1 active image2tspamRsimage "spam" doesn't exist(R(R(R(RRKR(RRKR(RGt PhotoImageR>R,R(RRRytimageR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytcheckImageParamsc Cs8|j}|j|ddddddddd dS( NtcompoundtnoneR8RRuttoptbottomtlefttright(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_compounds   cCs)|j}|j|dddddS(NRSRKRJtnormal(Rt checkParams(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_states cCs)|j}|j|dddddS(NR7iini(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_widths (R4R5RRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR~s  t LabelTestcBs&eZdZeZdZdZRS(tanchort backgroundR\RRR]tfontt foregroundRtjustifyR!R_RSR.R`R8t textvariableRgR7t wraplengthcKstj|j|S(N(R<R{R>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs#|j}|j|dddS(NRs3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*(RR,(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_fonts  (RRR\RRR]RRRRR!R_RSR.R`R8RRgR7R(R4R5RcR RZRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs t ButtonTestcBs)eZdZdZdZdZRS(RtcommandRR]tdefaultRR!RSR.R`R8RRgR7cKstj|j|S(N(R<R=R>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs)|j}|j|dddddS(NRRRKRJ(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_defaults csBgtj|jdfd}|j|jdS(NRcs jdS(Ni(tappend((tsuccess(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytR(R<R=R>tinvoket assertTrue(Rtbtn((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_invokes! (RRRR]RRR!RSR.R`R8RRgR7(R4R5RcRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs  tCheckbuttonTestcBs2eZdZdZdZdZdZRS(RRRR]RtoffvaluetonvalueR!RSR.R`R8RRgtvariableR7cKstj|j|S(N(R<t CheckbuttonR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs,|j}|j|ddddddS(NRigffffff@Rs any string(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_offvalues cCs,|j}|j|ddddddS(NRigffffff@Rs any string(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_onvalues csgfd}tj|jd|}|j|jd |jtj|jj |d|j }|j|d|j|d|jj |d|j d|d<|j }|j t ||jtd|j|d |jj |ddS( NcsjddS(Niscb test called(R((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytcb_tests Rt alternateRscb test calledRRiR(R(R<RR>RRSRFRGRttkt globalgetvarRRt assertFalsetstrtassertLessEqualtlen(RRtcbtntres((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs"       (RRRR]RRRR!RSR.R`R8RRgRR7(R4R5RcRRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs   t EntryTestcBszeZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZRS(RRR]texportselectionRRtinvalidcommandRtshowRSR.R`RtvalidatetvalidatecommandR7txscrollcommandcCs&tt|j|j|_dS(N(R:RR;Rtentry(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;#scKstj|j|S(N(R<tEntryR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR'scCs |j}|j|ddS(NR(RtcheckCommandParam(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_invalidcommand*s cCsI|j}|j|dd|j|dd|j|dddS(NRt*Rt (RR,(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_show.s cCs)|j}|j|dddddS(NRSRJRtreadonly(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR4s  c Cs2|j}|j|ddddddddS(NRtalltkeytfocustfocusintfocusoutR(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_validate9s  cCs |j}|j|ddS(NR(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_validatecommand>s cCsU|j|jjd|jtj|jjd|jtj|jjddS(Nitnoindex(tassertIsBoundingBoxRtbboxRFRGRRH(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_bboxCscCs|jj|jj|jjtjdkrX|j|jjdddn|j|jjddd|j|jjddd|j t j |jjdd|j t j |jjdd|j t j |jjdddS(NtdarwinittextareasCombobox.buttoniR(RsCombobox.button( RR?R@RBtsystplatformtassertInRCRRFRGRRH(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRIIs    cs#gfd}d|jd(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRsc Cs2|j}|j|ddddddddS(NR^idgLY@gfffffY@iit1i(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_heights cCs`|jj}|jjdd|ddd|jjdd|ddd|jjdS(Nstxitys(RRDtevent_generateRB(RR7((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt_show_drop_down_listboxs  csgdg|jd<|jjdfd|jj|jj|jj}|j|jj|jjd|jj|jdS(NiRs<>cs jtS(N(RRU(tevt(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRs( RtbindR?R@RERtupdateRR(RR^((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_virtual_events      cs~gfd|jd<|jj|jj|j|jd|jd<|j|jtddS(Ncs jtS(N(RRU((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRRRi(RR?R@RRRR(R((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_postcommands      c sfd}jjdtd#kr1d$nd|ddjjdddd%jjdd&jjdd'jjdtd(krd)nddddgjd<jjd|ddjjd|ddjjd|ddjjdd*jd<|ddjjddddgjjdjrd+nddddgjd<jjdjrd,ndddd gjd<jjdjrd-nd!jt j jjt jdjt j jjdt j jddddg}j|djrd.nd"|jdS(/Ncs6jjj|jjj|dS(N(RRRtcurrent(tgetvaltcurrval(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytcheck_get_currentsRiiRismon tue wed thurR"tmonttuetwedtthuri*gQ @s any stringRitciitdit1t2s1 {} 2sa bsa bsa bs{a b} {a b} {a b}sa\tbs"a"s} {sa\\tb {"a"} \}\ \{s1 2 {}(ii((RRRR(RRRR(i*gQ @Rs any string(ii((iiRi(RRR(sa bsa bsa b(sa\tbs"a"s} {(RRR(RRRR,tsetRt configuret wantobjectsRFRGRRR<RR>R|(RRtcombo2((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_valuessL (     ! (RRR]RRRR^RRRRRSR.R`RRRRR7R( R4R5RcR;RRRRRR (((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs      tPanedWindowTestcBsVeZdZdZdZd Zd Zd Zd Zd Z dZ RS(RR]R^torientR.R`R7cCs&tt|j|j|_dS(N(R:R R;Rtpaned(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;&scKstj|j|S(N(R<t PanedWindowR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR*scCs|j}|jt|ddd}td krDd }n|j|dd d ||jdd }|jt|dd dS( NR tverticals"attempt to change read-only optioniiiRis"Attempt to change read-only optiont horizontalR(iiiRi(RRRRR(RRRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_orient-s  cCsztj|j}tj|}|jtj|jj||j|jtj|j}tj|}|jtj|jj||j|jtj|j}|jj||jtj|jj|tj|j}|jj||j |jj d|jj d|jtj|jj d|j|j|jtj|jj ddS(Niii( R<R{R RFRGRtaddR|R>Rtpane(RRAtchildt good_childt other_child((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_add8s(    (  cCs|jtj|jjd|jtj|jjd|jjtj|j |jjd|jtj|jjddS(Ni( RFRGRR tforgetRHRR<R{R>(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_forgetTs cCs|jtj|jjdd|jtj|jjdd|jtj|jjddtj|j}tj|j}tj|j}|jtj|jjd||jjd||jjd||j |jj t |t |f|jjd||j |jj t |t |f|jjd||j |jj t |t |t |f|jj }|jjd||j ||jj |jj|||j |jj t |t |t |fdS(NiR( RFRGRR RRHR<R{R>RtpanesR(RRtchild2tchild3R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_insert]s*++"cCs |jtj|jjdtj|j}|jj||j |jjdt |j |jjddd|j rdnd|j |jjdd|j rdnd|j |jjd|jjt||jtj|jjddddS(NitweightR#t badoptiont somevalue(RFRGRR RR<R{R>RtassertIsInstancetdictRRHRR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_panes.cCsi|jtj|jjd|jtj|jjd|jtj|jjdtj|jdd}|jj|dd|jtj|jjdtj|jdd}|jj||jtj|jjd|jj dt d d |jj |jjd}|jjdd |j ||jjd|j |jjdtdS( NRiR8RRitbtexpandtfilltbothi(RFRGRR tsashposRHR<R{RR?RUR@tassertNotEqualR tint(RRRtcurr_pos((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_sashposs (RR]R^R R.R`R7( R4R5RcR;RRRRRR"R+(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR s    # tRadiobuttonTestcBs)eZdZdZdZdZRS(RRRR]RR!RSR.R`R8RRgtvalueRR7cKstj|j|S(N(R<t RadiobuttonR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs,|j}|j|ddddddS(NR-igffffff@Rs any string(RR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_values csgfd}tj|j}tj|jd|d|dd}tj|jd|d|dd}|jrd}nt}|j}|j|d|j||d|j |j|j ||j j |d|j d |d<|j}|jt |d |jtd|j||d|j |j|j ||j j |d|jt |dt |ddS( NcsjddS(Niscb test called(R((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs RRR-iicSs|S(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRscb test calledR(RGtIntVarR>R<R.RR)RRRRRRRRR(RRtmyvarRtcbtn2tconvR((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs0        (RRRR]RR!RSR.R`R8RRgR-RR7(R4R5RcRR/R(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR,s  tMenubuttonTestcBs)eZdZdZdZdZRS(RRR]t directionRtmenuR!RSR.R`R8RRgR7cKstj|j|S(N(R<t MenubuttonR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs/|j}|j|dddddddS(NR5tabovetbelowRRtflush(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_directions  cCsH|j}tj|dd}|j|d|dt|jdS(NRyR6R3(RRGtMenuR,RR|(RRR6((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_menus (RRR]R5RR6R!RSR.R`R8RRgR7(R4R5RcRR;R=(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR4s  t ScaleTestc BskeZdZeZd Zd Zd ZdZdZ dZ dZ dZ dZ dZRS(RRR]tfromtlengthR R.R`ttoR-RRcCs@tt|j|j|_|jj|jjdS(N(R:R>R;RtscaleR?R(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;s cKstj|j|S(N(R<tScaleR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs/|j}|j|dddddtdS(NR?idg-@g333333.@R3(RtcheckFloatParamR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_froms cCs,|j}|j|ddddddS(NR@igffffff`@g33333`@t5i(RtcheckPixelsParam(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_lengths c Cs2|j}|j|ddddddtdS(NRAi,g-@g333333.@iR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_to s c Cs2|j}|j|ddddddtdS(NR-i,g-@g333333.@iR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR/s csdddg|jjdfd}d|jd>cs jS(N(tpop(R(tfailure(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRi R?tfrom_iRAiiii(RBRRR(Rtfuncid((RKs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_custom_events    cCs|jrd}nt}|jj}|j|jj|d|jd|j||jjdd||jd|j|jj|jdd|jd<|j|jj|jd|jtj|jjdd|jtj|jjdddS(NcSs|S(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR(RiRAR?R-iR( RtfloatRBRDRRRFRGR(RR3t scale_width((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_get&s  &2   cCs|jrd}nt}||jd}|d}|jj||j||jj|||jd}|jj|d|j||jj|tj|j}||jd<|j|d|j||jj|j|j||jj|d~|d|jd<|j||jj|d|j||jj||jd|j||jjd d ||j||jj|jj d ||j tj |jjddS( NcSs|S(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR:RRAi R?iRiR-i( RRORBRRRRGt DoubleVarR>RDRFRRH(RR3tmaxtnew_maxtmintvar((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_set8s,    %##,%.( RRR]R?R@R R.R`RAR-R(R4R5RcR RZR/R;RRERHRIR/RNRQRW(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR>s        tProgressbarTestc BsPeZdZeZd Zd Zd ZdZdZ dZ dZ RS(RR]R R@tmodetmaximumtphaseR.R`R-RRcKstj|j|S(N(R<t ProgressbarR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRfscCs)|j}|j|dddddS(NR@gfffffY@gYL@t2i(RRG(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRHis c Cs2|j}|j|ddddddtdS(NRZgfffffb@glS@iiR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_maximumms cCs&|j}|j|ddddS(NRYt determinatet indeterminate(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_modeqs cCsdS(N((R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_phaseusc Cs2|j}|j|ddddddtdS(NR-gfffffb@glS@iiR3(RRDR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR/ys ( RR]R R@RYRZR[R.R`R-R( R4R5RcR RZR/RRHR^RaRbR/(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRX\s     Rs"ttk.Scrollbar is special on MacOSXt ScrollbarTestcBseZdZdZdZRS( RRR]R R.R`RcKstj|j|S(N(R<t ScrollbarR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs(RRR]R R.R`(R4R5RcR/R(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRcst NotebookTestcBsqeZdZdZdZd Zd Zd Zd Zd Z dZ dZ dZ dZ RS(RR]R^R!R.R`R7cCstt|j|jdd|_tj|j|_tj|j|_ |jj |jdd|jj |j dddS(NR!iR8RR#( R:ReR;RtnbR<R{R>tchild1RR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;s cKstj|j|S(N(R<tNotebookR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRscCs|jjd|jj|j|jtj|jj|j|j |jj dd|jj |j|j |jj dd|jj |j|j |jjd|jj |jdd|jj|jjtjdkrd}nd }|j |jj||jjdxhtd d d D]G}y*|jjd |dddkrtPnWqEtjk rqEXqEW|jd dS(NiRiRR8RRs@20,5s@5,5iids@%d, 5sTab with text 'a' not found(RfRthideRRFRGRttabRgRtindexRtselectRR?R@RRtrangeRHtfail(Rttb_idxti((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_tab_identifierss,   ("cCs|jtj|jjd|jtj|jjd|jtj|jjd|jtj|jjd|jtj|jjtj|j dd|jj }|jj|j |jj|j |j |jj |tj|j }|jj|dd|jj }|jj d}|jj |j}|jj|j|jj|j|j |jj ||j |jj |j||j t|j|jj ||j |jj d|ddS( NiROtunknowntoptionR8RRi(RFRGRRfRiRHRR<R{R>ttabsRgRRkRR(RRtRtcurrt child2_index((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_add_and_hiddens*'&cCs+|jtj|jjd|jtj|jjd|jtj|jjd|jj}|jj|j}|jj|j|j t |j|jj|j t |dt |jj|jj |j|j |jj|jd|j||jj|jdS(NiROi(RFRGRRfRRHRtRkRgt assertNotInRRRRR((RRtt child1_index((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs")cCs|jtj|jjd|jtj|jjd|j|jjdt|j|jj|j d|j|jj|j d|j|jjdddS(NiRiii( RFRGRRfRkRHR R)RRgR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_indexs cCs|jj}|jjd|d|j|jj|d|df|jj|j|j|j|jj||jjd|j|j|jj|d|df|jjdd|j|jj||jtj|jjd|d|jtj|jjd|dt j |j }|jjd||j|jj|dt ||df|jj ||j|jj||jj|j||j|jjt |f||jj ||jtj|jjd||jtj|jjd||jtj|jjdd|jtj|jjdd|jtj|jjdddS(NiiRii(RfRtRRRgRRFRGRR<R{R>RRRH(RRtR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs0''##0&cs|jj|jjgg|jjdfd|jjdfd|j|jjt|j|jj|j|j |j|jjt|j|jj |j dS(Nscs jtS(N(RRU(R(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRRs<>cs jtS(N(RRU(R(t tab_changed(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRR( RfR?R@RgRRRlRRRR(R((RR{s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_selects   " " cCs|jtj|jjd|jtj|jjd|jtj|jjd|j|jj|jt|j |jj|jddd|j |jj|jdd|jj|jdd|j |jj|jddd|j |jj|jdddS(NitnotabR8Rtabc( RFRGRRfRjRHR RgR!R(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_tab(s%"%cCsb|jt|jjd|jj|j|jj|j|j|jjddS(Ni((RRRfRtRRgR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_tabs6scCs|jj|jj|jjdt|jdd|jj|jjd|j|jjt|j |jj|jjd|j|jjt|j |jj|jjd|j|jjt|j |jj |j dddd|jj |jjt|jddt jdkrh|jjd n|jjd |j|jjt|j dS( Niis sR8RRgRs s(RfR?R@RlR t focus_forceRRRRRgRjtenable_traversalRR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_traversal?s*   " " "  (RR]R^R!R.R`R7(R4R5RcR;RRqRwRRzRR|RRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRes      !   t TreeviewTestc BseZd#Zd Zd ZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZd Zd!Zd"ZRS($RtcolumnsR]tdisplaycolumnsR^R!t selectmodeRR.R`RtyscrollcommandcCs,tt|j|jdd|_dS(NR!i(R:RR;Rttv(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;cscKstj|j|S(N(R<tTreeviewR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRgscCsa|j}|j|dddd |j|dd |j|dtd krVd nd dS(NRsa b cR"RR#RiiR(RR#R(RR#R(ii((RR,R(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_columnsjs  cCs|j}d|d<|j|dddd|j|dd|j|dddd|j|dd|j|ddd d|j|ddd d|j|ddd ddS(NRR#RRRsb a cR"s#alliiiRRsInvalid column index disColumn index 3 out of boundsisColumn index -2 out of bounds(RR#R(R#RR(R#RR(s#all(iii(RR#R(iii(ii(RR,R(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_displaycolumnsqs  c CsN|j}|j|ddddddt|j|ddddtdS( NR^idiit3cR3gLY@gfffffY@(RRGRR (RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs "cCs)|j}|j|dddddS(NRRtbrowsetextended(RRv(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_selectmodes  cCs|j}|j|dddd|j|dd|j|dd|j|dddd |j|dddd dS( NRs tree headingsR"ttreetheadings(RR(RR(RR(R(R(RR,(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs cCsW|jj|j|jjdd|jj|jj|jjdd}|jj}|j||jj|d}|j |dg|jd<|jj ddd|jj|dd}|jj ddd}|j st |}n|j|d|d||jj|d}|j|jj|ddS( NRRittestRR7i2s#0(RR?RRR@RRt get_childrenRRtcolumnRHRR)(Rtitem_idtchildrenRt bbox_column0t root_widthRg((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs$      cCs>|j|jjd|jjdd}|j|jjt|j|jjd||jjdd}|jjdd}|jj||||j|jj|||f|jtj |jj|||jj||j|jj|d|jjd|j|jjddS(NRRi(((( RRRRR ttuplet set_childrenRFRGR(RRRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_childrens" cCsi|j|jjdt|jrJ|j|jjdddtn|jjddd|j|jjdd|jrdnd|j|jjddd|jrdnd|jt j |jjddd|jt j |jjdidd 6id d 6id d 6id d6id d 6g}x-|D]%}|jt j |jjd|q<WdS(Ns#0R7i t10tidtXRs some valuetunknown_optiontwrongtstretchRtminwidth( R RRR!RRHR)RRFRGR(Rt invalid_kwsRM((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_columns %"$ cCs?|jtj|jjd|jjdd}|jj|d}|j|jj|f|j|jj||f|jj||j|jj|jtj|jj |dd|jjdd}|jjdd}|j|jj||f|jj|||j|jjdS(Ns#0RR( RFRGRRRRRRRtreattach(RRtitem2titem1((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_deletes cCs0|jjdd}|jj|d}|jj}|jj|j||jj|j|jj|f|j|jj||f|jj||j|jj|jj|dd|j|jj|f|j|jj||f|jj|dd|j|jj||f|j|jj|d|jt j |jjddd|jt j |jjd|jt j |jj|dd|jt j |jj|dd|jj|||j|jjd|j|jj|ddS( NRRt nonexistentt otherparentR(((( RRRtdetachRRRtmoveRFRGR(RRRtprev((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_detach_reattachs4     cCst|j|jjdt|j|jjdt|j|jjit|jtj|jjddS(Nt somethingR( RRtexistsRRURFRGRRH(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_exists'scCs|j|jjd|jjdd}|jj||j|jj||jj||j|jjd|jtj|jjddS(NRRRO(RRRRRRFRGR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_focus2scCs|j|jjdt|jjddd|j|jjddd|j|jjdddd|jtj|jjddd|jtj|jjddddS(Ns#0R8RORRi( R RtheadingR!RRHRFRGR(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_headingAs"csfd}gjjjjjjddfdjjdddjj|ddsjdngjjj}jjddt jjdddj |jjj|ddsjdndS( Ncs$tj||jjdS(N(R RR(RR(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytsimulate_heading_clickRss#0Rcs jtS(N(RRU((R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRZRR7idis>The command associated to the treeview heading wasn't invoked.( RR?R@RRRRnRt _tclCommandsRRHR(RRtcommands((RRs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_heading_callbackQs"    . cCs|jtj|jjd|j|jjdd|jjdd}|jjdd}|jj|d}|jj|d}|j|jj|d|j|jj|d|j|jj|d|j|jj|d|jj|dd|j|jj|d|j|jj|d|jj||j|jj|d|jj||j|jj|d|jj ||jtj|jj|dS(NtwhatRiRi( RFRGRRRkRRRRR(RRRtc1tc2((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRzss&cCs|jtj|jjdd|jtj|jjdddd|jtj|jjdddd|j|jj|jjdddt|j|jj|jjdddt|jtj|jjdd|jjddd}|j |d|jtj|jjddd|jtj|jjddt dd}|jjddd |f}|j |jj |d |j r|fn||j |jj |d d|j r|fn||jj |d |jj|jj |d d|j |jj |d d|j r@|fn||j|jj |t|jj |d d|j|jj |d d|jjddd d d |g}|j |jj |d d|j rd d|fnd||jj |d g|j|jj |d d|jj |d d|j |jj |d d|j rodnd|jjddd dd||ff}|j |jj |d d|j rdd||ffn d||f|j |jj |jjddddddd|j |jj |jjddd|dd||jjddd}|j |d|jjddd}|j |d|jtj|jjddt|jtj|jjddddS(NRRRtopentpleasetmiddles first-itemuábaRttagsiiRRs1 2 %ss1 2sa b cs%s %ss{a b c} {%s %s}R8s Label hereiR#gs0.0(ii(RR(RFRGRRRRRRURRRtitemRRHR>t splitlistR R!(RtitemidR-R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_insert_itemsh.. 4$ !!"cCs|jtj|jjd|jtj|jjd|jtj|jjd|jtj|jjd|jjdd}|jjdd}|jj|d}|jj|d}|jj|d}|j |jj d |jj||f|j |jj ||f|jj||j |jj |f|jj||f|j |jj |||f|jj||j |jj ||||f|jj||f|j |jj |||f|jj||j |jj ||f|jj||f|j |jj ||f|jj||j |jj |f|jjdddd|jjd|j |jj d |jjdddd|jjd|j |jj d t rl|jjdddt d|jjt d|j |jj t dfn|jjdddd|jjd|j |jj t rt d ndfdS( NRRRRs with spacess{braces unicode\u20acsbytes€s bytes\u20ac((s with spaces(s{brace( RFRGRRt selection_sett selection_addtselection_removetselection_toggleRRt selectionRR(RRRRRtc3((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_selectionsR"%"%cCsPddg|jd<|jjdddddg}|j|jj|idd6dd6|jj|dd|j|jj|dd|jrdnd dg|jd<|j|jj|idd6|jj|dd|j|jj|d dd|j|jj|dd|jr:dnd |jj|dd |j|jj|d|jr~d nd |j|jj|dd|jrdnd|j|jj||jrid d6n id d6|jtj |jj|d|jtj |jj|dd|jtj |jjddS(NtAtBRRRRRR#sa aRsb ai{t123s123 atnotme(RR(R#R(i{R( RRRRRRHRRFRGR(RR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRWs,!*#"$"c sg|jjddddg}|jjddddg}|jjddfd|jjddfd|jj|jj|jjt}t}xqtd d d D]]}t|d krPn|jj |}|r||kr|j ||j |qqW|j t|d x!|D]}t |jd |qJW|j td xAt ddd ddd D]}|j |dqWdS(NRRRtcallscs jdS(Ni(R(R(tevents(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR;Rscs jdS(Ni(R(R(R(s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR=Riidi iii(ii(RRttag_bindR?R@RRRmRt identify_rowRRR tzip( RRRtpos_ytfoundRpRRR((Rs9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_tag_bind6s2       0cCs|jt|jj|jtj|jjddd|jjddd|jt|jjddd|jt|jjdddd|j |jjdt dS(NRtskytblueR( RFt TypeErrorRt tag_configureRGRRRRHR R!(R((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyttest_tag_configureXs !cCs|jjddddddg}|jjddddddg}|jt|jj|jt|jjdd |j|jjd||j|jjd||j|jjd||j|jjd||j|jjd ||j|jjd ||j|jjd|f|j|jjd|f|j|jjd d dS( NRRR8sItem 1Rttag1sItem 2ttag2s non-existingttag3(( RRRFRttag_hasRRRR(RRR((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyt test_tag_hasds$$( RRR]RR^R!RRR.R`RR(R4R5RcR;RRRRRRRRRRRRRRRRzRRRWRRR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR[s4           *   "  M 6 ! " t SeparatorTestcBseZdZdZdZRS(RR]R R.R`RcKstj|j|S(N(R<t SeparatorR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyR|s(RR]R R.R`(R4R5RcR/R(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRtst SizegripTestcBseZdZdZRS(RR]R.R`cKstj|j|S(N(R<tSizegripR>(RRb((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRs(RR]R.R`(R4R5RcR(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pyRst__main__(5tunittesttTkinterRGRR<ttest.test_supportRRRRRttest_functionsRtsupportRRRR t widget_testsR R R R RRRRRtTestCaseR6RYR[RdR~RRRRRR R,R4R>RXtskipIfRRcReRRRt tests_guiR4(((s9/usr/lib64/python2.7/lib-tk/test/test_ttk/test_widgets.pytsr   " ": ';     0| 3 j "          PK]B,,test_ttk/test_extensions.pynu[import sys import unittest import Tkinter as tkinter import ttk from test.test_support import requires, run_unittest, swap_attr from test_ttk.support import AbstractTkTest, destroy_default_root requires('gui') class LabeledScaleTest(AbstractTkTest, unittest.TestCase): def tearDown(self): self.root.update_idletasks() super(LabeledScaleTest, self).tearDown() def test_widget_destroy(self): # automatically created variable x = ttk.LabeledScale(self.root) var = x._variable._name x.destroy() self.assertRaises(tkinter.TclError, x.tk.globalgetvar, var) # manually created variable myvar = tkinter.DoubleVar(self.root) name = myvar._name x = ttk.LabeledScale(self.root, variable=myvar) x.destroy() if self.wantobjects: self.assertEqual(x.tk.globalgetvar(name), myvar.get()) else: self.assertEqual(float(x.tk.globalgetvar(name)), myvar.get()) del myvar self.assertRaises(tkinter.TclError, x.tk.globalgetvar, name) # checking that the tracing callback is properly removed myvar = tkinter.IntVar(self.root) # LabeledScale will start tracing myvar x = ttk.LabeledScale(self.root, variable=myvar) x.destroy() # Unless the tracing callback was removed, creating a new # LabeledScale with the same var will cause an error now. This # happens because the variable will be set to (possibly) a new # value which causes the tracing callback to be called and then # it tries calling instance attributes not yet defined. ttk.LabeledScale(self.root, variable=myvar) if hasattr(sys, 'last_type'): self.assertNotEqual(sys.last_type, tkinter.TclError) def test_initialization_no_master(self): # no master passing with swap_attr(tkinter, '_default_root', None), \ swap_attr(tkinter, '_support_default_root', True): try: x = ttk.LabeledScale() self.assertIsNotNone(tkinter._default_root) self.assertEqual(x.master, tkinter._default_root) self.assertEqual(x.tk, tkinter._default_root.tk) x.destroy() finally: destroy_default_root() def test_initialization(self): # master passing master = tkinter.Frame(self.root) x = ttk.LabeledScale(master) self.assertEqual(x.master, master) x.destroy() # variable initialization/passing passed_expected = (('0', 0), (0, 0), (10, 10), (-1, -1), (sys.maxint + 1, sys.maxint + 1)) if self.wantobjects: passed_expected += ((2.5, 2),) for pair in passed_expected: x = ttk.LabeledScale(self.root, from_=pair[0]) self.assertEqual(x.value, pair[1]) x.destroy() x = ttk.LabeledScale(self.root, from_='2.5') self.assertRaises(ValueError, x._variable.get) x.destroy() x = ttk.LabeledScale(self.root, from_=None) self.assertRaises(ValueError, x._variable.get) x.destroy() # variable should have its default value set to the from_ value myvar = tkinter.DoubleVar(self.root, value=20) x = ttk.LabeledScale(self.root, variable=myvar) self.assertEqual(x.value, 0) x.destroy() # check that it is really using a DoubleVar x = ttk.LabeledScale(self.root, variable=myvar, from_=0.5) self.assertEqual(x.value, 0.5) self.assertEqual(x._variable._name, myvar._name) x.destroy() # widget positionment def check_positions(scale, scale_pos, label, label_pos): self.assertEqual(scale.pack_info()['side'], scale_pos) self.assertEqual(label.place_info()['anchor'], label_pos) x = ttk.LabeledScale(self.root, compound='top') check_positions(x.scale, 'bottom', x.label, 'n') x.destroy() x = ttk.LabeledScale(self.root, compound='bottom') check_positions(x.scale, 'top', x.label, 's') x.destroy() # invert default positions x = ttk.LabeledScale(self.root, compound='unknown') check_positions(x.scale, 'top', x.label, 's') x.destroy() x = ttk.LabeledScale(self.root) # take default positions check_positions(x.scale, 'bottom', x.label, 'n') x.destroy() # extra, and invalid, kwargs self.assertRaises(tkinter.TclError, ttk.LabeledScale, master, a='b') def test_horizontal_range(self): lscale = ttk.LabeledScale(self.root, from_=0, to=10) lscale.pack() lscale.wait_visibility() lscale.update() linfo_1 = lscale.label.place_info() prev_xcoord = lscale.scale.coords()[0] self.assertEqual(prev_xcoord, int(linfo_1['x'])) # change range to: from -5 to 5. This should change the x coord of # the scale widget, since 0 is at the middle of the new # range. lscale.scale.configure(from_=-5, to=5) # The following update is needed since the test doesn't use mainloop, # at the same time this shouldn't affect test outcome lscale.update() curr_xcoord = lscale.scale.coords()[0] self.assertNotEqual(prev_xcoord, curr_xcoord) # the label widget should have been repositioned too linfo_2 = lscale.label.place_info() self.assertEqual(lscale.label['text'], 0 if self.wantobjects else '0') self.assertEqual(curr_xcoord, int(linfo_2['x'])) # change the range back lscale.scale.configure(from_=0, to=10) self.assertNotEqual(prev_xcoord, curr_xcoord) self.assertEqual(prev_xcoord, int(linfo_1['x'])) lscale.destroy() def test_variable_change(self): x = ttk.LabeledScale(self.root) x.pack() x.wait_visibility() x.update() curr_xcoord = x.scale.coords()[0] newval = x.value + 1 x.value = newval # The following update is needed since the test doesn't use mainloop, # at the same time this shouldn't affect test outcome x.update() self.assertEqual(x.label['text'], newval if self.wantobjects else str(newval)) self.assertGreater(x.scale.coords()[0], curr_xcoord) self.assertEqual(x.scale.coords()[0], int(x.label.place_info()['x'])) # value outside range if self.wantobjects: conv = lambda x: x else: conv = int x.value = conv(x.scale['to']) + 1 # no changes shouldn't happen x.update() self.assertEqual(conv(x.label['text']), newval) self.assertEqual(x.scale.coords()[0], int(x.label.place_info()['x'])) x.destroy() def test_resize(self): x = ttk.LabeledScale(self.root) x.pack(expand=True, fill='both') x.wait_visibility() x.update() width, height = x.master.winfo_width(), x.master.winfo_height() width_new, height_new = width * 2, height * 2 x.value = 3 x.update() x.master.wm_geometry("%dx%d" % (width_new, height_new)) self.assertEqual(int(x.label.place_info()['x']), x.scale.coords()[0]) # Reset geometry x.master.wm_geometry("%dx%d" % (width, height)) x.destroy() class OptionMenuTest(AbstractTkTest, unittest.TestCase): def setUp(self): super(OptionMenuTest, self).setUp() self.textvar = tkinter.StringVar(self.root) def tearDown(self): del self.textvar super(OptionMenuTest, self).tearDown() def test_widget_destroy(self): var = tkinter.StringVar(self.root) optmenu = ttk.OptionMenu(self.root, var) name = var._name optmenu.update_idletasks() optmenu.destroy() self.assertEqual(optmenu.tk.globalgetvar(name), var.get()) del var self.assertRaises(tkinter.TclError, optmenu.tk.globalgetvar, name) def test_initialization(self): self.assertRaises(tkinter.TclError, ttk.OptionMenu, self.root, self.textvar, invalid='thing') optmenu = ttk.OptionMenu(self.root, self.textvar, 'b', 'a', 'b') self.assertEqual(optmenu._variable.get(), 'b') self.assertTrue(optmenu['menu']) self.assertTrue(optmenu['textvariable']) optmenu.destroy() def test_menu(self): items = ('a', 'b', 'c') default = 'a' optmenu = ttk.OptionMenu(self.root, self.textvar, default, *items) found_default = False for i in range(len(items)): value = optmenu['menu'].entrycget(i, 'value') self.assertEqual(value, items[i]) if value == default: found_default = True self.assertTrue(found_default) optmenu.destroy() # default shouldn't be in menu if it is not part of values default = 'd' optmenu = ttk.OptionMenu(self.root, self.textvar, default, *items) curr = None i = 0 while True: last, curr = curr, optmenu['menu'].entryconfigure(i, 'value') if last == curr: # no more menu entries break self.assertNotEqual(curr, default) i += 1 self.assertEqual(i, len(items)) # check that variable is updated correctly optmenu.pack() optmenu.wait_visibility() optmenu['menu'].invoke(0) self.assertEqual(optmenu._variable.get(), items[0]) # changing to an invalid index shouldn't change the variable self.assertRaises(tkinter.TclError, optmenu['menu'].invoke, -1) self.assertEqual(optmenu._variable.get(), items[0]) optmenu.destroy() # specifying a callback success = [] def cb_test(item): self.assertEqual(item, items[1]) success.append(True) optmenu = ttk.OptionMenu(self.root, self.textvar, 'a', command=cb_test, *items) optmenu['menu'].invoke(1) if not success: self.fail("Menu callback not invoked") optmenu.destroy() def test_unique_radiobuttons(self): # check that radiobuttons are unique across instances (bpo25684) items = ('a', 'b', 'c') default = 'a' optmenu = ttk.OptionMenu(self.root, self.textvar, default, *items) textvar2 = tkinter.StringVar(self.root) optmenu2 = ttk.OptionMenu(self.root, textvar2, default, *items) optmenu.pack() optmenu.wait_visibility() optmenu2.pack() optmenu2.wait_visibility() optmenu['menu'].invoke(1) optmenu2['menu'].invoke(2) optmenu_stringvar_name = optmenu['menu'].entrycget(0, 'variable') optmenu2_stringvar_name = optmenu2['menu'].entrycget(0, 'variable') self.assertNotEqual(optmenu_stringvar_name, optmenu2_stringvar_name) self.assertEqual(self.root.tk.globalgetvar(optmenu_stringvar_name), items[1]) self.assertEqual(self.root.tk.globalgetvar(optmenu2_stringvar_name), items[2]) optmenu.destroy() optmenu2.destroy() tests_gui = (LabeledScaleTest, OptionMenuTest) if __name__ == "__main__": run_unittest(*tests_gui) PK]@ Stest_ttk/support.pycnu[ zfc@sddlZddlZddlZddlZdddYZdZdZddlZe e e ej j dZdZdadZid d d 6d d 6d d d6dd6ZdZdZdZdS(iNtAbstractTkTestcBs8eZedZedZdZdZRS(cCstj|_ttjtj|_|jj|_|jjdy|jj dt Wntj k r{nXdS(Ntnormals-zoomed( ttkintert_support_default_roott_old_support_default_roottdestroy_default_roott NoDefaultRoottTktroott wantobjectstwm_statet wm_attributestFalsetTclError(tcls((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt setUpClasss  cCs9|jj|jj|`dt_|jt_dS(N(Rtupdate_idletaskstdestroytNoneRt _default_rootRR(R((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt tearDownClasss    cCs|jjdS(N(Rt deiconify(tself((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytsetUpscCs5x!|jjD]}|jqW|jjdS(N(Rtwinfo_childrenRtwithdraw(Rtw((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyttearDown"s(t__name__t __module__t classmethodRRRR(((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyRs cCs<ttddr8tjjtjjdt_ndS(NR(tgetattrRRRRR(((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyR's  cCsh|jddddd|jdd|d||jdd|d||jdd|d|dS( sYGenerate proper events to click at the x, y position (tries to act like an X server).stxitysssN(tevent_generate(twidgetR R!((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytsimulate_mouse_click-st.csQtdkr>tjtkddjttSfd}|S(Nisrequires Tcl version >= R%cs%tjfd}|S(NcsCtkr5|jddjttn|dS(Nsrequires Tcl version >= R%(tget_tk_patchleveltskipTesttjointmaptstr(R(ttesttversion(s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytnewtest?s (t functoolstwraps(R+R-(R,(R+s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytdeco>s!(tlentunittestt skipUnlesst tcl_versionR(R)R*(R,R0((R,s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt requires_tcl9s cCstdkrtj}|jdd}tjd|}|j\}}}}t|t|t|}}}idd6dd6dd 6|}|dkr||||d faq||d ||fantS( Ntinfot patchlevels(\d+)\.(\d+)([ab.])(\d+)$talphatatbetatbtfinalR%i( t_tk_patchlevelRRtTcltcalltretmatchtgroupstint(ttclR7tmtmajortminort releaseleveltserial((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyR&Is  & iHgRQ@tctigffffff9@REitpcCst|d t|dS(Ni(tfloattunits(tvalue((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt pixels_conv_scCs||krtSt|tjrDt|trDt||kSnt|trt|trt|t|kotdt||DSnt S(Ncss$|]\}}t||VqdS(N(t tcl_obj_eq(t.0tacttexp((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pys ks( tTruet isinstancet_tkintertTcl_ObjR*ttupleR1talltzipR (tactualtexpected((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyRQbs  cCs]||krtSt|ttjfrYt|ttjfrYt|t|kSntS(N(RURVR*RtWidgetR (R\R]((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt widget_eqos  ((R.R@R2tTkinterRRRR$RWRYR)RCt TCL_VERSIONtsplitR4R5RR=R&RNRPRQR_(((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyts&    !  !       PK]M,7test_ttk/support.pynu[import functools import re import unittest import Tkinter as tkinter class AbstractTkTest: @classmethod def setUpClass(cls): cls._old_support_default_root = tkinter._support_default_root destroy_default_root() tkinter.NoDefaultRoot() cls.root = tkinter.Tk() cls.wantobjects = cls.root.wantobjects() # De-maximize main window. # Some window managers can maximize new windows. cls.root.wm_state('normal') try: cls.root.wm_attributes('-zoomed', False) except tkinter.TclError: pass @classmethod def tearDownClass(cls): cls.root.update_idletasks() cls.root.destroy() del cls.root tkinter._default_root = None tkinter._support_default_root = cls._old_support_default_root def setUp(self): self.root.deiconify() def tearDown(self): for w in self.root.winfo_children(): w.destroy() self.root.withdraw() def destroy_default_root(): if getattr(tkinter, '_default_root', None): tkinter._default_root.update_idletasks() tkinter._default_root.destroy() tkinter._default_root = None def simulate_mouse_click(widget, x, y): """Generate proper events to click at the x, y position (tries to act like an X server).""" widget.event_generate('', x=0, y=0) widget.event_generate('', x=x, y=y) widget.event_generate('', x=x, y=y) widget.event_generate('', x=x, y=y) import _tkinter tcl_version = tuple(map(int, _tkinter.TCL_VERSION.split('.'))) def requires_tcl(*version): if len(version) <= 2: return unittest.skipUnless(tcl_version >= version, 'requires Tcl version >= ' + '.'.join(map(str, version))) def deco(test): @functools.wraps(test) def newtest(self): if get_tk_patchlevel() < version: self.skipTest('requires Tcl version >= ' + '.'.join(map(str, version))) test(self) return newtest return deco _tk_patchlevel = None def get_tk_patchlevel(): global _tk_patchlevel if _tk_patchlevel is None: tcl = tkinter.Tcl() patchlevel = tcl.call('info', 'patchlevel') m = re.match(r'(\d+)\.(\d+)([ab.])(\d+)$', patchlevel) major, minor, releaselevel, serial = m.groups() major, minor, serial = int(major), int(minor), int(serial) releaselevel = {'a': 'alpha', 'b': 'beta', '.': 'final'}[releaselevel] if releaselevel == 'final': _tk_patchlevel = major, minor, serial, releaselevel, 0 else: _tk_patchlevel = major, minor, 0, releaselevel, serial return _tk_patchlevel units = { 'c': 72 / 2.54, # centimeters 'i': 72, # inches 'm': 72 / 25.4, # millimeters 'p': 1, # points } def pixels_conv(value): return float(value[:-1]) * units[value[-1:]] def tcl_obj_eq(actual, expected): if actual == expected: return True if isinstance(actual, _tkinter.Tcl_Obj): if isinstance(expected, str): return str(actual) == expected if isinstance(actual, tuple): if isinstance(expected, tuple): return (len(actual) == len(expected) and all(tcl_obj_eq(act, exp) for act, exp in zip(actual, expected))) return False def widget_eq(actual, expected): if actual == expected: return True if isinstance(actual, (str, tkinter.Widget)): if isinstance(expected, (str, tkinter.Widget)): return str(actual) == str(expected) return False PK]Vtest_ttk/test_widgets.pynu[import unittest import Tkinter as tkinter from Tkinter import TclError import ttk from test.test_support import requires, run_unittest, have_unicode, u import sys from test_functions import MockTclObj from support import (AbstractTkTest, tcl_version, get_tk_patchlevel, simulate_mouse_click) from widget_tests import (add_standard_options, noconv, noconv_meth, AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests, setUpModule) requires('gui') class StandardTtkOptionsTests(StandardOptionsTests): def test_class(self): widget = self.create() self.assertEqual(widget['class'], '') errmsg='attempt to change read-only option' if get_tk_patchlevel() < (8, 6, 0, 'beta', 3): errmsg='Attempt to change read-only option' self.checkInvalidParam(widget, 'class', 'Foo', errmsg=errmsg) widget2 = self.create(class_='Foo') self.assertEqual(widget2['class'], 'Foo') def test_padding(self): widget = self.create() self.checkParam(widget, 'padding', 0, expected=('0',)) self.checkParam(widget, 'padding', 5, expected=('5',)) self.checkParam(widget, 'padding', (5, 6), expected=('5', '6')) self.checkParam(widget, 'padding', (5, 6, 7), expected=('5', '6', '7')) self.checkParam(widget, 'padding', (5, 6, 7, 8), expected=('5', '6', '7', '8')) self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p')) self.checkParam(widget, 'padding', (), expected='') def test_style(self): widget = self.create() self.assertEqual(widget['style'], '') errmsg = 'Layout Foo not found' if hasattr(self, 'default_orient'): errmsg = ('Layout %s.Foo not found' % getattr(self, 'default_orient').title()) self.checkInvalidParam(widget, 'style', 'Foo', errmsg=errmsg) widget2 = self.create(class_='Foo') self.assertEqual(widget2['class'], 'Foo') # XXX pass class WidgetTest(AbstractTkTest, unittest.TestCase): """Tests methods available in every ttk widget.""" def setUp(self): super(WidgetTest, self).setUp() self.widget = ttk.Button(self.root, width=0, text="Text") self.widget.pack() self.widget.wait_visibility() def test_identify(self): self.widget.update_idletasks() self.assertEqual(self.widget.identify( self.widget.winfo_width() // 2, self.widget.winfo_height() // 2 ), "label") self.assertEqual(self.widget.identify(-1, -1), "") self.assertRaises(tkinter.TclError, self.widget.identify, None, 5) self.assertRaises(tkinter.TclError, self.widget.identify, 5, None) self.assertRaises(tkinter.TclError, self.widget.identify, 5, '') def test_widget_state(self): # XXX not sure about the portability of all these tests self.assertEqual(self.widget.state(), ()) self.assertEqual(self.widget.instate(['!disabled']), True) # changing from !disabled to disabled self.assertEqual(self.widget.state(['disabled']), ('!disabled', )) # no state change self.assertEqual(self.widget.state(['disabled']), ()) # change back to !disable but also active self.assertEqual(self.widget.state(['!disabled', 'active']), ('!active', 'disabled')) # no state changes, again self.assertEqual(self.widget.state(['!disabled', 'active']), ()) self.assertEqual(self.widget.state(['active', '!disabled']), ()) def test_cb(arg1, **kw): return arg1, kw self.assertEqual(self.widget.instate(['!disabled'], test_cb, "hi", **{"msg": "there"}), ('hi', {'msg': 'there'})) # attempt to set invalid statespec currstate = self.widget.state() self.assertRaises(tkinter.TclError, self.widget.instate, ['badstate']) self.assertRaises(tkinter.TclError, self.widget.instate, ['disabled', 'badstate']) # verify that widget didn't change its state self.assertEqual(currstate, self.widget.state()) # ensuring that passing None as state doesn't modify current state self.widget.state(['active', '!disabled']) self.assertEqual(self.widget.state(), ('active', )) class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests): _conv_pixels = noconv_meth @add_standard_options(StandardTtkOptionsTests) class FrameTest(AbstractToplevelTest, unittest.TestCase): OPTIONS = ( 'borderwidth', 'class', 'cursor', 'height', 'padding', 'relief', 'style', 'takefocus', 'width', ) def create(self, **kwargs): return ttk.Frame(self.root, **kwargs) @add_standard_options(StandardTtkOptionsTests) class LabelFrameTest(AbstractToplevelTest, unittest.TestCase): OPTIONS = ( 'borderwidth', 'class', 'cursor', 'height', 'labelanchor', 'labelwidget', 'padding', 'relief', 'style', 'takefocus', 'text', 'underline', 'width', ) def create(self, **kwargs): return ttk.LabelFrame(self.root, **kwargs) def test_labelanchor(self): widget = self.create() self.checkEnumParam(widget, 'labelanchor', 'e', 'en', 'es', 'n', 'ne', 'nw', 's', 'se', 'sw', 'w', 'wn', 'ws', errmsg='Bad label anchor specification {}') self.checkInvalidParam(widget, 'labelanchor', 'center') def test_labelwidget(self): widget = self.create() label = ttk.Label(self.root, text='Mupp', name='foo') self.checkParam(widget, 'labelwidget', label, expected='.foo') label.destroy() class AbstractLabelTest(AbstractWidgetTest): def checkImageParam(self, widget, name): image = tkinter.PhotoImage(master=self.root, name='image1') image2 = tkinter.PhotoImage(master=self.root, name='image2') self.checkParam(widget, name, image, expected=('image1',)) self.checkParam(widget, name, 'image1', expected=('image1',)) self.checkParam(widget, name, (image,), expected=('image1',)) self.checkParam(widget, name, (image, 'active', image2), expected=('image1', 'active', 'image2')) self.checkParam(widget, name, 'image1 active image2', expected=('image1', 'active', 'image2')) self.checkInvalidParam(widget, name, 'spam', errmsg='image "spam" doesn\'t exist') def test_compound(self): widget = self.create() self.checkEnumParam(widget, 'compound', 'none', 'text', 'image', 'center', 'top', 'bottom', 'left', 'right') def test_state(self): widget = self.create() self.checkParams(widget, 'state', 'active', 'disabled', 'normal') def test_width(self): widget = self.create() self.checkParams(widget, 'width', 402, -402, 0) @add_standard_options(StandardTtkOptionsTests) class LabelTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'anchor', 'background', 'borderwidth', 'class', 'compound', 'cursor', 'font', 'foreground', 'image', 'justify', 'padding', 'relief', 'state', 'style', 'takefocus', 'text', 'textvariable', 'underline', 'width', 'wraplength', ) _conv_pixels = noconv_meth def create(self, **kwargs): return ttk.Label(self.root, **kwargs) def test_font(self): widget = self.create() self.checkParam(widget, 'font', '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') @add_standard_options(StandardTtkOptionsTests) class ButtonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'class', 'command', 'compound', 'cursor', 'default', 'image', 'padding', 'state', 'style', 'takefocus', 'text', 'textvariable', 'underline', 'width', ) def create(self, **kwargs): return ttk.Button(self.root, **kwargs) def test_default(self): widget = self.create() self.checkEnumParam(widget, 'default', 'normal', 'active', 'disabled') def test_invoke(self): success = [] btn = ttk.Button(self.root, command=lambda: success.append(1)) btn.invoke() self.assertTrue(success) @add_standard_options(StandardTtkOptionsTests) class CheckbuttonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'class', 'command', 'compound', 'cursor', 'image', 'offvalue', 'onvalue', 'padding', 'state', 'style', 'takefocus', 'text', 'textvariable', 'underline', 'variable', 'width', ) def create(self, **kwargs): return ttk.Checkbutton(self.root, **kwargs) def test_offvalue(self): widget = self.create() self.checkParams(widget, 'offvalue', 1, 2.3, '', 'any string') def test_onvalue(self): widget = self.create() self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string') def test_invoke(self): success = [] def cb_test(): success.append(1) return "cb test called" cbtn = ttk.Checkbutton(self.root, command=cb_test) # the variable automatically created by ttk.Checkbutton is actually # undefined till we invoke the Checkbutton self.assertEqual(cbtn.state(), ('alternate', )) self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar, cbtn['variable']) res = cbtn.invoke() self.assertEqual(res, "cb test called") self.assertEqual(cbtn['onvalue'], cbtn.tk.globalgetvar(cbtn['variable'])) self.assertTrue(success) cbtn['command'] = '' res = cbtn.invoke() self.assertFalse(str(res)) self.assertLessEqual(len(success), 1) self.assertEqual(cbtn['offvalue'], cbtn.tk.globalgetvar(cbtn['variable'])) @add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) class EntryTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'background', 'class', 'cursor', 'exportselection', 'font', 'foreground', 'invalidcommand', 'justify', 'show', 'state', 'style', 'takefocus', 'textvariable', 'validate', 'validatecommand', 'width', 'xscrollcommand', ) def setUp(self): super(EntryTest, self).setUp() self.entry = self.create() def create(self, **kwargs): return ttk.Entry(self.root, **kwargs) def test_invalidcommand(self): widget = self.create() self.checkCommandParam(widget, 'invalidcommand') def test_show(self): widget = self.create() self.checkParam(widget, 'show', '*') self.checkParam(widget, 'show', '') self.checkParam(widget, 'show', ' ') def test_state(self): widget = self.create() self.checkParams(widget, 'state', 'disabled', 'normal', 'readonly') def test_validate(self): widget = self.create() self.checkEnumParam(widget, 'validate', 'all', 'key', 'focus', 'focusin', 'focusout', 'none') def test_validatecommand(self): widget = self.create() self.checkCommandParam(widget, 'validatecommand') def test_bbox(self): self.assertIsBoundingBox(self.entry.bbox(0)) self.assertRaises(tkinter.TclError, self.entry.bbox, 'noindex') self.assertRaises(tkinter.TclError, self.entry.bbox, None) def test_identify(self): self.entry.pack() self.entry.wait_visibility() self.entry.update_idletasks() # bpo-27313: macOS Cocoa widget differs from X, allow either if sys.platform == 'darwin': self.assertIn(self.entry.identify(5, 5), ("textarea", "Combobox.button") ) else: self.assertEqual(self.entry.identify(5, 5), "textarea") self.assertEqual(self.entry.identify(-1, -1), "") self.assertRaises(tkinter.TclError, self.entry.identify, None, 5) self.assertRaises(tkinter.TclError, self.entry.identify, 5, None) self.assertRaises(tkinter.TclError, self.entry.identify, 5, '') def test_validation_options(self): success = [] test_invalid = lambda: success.append(True) self.entry['validate'] = 'none' self.entry['validatecommand'] = lambda: False self.entry['invalidcommand'] = test_invalid self.entry.validate() self.assertTrue(success) self.entry['invalidcommand'] = '' self.entry.validate() self.assertEqual(len(success), 1) self.entry['invalidcommand'] = test_invalid self.entry['validatecommand'] = lambda: True self.entry.validate() self.assertEqual(len(success), 1) self.entry['validatecommand'] = '' self.entry.validate() self.assertEqual(len(success), 1) self.entry['validatecommand'] = True self.assertRaises(tkinter.TclError, self.entry.validate) def test_validation(self): validation = [] def validate(to_insert): if not 'a' <= to_insert.lower() <= 'z': validation.append(False) return False validation.append(True) return True self.entry['validate'] = 'key' self.entry['validatecommand'] = self.entry.register(validate), '%S' self.entry.insert('end', 1) self.entry.insert('end', 'a') self.assertEqual(validation, [False, True]) self.assertEqual(self.entry.get(), 'a') def test_revalidation(self): def validate(content): for letter in content: if not 'a' <= letter.lower() <= 'z': return False return True self.entry['validatecommand'] = self.entry.register(validate), '%P' self.entry.insert('end', 'avocado') self.assertEqual(self.entry.validate(), True) self.assertEqual(self.entry.state(), ()) self.entry.delete(0, 'end') self.assertEqual(self.entry.get(), '') self.entry.insert('end', 'a1b') self.assertEqual(self.entry.validate(), False) self.assertEqual(self.entry.state(), ('invalid', )) self.entry.delete(1) self.assertEqual(self.entry.validate(), True) self.assertEqual(self.entry.state(), ()) @add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) class ComboboxTest(EntryTest, unittest.TestCase): OPTIONS = ( 'background', 'class', 'cursor', 'exportselection', 'font', 'foreground', 'height', 'invalidcommand', 'justify', 'postcommand', 'show', 'state', 'style', 'takefocus', 'textvariable', 'validate', 'validatecommand', 'values', 'width', 'xscrollcommand', ) def setUp(self): super(ComboboxTest, self).setUp() self.combo = self.create() def create(self, **kwargs): return ttk.Combobox(self.root, **kwargs) def test_height(self): widget = self.create() self.checkParams(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i') def _show_drop_down_listbox(self): width = self.combo.winfo_width() self.combo.event_generate('', x=width - 5, y=5) self.combo.event_generate('', x=width - 5, y=5) self.combo.update_idletasks() def test_virtual_event(self): success = [] self.combo['values'] = [1] self.combo.bind('<>', lambda evt: success.append(True)) self.combo.pack() self.combo.wait_visibility() height = self.combo.winfo_height() self._show_drop_down_listbox() self.combo.update() self.combo.event_generate('') self.combo.update() self.assertTrue(success) def test_postcommand(self): success = [] self.combo['postcommand'] = lambda: success.append(True) self.combo.pack() self.combo.wait_visibility() self._show_drop_down_listbox() self.assertTrue(success) # testing postcommand removal self.combo['postcommand'] = '' self._show_drop_down_listbox() self.assertEqual(len(success), 1) def test_values(self): def check_get_current(getval, currval): self.assertEqual(self.combo.get(), getval) self.assertEqual(self.combo.current(), currval) self.assertEqual(self.combo['values'], () if tcl_version < (8, 5) else '') check_get_current('', -1) self.checkParam(self.combo, 'values', 'mon tue wed thur', expected=('mon', 'tue', 'wed', 'thur')) self.checkParam(self.combo, 'values', ('mon', 'tue', 'wed', 'thur')) self.checkParam(self.combo, 'values', (42, 3.14, '', 'any string')) self.checkParam(self.combo, 'values', () if tcl_version < (8, 5) else '') self.combo['values'] = ['a', 1, 'c'] self.combo.set('c') check_get_current('c', 2) self.combo.current(0) check_get_current('a', 0) self.combo.set('d') check_get_current('d', -1) # testing values with empty string self.combo.set('') self.combo['values'] = (1, 2, '', 3) check_get_current('', 2) # testing values with empty string set through configure self.combo.configure(values=[1, '', 2]) self.assertEqual(self.combo['values'], ('1', '', '2') if self.wantobjects else '1 {} 2') # testing values with spaces self.combo['values'] = ['a b', 'a\tb', 'a\nb'] self.assertEqual(self.combo['values'], ('a b', 'a\tb', 'a\nb') if self.wantobjects else '{a b} {a\tb} {a\nb}') # testing values with special characters self.combo['values'] = [r'a\tb', '"a"', '} {'] self.assertEqual(self.combo['values'], (r'a\tb', '"a"', '} {') if self.wantobjects else r'a\\tb {"a"} \}\ \{') # out of range self.assertRaises(tkinter.TclError, self.combo.current, len(self.combo['values'])) # it expects an integer (or something that can be converted to int) self.assertRaises(tkinter.TclError, self.combo.current, '') # testing creating combobox with empty string in values combo2 = ttk.Combobox(self.root, values=[1, 2, '']) self.assertEqual(combo2['values'], ('1', '2', '') if self.wantobjects else '1 2 {}') combo2.destroy() @add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) class PanedWindowTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'cursor', 'height', 'orient', 'style', 'takefocus', 'width', ) def setUp(self): super(PanedWindowTest, self).setUp() self.paned = self.create() def create(self, **kwargs): return ttk.PanedWindow(self.root, **kwargs) def test_orient(self): widget = self.create() self.assertEqual(str(widget['orient']), 'vertical') errmsg='attempt to change read-only option' if get_tk_patchlevel() < (8, 6, 0, 'beta', 3): errmsg='Attempt to change read-only option' self.checkInvalidParam(widget, 'orient', 'horizontal', errmsg=errmsg) widget2 = self.create(orient='horizontal') self.assertEqual(str(widget2['orient']), 'horizontal') def test_add(self): # attempt to add a child that is not a direct child of the paned window label = ttk.Label(self.paned) child = ttk.Label(label) self.assertRaises(tkinter.TclError, self.paned.add, child) label.destroy() child.destroy() # another attempt label = ttk.Label(self.root) child = ttk.Label(label) self.assertRaises(tkinter.TclError, self.paned.add, child) child.destroy() label.destroy() good_child = ttk.Label(self.root) self.paned.add(good_child) # re-adding a child is not accepted self.assertRaises(tkinter.TclError, self.paned.add, good_child) other_child = ttk.Label(self.paned) self.paned.add(other_child) self.assertEqual(self.paned.pane(0), self.paned.pane(1)) self.assertRaises(tkinter.TclError, self.paned.pane, 2) good_child.destroy() other_child.destroy() self.assertRaises(tkinter.TclError, self.paned.pane, 0) def test_forget(self): self.assertRaises(tkinter.TclError, self.paned.forget, None) self.assertRaises(tkinter.TclError, self.paned.forget, 0) self.paned.add(ttk.Label(self.root)) self.paned.forget(0) self.assertRaises(tkinter.TclError, self.paned.forget, 0) def test_insert(self): self.assertRaises(tkinter.TclError, self.paned.insert, None, 0) self.assertRaises(tkinter.TclError, self.paned.insert, 0, None) self.assertRaises(tkinter.TclError, self.paned.insert, 0, 0) child = ttk.Label(self.root) child2 = ttk.Label(self.root) child3 = ttk.Label(self.root) self.assertRaises(tkinter.TclError, self.paned.insert, 0, child) self.paned.insert('end', child2) self.paned.insert(0, child) self.assertEqual(self.paned.panes(), (str(child), str(child2))) self.paned.insert(0, child2) self.assertEqual(self.paned.panes(), (str(child2), str(child))) self.paned.insert('end', child3) self.assertEqual(self.paned.panes(), (str(child2), str(child), str(child3))) # reinserting a child should move it to its current position panes = self.paned.panes() self.paned.insert('end', child3) self.assertEqual(panes, self.paned.panes()) # moving child3 to child2 position should result in child2 ending up # in previous child position and child ending up in previous child3 # position self.paned.insert(child2, child3) self.assertEqual(self.paned.panes(), (str(child3), str(child2), str(child))) def test_pane(self): self.assertRaises(tkinter.TclError, self.paned.pane, 0) child = ttk.Label(self.root) self.paned.add(child) self.assertIsInstance(self.paned.pane(0), dict) self.assertEqual(self.paned.pane(0, weight=None), 0 if self.wantobjects else '0') # newer form for querying a single option self.assertEqual(self.paned.pane(0, 'weight'), 0 if self.wantobjects else '0') self.assertEqual(self.paned.pane(0), self.paned.pane(str(child))) self.assertRaises(tkinter.TclError, self.paned.pane, 0, badoption='somevalue') def test_sashpos(self): self.assertRaises(tkinter.TclError, self.paned.sashpos, None) self.assertRaises(tkinter.TclError, self.paned.sashpos, '') self.assertRaises(tkinter.TclError, self.paned.sashpos, 0) child = ttk.Label(self.paned, text='a') self.paned.add(child, weight=1) self.assertRaises(tkinter.TclError, self.paned.sashpos, 0) child2 = ttk.Label(self.paned, text='b') self.paned.add(child2) self.assertRaises(tkinter.TclError, self.paned.sashpos, 1) self.paned.pack(expand=True, fill='both') self.paned.wait_visibility() curr_pos = self.paned.sashpos(0) self.paned.sashpos(0, 1000) self.assertNotEqual(curr_pos, self.paned.sashpos(0)) self.assertIsInstance(self.paned.sashpos(0), int) @add_standard_options(StandardTtkOptionsTests) class RadiobuttonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'class', 'command', 'compound', 'cursor', 'image', 'padding', 'state', 'style', 'takefocus', 'text', 'textvariable', 'underline', 'value', 'variable', 'width', ) def create(self, **kwargs): return ttk.Radiobutton(self.root, **kwargs) def test_value(self): widget = self.create() self.checkParams(widget, 'value', 1, 2.3, '', 'any string') def test_invoke(self): success = [] def cb_test(): success.append(1) return "cb test called" myvar = tkinter.IntVar(self.root) cbtn = ttk.Radiobutton(self.root, command=cb_test, variable=myvar, value=0) cbtn2 = ttk.Radiobutton(self.root, command=cb_test, variable=myvar, value=1) if self.wantobjects: conv = lambda x: x else: conv = int res = cbtn.invoke() self.assertEqual(res, "cb test called") self.assertEqual(conv(cbtn['value']), myvar.get()) self.assertEqual(myvar.get(), conv(cbtn.tk.globalgetvar(cbtn['variable']))) self.assertTrue(success) cbtn2['command'] = '' res = cbtn2.invoke() self.assertEqual(str(res), '') self.assertLessEqual(len(success), 1) self.assertEqual(conv(cbtn2['value']), myvar.get()) self.assertEqual(myvar.get(), conv(cbtn.tk.globalgetvar(cbtn['variable']))) self.assertEqual(str(cbtn['variable']), str(cbtn2['variable'])) class MenubuttonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'class', 'compound', 'cursor', 'direction', 'image', 'menu', 'padding', 'state', 'style', 'takefocus', 'text', 'textvariable', 'underline', 'width', ) def create(self, **kwargs): return ttk.Menubutton(self.root, **kwargs) def test_direction(self): widget = self.create() self.checkEnumParam(widget, 'direction', 'above', 'below', 'left', 'right', 'flush') def test_menu(self): widget = self.create() menu = tkinter.Menu(widget, name='menu') self.checkParam(widget, 'menu', menu, conv=str) menu.destroy() @add_standard_options(StandardTtkOptionsTests) class ScaleTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'command', 'cursor', 'from', 'length', 'orient', 'style', 'takefocus', 'to', 'value', 'variable', ) _conv_pixels = noconv_meth default_orient = 'horizontal' def setUp(self): super(ScaleTest, self).setUp() self.scale = self.create() self.scale.pack() self.scale.update() def create(self, **kwargs): return ttk.Scale(self.root, **kwargs) def test_from(self): widget = self.create() self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=False) def test_length(self): widget = self.create() self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i') def test_to(self): widget = self.create() self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False) def test_value(self): widget = self.create() self.checkFloatParam(widget, 'value', 300, 14.9, 15.1, -10, conv=False) def test_custom_event(self): failure = [1, 1, 1] # will need to be empty funcid = self.scale.bind('<>', lambda evt: failure.pop()) self.scale['from'] = 10 self.scale['from_'] = 10 self.scale['to'] = 3 self.assertFalse(failure) failure = [1, 1, 1] self.scale.configure(from_=2, to=5) self.scale.configure(from_=0, to=-2) self.scale.configure(to=10) self.assertFalse(failure) def test_get(self): if self.wantobjects: conv = lambda x: x else: conv = float scale_width = self.scale.winfo_width() self.assertEqual(self.scale.get(scale_width, 0), self.scale['to']) self.assertEqual(conv(self.scale.get(0, 0)), conv(self.scale['from'])) self.assertEqual(self.scale.get(), self.scale['value']) self.scale['value'] = 30 self.assertEqual(self.scale.get(), self.scale['value']) self.assertRaises(tkinter.TclError, self.scale.get, '', 0) self.assertRaises(tkinter.TclError, self.scale.get, 0, '') def test_set(self): if self.wantobjects: conv = lambda x: x else: conv = float # set restricts the max/min values according to the current range max = conv(self.scale['to']) new_max = max + 10 self.scale.set(new_max) self.assertEqual(conv(self.scale.get()), max) min = conv(self.scale['from']) self.scale.set(min - 1) self.assertEqual(conv(self.scale.get()), min) # changing directly the variable doesn't impose this limitation tho var = tkinter.DoubleVar(self.root) self.scale['variable'] = var var.set(max + 5) self.assertEqual(conv(self.scale.get()), var.get()) self.assertEqual(conv(self.scale.get()), max + 5) del var # the same happens with the value option self.scale['value'] = max + 10 self.assertEqual(conv(self.scale.get()), max + 10) self.assertEqual(conv(self.scale.get()), conv(self.scale['value'])) # nevertheless, note that the max/min values we can get specifying # x, y coords are the ones according to the current range self.assertEqual(conv(self.scale.get(0, 0)), min) self.assertEqual(conv(self.scale.get(self.scale.winfo_width(), 0)), max) self.assertRaises(tkinter.TclError, self.scale.set, None) @add_standard_options(StandardTtkOptionsTests) class ProgressbarTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'cursor', 'orient', 'length', 'mode', 'maximum', 'phase', 'style', 'takefocus', 'value', 'variable', ) _conv_pixels = noconv_meth default_orient = 'horizontal' def create(self, **kwargs): return ttk.Progressbar(self.root, **kwargs) def test_length(self): widget = self.create() self.checkPixelsParam(widget, 'length', 100.1, 56.7, '2i') def test_maximum(self): widget = self.create() self.checkFloatParam(widget, 'maximum', 150.2, 77.7, 0, -10, conv=False) def test_mode(self): widget = self.create() self.checkEnumParam(widget, 'mode', 'determinate', 'indeterminate') def test_phase(self): # XXX pass def test_value(self): widget = self.create() self.checkFloatParam(widget, 'value', 150.2, 77.7, 0, -10, conv=False) @unittest.skipIf(sys.platform == 'darwin', 'ttk.Scrollbar is special on MacOSX') @add_standard_options(StandardTtkOptionsTests) class ScrollbarTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'command', 'cursor', 'orient', 'style', 'takefocus', ) default_orient = 'vertical' def create(self, **kwargs): return ttk.Scrollbar(self.root, **kwargs) @add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) class NotebookTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'cursor', 'height', 'padding', 'style', 'takefocus', 'width', ) def setUp(self): super(NotebookTest, self).setUp() self.nb = self.create(padding=0) self.child1 = ttk.Label(self.root) self.child2 = ttk.Label(self.root) self.nb.add(self.child1, text='a') self.nb.add(self.child2, text='b') def create(self, **kwargs): return ttk.Notebook(self.root, **kwargs) def test_tab_identifiers(self): self.nb.forget(0) self.nb.hide(self.child2) self.assertRaises(tkinter.TclError, self.nb.tab, self.child1) self.assertEqual(self.nb.index('end'), 1) self.nb.add(self.child2) self.assertEqual(self.nb.index('end'), 1) self.nb.select(self.child2) self.assertTrue(self.nb.tab('current')) self.nb.add(self.child1, text='a') self.nb.pack() self.nb.wait_visibility() if sys.platform == 'darwin': tb_idx = "@20,5" else: tb_idx = "@5,5" self.assertEqual(self.nb.tab(tb_idx), self.nb.tab('current')) for i in range(5, 100, 5): try: if self.nb.tab('@%d, 5' % i, text=None) == 'a': break except tkinter.TclError: pass else: self.fail("Tab with text 'a' not found") def test_add_and_hidden(self): self.assertRaises(tkinter.TclError, self.nb.hide, -1) self.assertRaises(tkinter.TclError, self.nb.hide, 'hi') self.assertRaises(tkinter.TclError, self.nb.hide, None) self.assertRaises(tkinter.TclError, self.nb.add, None) self.assertRaises(tkinter.TclError, self.nb.add, ttk.Label(self.root), unknown='option') tabs = self.nb.tabs() self.nb.hide(self.child1) self.nb.add(self.child1) self.assertEqual(self.nb.tabs(), tabs) child = ttk.Label(self.root) self.nb.add(child, text='c') tabs = self.nb.tabs() curr = self.nb.index('current') # verify that the tab gets readded at its previous position child2_index = self.nb.index(self.child2) self.nb.hide(self.child2) self.nb.add(self.child2) self.assertEqual(self.nb.tabs(), tabs) self.assertEqual(self.nb.index(self.child2), child2_index) self.assertEqual(str(self.child2), self.nb.tabs()[child2_index]) # but the tab next to it (not hidden) is the one selected now self.assertEqual(self.nb.index('current'), curr + 1) def test_forget(self): self.assertRaises(tkinter.TclError, self.nb.forget, -1) self.assertRaises(tkinter.TclError, self.nb.forget, 'hi') self.assertRaises(tkinter.TclError, self.nb.forget, None) tabs = self.nb.tabs() child1_index = self.nb.index(self.child1) self.nb.forget(self.child1) self.assertNotIn(str(self.child1), self.nb.tabs()) self.assertEqual(len(tabs) - 1, len(self.nb.tabs())) self.nb.add(self.child1) self.assertEqual(self.nb.index(self.child1), 1) self.assertNotEqual(child1_index, self.nb.index(self.child1)) def test_index(self): self.assertRaises(tkinter.TclError, self.nb.index, -1) self.assertRaises(tkinter.TclError, self.nb.index, None) self.assertIsInstance(self.nb.index('end'), int) self.assertEqual(self.nb.index(self.child1), 0) self.assertEqual(self.nb.index(self.child2), 1) self.assertEqual(self.nb.index('end'), 2) def test_insert(self): # moving tabs tabs = self.nb.tabs() self.nb.insert(1, tabs[0]) self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0])) self.nb.insert(self.child1, self.child2) self.assertEqual(self.nb.tabs(), tabs) self.nb.insert('end', self.child1) self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0])) self.nb.insert('end', 0) self.assertEqual(self.nb.tabs(), tabs) # bad moves self.assertRaises(tkinter.TclError, self.nb.insert, 2, tabs[0]) self.assertRaises(tkinter.TclError, self.nb.insert, -1, tabs[0]) # new tab child3 = ttk.Label(self.root) self.nb.insert(1, child3) self.assertEqual(self.nb.tabs(), (tabs[0], str(child3), tabs[1])) self.nb.forget(child3) self.assertEqual(self.nb.tabs(), tabs) self.nb.insert(self.child1, child3) self.assertEqual(self.nb.tabs(), (str(child3), ) + tabs) self.nb.forget(child3) self.assertRaises(tkinter.TclError, self.nb.insert, 2, child3) self.assertRaises(tkinter.TclError, self.nb.insert, -1, child3) # bad inserts self.assertRaises(tkinter.TclError, self.nb.insert, 'end', None) self.assertRaises(tkinter.TclError, self.nb.insert, None, 0) self.assertRaises(tkinter.TclError, self.nb.insert, None, None) def test_select(self): self.nb.pack() self.nb.wait_visibility() success = [] tab_changed = [] self.child1.bind('', lambda evt: success.append(True)) self.nb.bind('<>', lambda evt: tab_changed.append(True)) self.assertEqual(self.nb.select(), str(self.child1)) self.nb.select(self.child2) self.assertTrue(success) self.assertEqual(self.nb.select(), str(self.child2)) self.nb.update() self.assertTrue(tab_changed) def test_tab(self): self.assertRaises(tkinter.TclError, self.nb.tab, -1) self.assertRaises(tkinter.TclError, self.nb.tab, 'notab') self.assertRaises(tkinter.TclError, self.nb.tab, None) self.assertIsInstance(self.nb.tab(self.child1), dict) self.assertEqual(self.nb.tab(self.child1, text=None), 'a') # newer form for querying a single option self.assertEqual(self.nb.tab(self.child1, 'text'), 'a') self.nb.tab(self.child1, text='abc') self.assertEqual(self.nb.tab(self.child1, text=None), 'abc') self.assertEqual(self.nb.tab(self.child1, 'text'), 'abc') def test_tabs(self): self.assertEqual(len(self.nb.tabs()), 2) self.nb.forget(self.child1) self.nb.forget(self.child2) self.assertEqual(self.nb.tabs(), ()) def test_traversal(self): self.nb.pack() self.nb.wait_visibility() self.nb.select(0) simulate_mouse_click(self.nb, 5, 5) self.nb.focus_force() self.nb.event_generate('') self.assertEqual(self.nb.select(), str(self.child2)) self.nb.focus_force() self.nb.event_generate('') self.assertEqual(self.nb.select(), str(self.child1)) self.nb.focus_force() self.nb.event_generate('') self.assertEqual(self.nb.select(), str(self.child2)) self.nb.tab(self.child1, text='a', underline=0) self.nb.enable_traversal() self.nb.focus_force() simulate_mouse_click(self.nb, 5, 5) if sys.platform == 'darwin': self.nb.event_generate('') else: self.nb.event_generate('') self.assertEqual(self.nb.select(), str(self.child1)) @add_standard_options(StandardTtkOptionsTests) class TreeviewTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'columns', 'cursor', 'displaycolumns', 'height', 'padding', 'selectmode', 'show', 'style', 'takefocus', 'xscrollcommand', 'yscrollcommand', ) def setUp(self): super(TreeviewTest, self).setUp() self.tv = self.create(padding=0) def create(self, **kwargs): return ttk.Treeview(self.root, **kwargs) def test_columns(self): widget = self.create() self.checkParam(widget, 'columns', 'a b c', expected=('a', 'b', 'c')) self.checkParam(widget, 'columns', ('a', 'b', 'c')) self.checkParam(widget, 'columns', () if tcl_version < (8, 5) else '') def test_displaycolumns(self): widget = self.create() widget['columns'] = ('a', 'b', 'c') self.checkParam(widget, 'displaycolumns', 'b a c', expected=('b', 'a', 'c')) self.checkParam(widget, 'displaycolumns', ('b', 'a', 'c')) self.checkParam(widget, 'displaycolumns', '#all', expected=('#all',)) self.checkParam(widget, 'displaycolumns', (2, 1, 0)) self.checkInvalidParam(widget, 'displaycolumns', ('a', 'b', 'd'), errmsg='Invalid column index d') self.checkInvalidParam(widget, 'displaycolumns', (1, 2, 3), errmsg='Column index 3 out of bounds') self.checkInvalidParam(widget, 'displaycolumns', (1, -2), errmsg='Column index -2 out of bounds') def test_height(self): widget = self.create() self.checkPixelsParam(widget, 'height', 100, -100, 0, '3c', conv=False) self.checkPixelsParam(widget, 'height', 101.2, 102.6, conv=noconv) def test_selectmode(self): widget = self.create() self.checkEnumParam(widget, 'selectmode', 'none', 'browse', 'extended') def test_show(self): widget = self.create() self.checkParam(widget, 'show', 'tree headings', expected=('tree', 'headings')) self.checkParam(widget, 'show', ('tree', 'headings')) self.checkParam(widget, 'show', ('headings', 'tree')) self.checkParam(widget, 'show', 'tree', expected=('tree',)) self.checkParam(widget, 'show', 'headings', expected=('headings',)) def test_bbox(self): self.tv.pack() self.assertEqual(self.tv.bbox(''), '') self.tv.wait_visibility() self.tv.update() item_id = self.tv.insert('', 'end') children = self.tv.get_children() self.assertTrue(children) bbox = self.tv.bbox(children[0]) self.assertIsBoundingBox(bbox) # compare width in bboxes self.tv['columns'] = ['test'] self.tv.column('test', width=50) bbox_column0 = self.tv.bbox(children[0], 0) root_width = self.tv.column('#0', width=None) if not self.wantobjects: root_width = int(root_width) self.assertEqual(bbox_column0[0], bbox[0] + root_width) # verify that bbox of a closed item is the empty string child1 = self.tv.insert(item_id, 'end') self.assertEqual(self.tv.bbox(child1), '') def test_children(self): # no children yet, should get an empty tuple self.assertEqual(self.tv.get_children(), ()) item_id = self.tv.insert('', 'end') self.assertIsInstance(self.tv.get_children(), tuple) self.assertEqual(self.tv.get_children()[0], item_id) # add item_id and child3 as children of child2 child2 = self.tv.insert('', 'end') child3 = self.tv.insert('', 'end') self.tv.set_children(child2, item_id, child3) self.assertEqual(self.tv.get_children(child2), (item_id, child3)) # child3 has child2 as parent, thus trying to set child2 as a children # of child3 should result in an error self.assertRaises(tkinter.TclError, self.tv.set_children, child3, child2) # remove child2 children self.tv.set_children(child2) self.assertEqual(self.tv.get_children(child2), ()) # remove root's children self.tv.set_children('') self.assertEqual(self.tv.get_children(), ()) def test_column(self): # return a dict with all options/values self.assertIsInstance(self.tv.column('#0'), dict) # return a single value of the given option if self.wantobjects: self.assertIsInstance(self.tv.column('#0', width=None), int) # set a new value for an option self.tv.column('#0', width=10) # testing new way to get option value self.assertEqual(self.tv.column('#0', 'width'), 10 if self.wantobjects else '10') self.assertEqual(self.tv.column('#0', width=None), 10 if self.wantobjects else '10') # check read-only option self.assertRaises(tkinter.TclError, self.tv.column, '#0', id='X') self.assertRaises(tkinter.TclError, self.tv.column, 'invalid') invalid_kws = [ {'unknown_option': 'some value'}, {'stretch': 'wrong'}, {'anchor': 'wrong'}, {'width': 'wrong'}, {'minwidth': 'wrong'} ] for kw in invalid_kws: self.assertRaises(tkinter.TclError, self.tv.column, '#0', **kw) def test_delete(self): self.assertRaises(tkinter.TclError, self.tv.delete, '#0') item_id = self.tv.insert('', 'end') item2 = self.tv.insert(item_id, 'end') self.assertEqual(self.tv.get_children(), (item_id, )) self.assertEqual(self.tv.get_children(item_id), (item2, )) self.tv.delete(item_id) self.assertFalse(self.tv.get_children()) # reattach should fail self.assertRaises(tkinter.TclError, self.tv.reattach, item_id, '', 'end') # test multiple item delete item1 = self.tv.insert('', 'end') item2 = self.tv.insert('', 'end') self.assertEqual(self.tv.get_children(), (item1, item2)) self.tv.delete(item1, item2) self.assertFalse(self.tv.get_children()) def test_detach_reattach(self): item_id = self.tv.insert('', 'end') item2 = self.tv.insert(item_id, 'end') # calling detach without items is valid, although it does nothing prev = self.tv.get_children() self.tv.detach() # this should do nothing self.assertEqual(prev, self.tv.get_children()) self.assertEqual(self.tv.get_children(), (item_id, )) self.assertEqual(self.tv.get_children(item_id), (item2, )) # detach item with children self.tv.detach(item_id) self.assertFalse(self.tv.get_children()) # reattach item with children self.tv.reattach(item_id, '', 'end') self.assertEqual(self.tv.get_children(), (item_id, )) self.assertEqual(self.tv.get_children(item_id), (item2, )) # move a children to the root self.tv.move(item2, '', 'end') self.assertEqual(self.tv.get_children(), (item_id, item2)) self.assertEqual(self.tv.get_children(item_id), ()) # bad values self.assertRaises(tkinter.TclError, self.tv.reattach, 'nonexistent', '', 'end') self.assertRaises(tkinter.TclError, self.tv.detach, 'nonexistent') self.assertRaises(tkinter.TclError, self.tv.reattach, item2, 'otherparent', 'end') self.assertRaises(tkinter.TclError, self.tv.reattach, item2, '', 'invalid') # multiple detach self.tv.detach(item_id, item2) self.assertEqual(self.tv.get_children(), ()) self.assertEqual(self.tv.get_children(item_id), ()) def test_exists(self): self.assertEqual(self.tv.exists('something'), False) self.assertEqual(self.tv.exists(''), True) self.assertEqual(self.tv.exists({}), False) # the following will make a tk.call equivalent to # tk.call(treeview, "exists") which should result in an error # in the tcl interpreter since tk requires an item. self.assertRaises(tkinter.TclError, self.tv.exists, None) def test_focus(self): # nothing is focused right now self.assertEqual(self.tv.focus(), '') item1 = self.tv.insert('', 'end') self.tv.focus(item1) self.assertEqual(self.tv.focus(), item1) self.tv.delete(item1) self.assertEqual(self.tv.focus(), '') # try focusing inexistent item self.assertRaises(tkinter.TclError, self.tv.focus, 'hi') def test_heading(self): # check a dict is returned self.assertIsInstance(self.tv.heading('#0'), dict) # check a value is returned self.tv.heading('#0', text='hi') self.assertEqual(self.tv.heading('#0', 'text'), 'hi') self.assertEqual(self.tv.heading('#0', text=None), 'hi') # invalid option self.assertRaises(tkinter.TclError, self.tv.heading, '#0', background=None) # invalid value self.assertRaises(tkinter.TclError, self.tv.heading, '#0', anchor=1) def test_heading_callback(self): def simulate_heading_click(x, y): simulate_mouse_click(self.tv, x, y) self.tv.update() success = [] # no success for now self.tv.pack() self.tv.wait_visibility() self.tv.heading('#0', command=lambda: success.append(True)) self.tv.column('#0', width=100) self.tv.update() # assuming that the coords (5, 5) fall into heading #0 simulate_heading_click(5, 5) if not success: self.fail("The command associated to the treeview heading wasn't " "invoked.") success = [] commands = self.tv.master._tclCommands self.tv.heading('#0', command=str(self.tv.heading('#0', command=None))) self.assertEqual(commands, self.tv.master._tclCommands) simulate_heading_click(5, 5) if not success: self.fail("The command associated to the treeview heading wasn't " "invoked.") # XXX The following raises an error in a tcl interpreter, but not in # Python #self.tv.heading('#0', command='I dont exist') #simulate_heading_click(5, 5) def test_index(self): # item 'what' doesn't exist self.assertRaises(tkinter.TclError, self.tv.index, 'what') self.assertEqual(self.tv.index(''), 0) item1 = self.tv.insert('', 'end') item2 = self.tv.insert('', 'end') c1 = self.tv.insert(item1, 'end') c2 = self.tv.insert(item1, 'end') self.assertEqual(self.tv.index(item1), 0) self.assertEqual(self.tv.index(c1), 0) self.assertEqual(self.tv.index(c2), 1) self.assertEqual(self.tv.index(item2), 1) self.tv.move(item2, '', 0) self.assertEqual(self.tv.index(item2), 0) self.assertEqual(self.tv.index(item1), 1) # check that index still works even after its parent and siblings # have been detached self.tv.detach(item1) self.assertEqual(self.tv.index(c2), 1) self.tv.detach(c1) self.assertEqual(self.tv.index(c2), 0) # but it fails after item has been deleted self.tv.delete(item1) self.assertRaises(tkinter.TclError, self.tv.index, c2) def test_insert_item(self): # parent 'none' doesn't exist self.assertRaises(tkinter.TclError, self.tv.insert, 'none', 'end') # open values self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', open='') self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', open='please') self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=True))) self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=False))) # invalid index self.assertRaises(tkinter.TclError, self.tv.insert, '', 'middle') # trying to duplicate item id is invalid itemid = self.tv.insert('', 'end', 'first-item') self.assertEqual(itemid, 'first-item') self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', 'first-item') self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', MockTclObj('first-item')) # unicode values value = u'\xe1ba' item = self.tv.insert('', 'end', values=(value, )) self.assertEqual(self.tv.item(item, 'values'), (value,) if self.wantobjects else value) self.assertEqual(self.tv.item(item, values=None), (value,) if self.wantobjects else value) self.tv.item(item, values=self.root.splitlist(self.tv.item(item, values=None))) self.assertEqual(self.tv.item(item, values=None), (value,) if self.wantobjects else value) self.assertIsInstance(self.tv.item(item), dict) # erase item values self.tv.item(item, values='') self.assertFalse(self.tv.item(item, values=None)) # item tags item = self.tv.insert('', 'end', tags=[1, 2, value]) self.assertEqual(self.tv.item(item, tags=None), ('1', '2', value) if self.wantobjects else '1 2 %s' % value) self.tv.item(item, tags=[]) self.assertFalse(self.tv.item(item, tags=None)) self.tv.item(item, tags=(1, 2)) self.assertEqual(self.tv.item(item, tags=None), ('1', '2') if self.wantobjects else '1 2') # values with spaces item = self.tv.insert('', 'end', values=('a b c', '%s %s' % (value, value))) self.assertEqual(self.tv.item(item, values=None), ('a b c', '%s %s' % (value, value)) if self.wantobjects else '{a b c} {%s %s}' % (value, value)) # text self.assertEqual(self.tv.item( self.tv.insert('', 'end', text="Label here"), text=None), "Label here") self.assertEqual(self.tv.item( self.tv.insert('', 'end', text=value), text=None), value) # test for values which are not None itemid = self.tv.insert('', 'end', 0) self.assertEqual(itemid, '0') itemid = self.tv.insert('', 'end', 0.0) self.assertEqual(itemid, '0.0') # this is because False resolves to 0 and element with 0 iid is already present self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', False) self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end', '') def test_selection(self): # item 'none' doesn't exist self.assertRaises(tkinter.TclError, self.tv.selection_set, 'none') self.assertRaises(tkinter.TclError, self.tv.selection_add, 'none') self.assertRaises(tkinter.TclError, self.tv.selection_remove, 'none') self.assertRaises(tkinter.TclError, self.tv.selection_toggle, 'none') item1 = self.tv.insert('', 'end') item2 = self.tv.insert('', 'end') c1 = self.tv.insert(item1, 'end') c2 = self.tv.insert(item1, 'end') c3 = self.tv.insert(item1, 'end') self.assertEqual(self.tv.selection(), ()) self.tv.selection_set((c1, item2)) self.assertEqual(self.tv.selection(), (c1, item2)) self.tv.selection_set(c2) self.assertEqual(self.tv.selection(), (c2,)) self.tv.selection_add((c1, item2)) self.assertEqual(self.tv.selection(), (c1, c2, item2)) self.tv.selection_add(item1) self.assertEqual(self.tv.selection(), (item1, c1, c2, item2)) self.tv.selection_remove((item1, c3)) self.assertEqual(self.tv.selection(), (c1, c2, item2)) self.tv.selection_remove(c2) self.assertEqual(self.tv.selection(), (c1, item2)) self.tv.selection_toggle((c1, c3)) self.assertEqual(self.tv.selection(), (c3, item2)) self.tv.selection_toggle(item2) self.assertEqual(self.tv.selection(), (c3,)) self.tv.insert('', 'end', id='with spaces') self.tv.selection_set('with spaces') self.assertEqual(self.tv.selection(), ('with spaces',)) self.tv.insert('', 'end', id='{brace') self.tv.selection_set('{brace') self.assertEqual(self.tv.selection(), ('{brace',)) if have_unicode: self.tv.insert('', 'end', id=u(r'unicode\u20ac')) self.tv.selection_set(u(r'unicode\u20ac')) self.assertEqual(self.tv.selection(), (u(r'unicode\u20ac'),)) self.tv.insert('', 'end', id='bytes\xe2\x82\xac') self.tv.selection_set('bytes\xe2\x82\xac') self.assertEqual(self.tv.selection(), (u(r'bytes\u20ac') if have_unicode else 'bytes\xe2\x82\xac',)) def test_set(self): self.tv['columns'] = ['A', 'B'] item = self.tv.insert('', 'end', values=['a', 'b']) self.assertEqual(self.tv.set(item), {'A': 'a', 'B': 'b'}) self.tv.set(item, 'B', 'a') self.assertEqual(self.tv.item(item, values=None), ('a', 'a') if self.wantobjects else 'a a') self.tv['columns'] = ['B'] self.assertEqual(self.tv.set(item), {'B': 'a'}) self.tv.set(item, 'B', 'b') self.assertEqual(self.tv.set(item, column='B'), 'b') self.assertEqual(self.tv.item(item, values=None), ('b', 'a') if self.wantobjects else 'b a') self.tv.set(item, 'B', 123) self.assertEqual(self.tv.set(item, 'B'), 123 if self.wantobjects else '123') self.assertEqual(self.tv.item(item, values=None), (123, 'a') if self.wantobjects else '123 a') self.assertEqual(self.tv.set(item), {'B': 123} if self.wantobjects else {'B': '123'}) # inexistent column self.assertRaises(tkinter.TclError, self.tv.set, item, 'A') self.assertRaises(tkinter.TclError, self.tv.set, item, 'A', 'b') # inexistent item self.assertRaises(tkinter.TclError, self.tv.set, 'notme') def test_tag_bind(self): events = [] item1 = self.tv.insert('', 'end', tags=['call']) item2 = self.tv.insert('', 'end', tags=['call']) self.tv.tag_bind('call', '', lambda evt: events.append(1)) self.tv.tag_bind('call', '', lambda evt: events.append(2)) self.tv.pack() self.tv.wait_visibility() self.tv.update() pos_y = set() found = set() for i in range(0, 100, 10): if len(found) == 2: # item1 and item2 already found break item_id = self.tv.identify_row(i) if item_id and item_id not in found: pos_y.add(i) found.add(item_id) self.assertEqual(len(pos_y), 2) # item1 and item2 y pos for y in pos_y: simulate_mouse_click(self.tv, 0, y) # by now there should be 4 things in the events list, since each # item had a bind for two events that were simulated above self.assertEqual(len(events), 4) for evt in zip(events[::2], events[1::2]): self.assertEqual(evt, (1, 2)) def test_tag_configure(self): # Just testing parameter passing for now self.assertRaises(TypeError, self.tv.tag_configure) self.assertRaises(tkinter.TclError, self.tv.tag_configure, 'test', sky='blue') self.tv.tag_configure('test', foreground='blue') self.assertEqual(str(self.tv.tag_configure('test', 'foreground')), 'blue') self.assertEqual(str(self.tv.tag_configure('test', foreground=None)), 'blue') self.assertIsInstance(self.tv.tag_configure('test'), dict) def test_tag_has(self): item1 = self.tv.insert('', 'end', text='Item 1', tags=['tag1']) item2 = self.tv.insert('', 'end', text='Item 2', tags=['tag2']) self.assertRaises(TypeError, self.tv.tag_has) self.assertRaises(TclError, self.tv.tag_has, 'tag1', 'non-existing') self.assertTrue(self.tv.tag_has('tag1', item1)) self.assertFalse(self.tv.tag_has('tag1', item2)) self.assertFalse(self.tv.tag_has('tag2', item1)) self.assertTrue(self.tv.tag_has('tag2', item2)) self.assertFalse(self.tv.tag_has('tag3', item1)) self.assertFalse(self.tv.tag_has('tag3', item2)) self.assertEqual(self.tv.tag_has('tag1'), (item1,)) self.assertEqual(self.tv.tag_has('tag2'), (item2,)) self.assertEqual(self.tv.tag_has('tag3'), ()) @add_standard_options(StandardTtkOptionsTests) class SeparatorTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'cursor', 'orient', 'style', 'takefocus', # 'state'? ) default_orient = 'horizontal' def create(self, **kwargs): return ttk.Separator(self.root, **kwargs) @add_standard_options(StandardTtkOptionsTests) class SizegripTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'class', 'cursor', 'style', 'takefocus', # 'state'? ) def create(self, **kwargs): return ttk.Sizegrip(self.root, **kwargs) tests_gui = ( ButtonTest, CheckbuttonTest, ComboboxTest, EntryTest, FrameTest, LabelFrameTest, LabelTest, MenubuttonTest, NotebookTest, PanedWindowTest, ProgressbarTest, RadiobuttonTest, ScaleTest, ScrollbarTest, SeparatorTest, SizegripTest, TreeviewTest, WidgetTest, ) if __name__ == "__main__": run_unittest(*tests_gui) PK]test_ttk/__init__.pynu[PK]@ Stest_ttk/support.pyonu[ zfc@sddlZddlZddlZddlZdddYZdZdZddlZe e e ej j dZdZdadZid d d 6d d 6d d d6dd6ZdZdZdZdS(iNtAbstractTkTestcBs8eZedZedZdZdZRS(cCstj|_ttjtj|_|jj|_|jjdy|jj dt Wntj k r{nXdS(Ntnormals-zoomed( ttkintert_support_default_roott_old_support_default_roottdestroy_default_roott NoDefaultRoottTktroott wantobjectstwm_statet wm_attributestFalsetTclError(tcls((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt setUpClasss  cCs9|jj|jj|`dt_|jt_dS(N(Rtupdate_idletaskstdestroytNoneRt _default_rootRR(R((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt tearDownClasss    cCs|jjdS(N(Rt deiconify(tself((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytsetUpscCs5x!|jjD]}|jqW|jjdS(N(Rtwinfo_childrenRtwithdraw(Rtw((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyttearDown"s(t__name__t __module__t classmethodRRRR(((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyRs cCs<ttddr8tjjtjjdt_ndS(NR(tgetattrRRRRR(((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyR's  cCsh|jddddd|jdd|d||jdd|d||jdd|d|dS( sYGenerate proper events to click at the x, y position (tries to act like an X server).stxitysssN(tevent_generate(twidgetR R!((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytsimulate_mouse_click-st.csQtdkr>tjtkddjttSfd}|S(Nisrequires Tcl version >= R%cs%tjfd}|S(NcsCtkr5|jddjttn|dS(Nsrequires Tcl version >= R%(tget_tk_patchleveltskipTesttjointmaptstr(R(ttesttversion(s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytnewtest?s (t functoolstwraps(R+R-(R,(R+s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pytdeco>s!(tlentunittestt skipUnlesst tcl_versionR(R)R*(R,R0((R,s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt requires_tcl9s cCstdkrtj}|jdd}tjd|}|j\}}}}t|t|t|}}}idd6dd6dd 6|}|dkr||||d faq||d ||fantS( Ntinfot patchlevels(\d+)\.(\d+)([ab.])(\d+)$talphatatbetatbtfinalR%i( t_tk_patchlevelRRtTcltcalltretmatchtgroupstint(ttclR7tmtmajortminort releaseleveltserial((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyR&Is  & iHgRQ@tctigffffff9@REitpcCst|d t|dS(Ni(tfloattunits(tvalue((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt pixels_conv_scCs||krtSt|tjrDt|trDt||kSnt|trt|trt|t|kotdt||DSnt S(Ncss$|]\}}t||VqdS(N(t tcl_obj_eq(t.0tacttexp((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pys ks( tTruet isinstancet_tkintertTcl_ObjR*ttupleR1talltzipR (tactualtexpected((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyRQbs  cCs]||krtSt|ttjfrYt|ttjfrYt|t|kSntS(N(RURVR*RtWidgetR (R\R]((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyt widget_eqos  ((R.R@R2tTkinterRRRR$RWRYR)RCt TCL_VERSIONtsplitR4R5RR=R&RNRPRQR_(((s4/usr/lib64/python2.7/lib-tk/test/test_ttk/support.pyts&    !  !       PK]ܐb b test_ttk/test_style.pynu[import unittest import Tkinter as tkinter import ttk from test.test_support import requires, run_unittest from test_ttk.support import AbstractTkTest requires('gui') class StyleTest(AbstractTkTest, unittest.TestCase): def setUp(self): super(StyleTest, self).setUp() self.style = ttk.Style(self.root) def test_configure(self): style = self.style style.configure('TButton', background='yellow') self.assertEqual(style.configure('TButton', 'background'), 'yellow') self.assertIsInstance(style.configure('TButton'), dict) def test_map(self): style = self.style style.map('TButton', background=[('active', 'background', 'blue')]) self.assertEqual(style.map('TButton', 'background'), [('active', 'background', 'blue')] if self.wantobjects else [('active background', 'blue')]) self.assertIsInstance(style.map('TButton'), dict) def test_lookup(self): style = self.style style.configure('TButton', background='yellow') style.map('TButton', background=[('active', 'background', 'blue')]) self.assertEqual(style.lookup('TButton', 'background'), 'yellow') self.assertEqual(style.lookup('TButton', 'background', ['active', 'background']), 'blue') self.assertEqual(style.lookup('TButton', 'optionnotdefined', default='iknewit'), 'iknewit') def test_layout(self): style = self.style self.assertRaises(tkinter.TclError, style.layout, 'NotALayout') tv_style = style.layout('Treeview') # "erase" Treeview layout style.layout('Treeview', '') self.assertEqual(style.layout('Treeview'), [('null', {'sticky': 'nswe'})] ) # restore layout style.layout('Treeview', tv_style) self.assertEqual(style.layout('Treeview'), tv_style) # should return a list self.assertIsInstance(style.layout('TButton'), list) # correct layout, but "option" doesn't exist as option self.assertRaises(tkinter.TclError, style.layout, 'Treeview', [('name', {'option': 'inexistent'})]) def test_theme_use(self): self.assertRaises(tkinter.TclError, self.style.theme_use, 'nonexistingname') curr_theme = self.style.theme_use() new_theme = None for theme in self.style.theme_names(): if theme != curr_theme: new_theme = theme self.style.theme_use(theme) break else: # just one theme available, can't go on with tests return self.assertFalse(curr_theme == new_theme) self.assertFalse(new_theme != self.style.theme_use()) self.style.theme_use(curr_theme) tests_gui = (StyleTest, ) if __name__ == "__main__": run_unittest(*tests_gui) PK]T+ + runtktests.pycnu[ zfc@sdZddlZddlZddlZddlZddlZejjejj e Z dZ e e ddZe e ddZedkrejjendS(s Use this module to get and run all tk tests. Tkinter tests should live in a package inside the directory where this file lives, like test_tkinter. Extensions also should live in packages following the same rule as above. iNcCs.x'tj|D]}|dkrtSqWtS(Ns __init__.pys __init__.pycs __init.pyo(s __init__.pys __init__.pycs __init.pyo(tostlistdirtTruetFalse(tpathtname((s./usr/lib64/python2.7/lib-tk/test/runtktests.pyt is_packages c #s-dx tj|D]\}}}x4t|D]&}|ddkr2|j|q2q2Wt|r|r|t|ttjjdd}|r||krqntfd|}x[|D]P}y$t j d|t |VWqt j j k r|rqqXqWqqWdS(sThis will import and yield modules whose names start with test_ and are inside packages found in the path starting at basepath. If packages is specified it should contain package names that want their tests collected. s.pyit.t/cs|jdo|jS(Nttest_(t startswithtendswith(tx(tpy_ext(s./usr/lib64/python2.7/lib-tk/test/runtktests.pyt+ts.%sN(RtwalktlisttremoveRtlentseptreplacetfiltert importlibt import_modulettestt test_supporttResourceDenied( tbasepathtguitpackagestdirpathtdirnamest filenamestdirnametpkg_nameR((R s./usr/lib64/python2.7/lib-tk/test/runtktests.pytget_tests_moduless&)   ccsg}|r|jdn|r2|jdnxPtd|d|D]9}x0|D](}xt||dD] }|VqnWqUWqHWdS(sYield all the tests in the modules found by get_tests_modules. If nogui is True, only tests that do not require a GUI will be returned.t tests_noguit tests_guiRRN((tappendR$tgetattr(ttextRRtattrstmoduletattrR((s./usr/lib64/python2.7/lib-tk/test/runtktests.pyt get_tests6s t__main__(t__doc__RtsystunittestRttest.test_supportRRtabspathR"t__file__t this_dir_pathRRtNoneR$R-t__name__Rt run_unittest(((s./usr/lib64/python2.7/lib-tk/test/runtktests.pyts       PK]0<477test_tkinter/test_text.pycnu[ zfc@sddlZddlZddlmZmZddlmZeddeejfdYZ e fZ e dkree ndS(iN(trequirest run_unittest(tAbstractTkTesttguitTextTestcBs#eZdZdZdZRS(cCs,tt|jtj|j|_dS(N(tsuperRtsetUpttkintertTexttrootttext(tself((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyR scCs|j}|j}zJ|jd|j|jd|jd|j|jdWd|j||j|j|XdS(Nii(R tdebugt assertEqual(R R tolddebug((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyt test_debugs     cCs|j}|jtj|jdd|jtj|jdd|jtj|jdd|jtj|jdd|jdd|j|jdddd|j|jd ddd dS( Ns1.0tatishi-tests-testtends1.2ttests1.3(R t assertRaisesRtTclErrortsearchtNonetinsertR (R R ((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyt test_searchs (t__name__t __module__RRR(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyRs  t__main__( tunittesttTkinterRttest.test_supportRRttest_ttk.supportRtTestCaseRt tests_guiR(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyts   $  PK]0<477test_tkinter/test_text.pyonu[ zfc@sddlZddlZddlmZmZddlmZeddeejfdYZ e fZ e dkree ndS(iN(trequirest run_unittest(tAbstractTkTesttguitTextTestcBs#eZdZdZdZRS(cCs,tt|jtj|j|_dS(N(tsuperRtsetUpttkintertTexttrootttext(tself((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyR scCs|j}|j}zJ|jd|j|jd|jd|j|jdWd|j||j|j|XdS(Nii(R tdebugt assertEqual(R R tolddebug((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyt test_debugs     cCs|j}|jtj|jdd|jtj|jdd|jtj|jdd|jtj|jdd|jdd|j|jdddd|j|jd ddd dS( Ns1.0tatishi-tests-testtends1.2ttests1.3(R t assertRaisesRtTclErrortsearchtNonetinsertR (R R ((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyt test_searchs (t__name__t __module__RRR(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyRs  t__main__( tunittesttTkinterRttest.test_supportRRttest_ttk.supportRtTestCaseRt tests_guiR(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_text.pyts   $  PK]-ԠԠ'test_tkinter/test_geometry_managers.pyonu[ zfc@sddlZddlZddlZddlmZddlmZmZddlm Z m Z m Z ddl m Z mZedde ejfdYZd e ejfd YZd e ejfd YZeeefZed kreendS(iN(tTclError(trequirest run_unittest(t pixels_convt tcl_versiont requires_tcl(tAbstractWidgetTestt int_roundtguitPackTestcBseZd ZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd ZRS(c Cstj|jdd}|jd|jddtj|dddddd d d }tj|dd dd ddd d}tj|ddddddd d}tj|dddd ddd d}|||||fS(Ntnametpacks 300x200+0+0itatwidthitheighti(tbgtredtbi2itbluetciPtgreentdtyellow(ttkintertTopleveltroott wm_geometryt wm_minsizetFrame(tselfR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pytcreate2s ''''cCs;|j\}}}}}|jtd||jd|WdQX|jtd|jddWdQX|jdd|jdd|jdd|jdd|j|j||||g|jd||j|j||||g|jd||j|j||||gdS(Nswindow "%s" isn't packedtaftersbad window path name ".foo"s.footsidettop(RtassertRaisesRegexpRtpack_configuret assertEqualt pack_slaves(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_afters""csj\}}}}fd}|dd|dd|dd|dd |d d |d d |dd|dd|dddS(Ncs[jddddddddd d d td |jjjj|dS( NR R!tipadxitpadxi tipadyitpadyitexpandtanchor(R#tTrueRtupdateR$twinfo_geometry(R,tgeom(R R(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pytcheck-s'  tns 30x70+135+20tnes 30x70+260+20tes 30x70+260+65tses 30x70+260+110tss 30x70+135+110tsws 30x70+10+110tws 30x70+10+65tnws 30x70+10+20tcenters 30x70+135+65(R(RR RRRR1((R RsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_anchor+s        cCs;|j\}}}}}|jtd||jd|WdQX|jtd|jddWdQX|jdd|jdd|jdd|jdd|j|j||||g|jd||j|j||||g|jd||j|j||||gdS(Nswindow "%s" isn't packedtbeforesbad window path name ".foo"s.fooR R!(RR"RR#R$R%(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_before<s""cs{j\}fd}jddjddjddjdd|ddd d jddd d jddd d jddd tjddd d|ddddjddd d ddjddd d ddjddd tddjddd ddd|dddddS(Ncsyjjjj|djj|djj|djj|ddS(Niiii(RR.R$R/(tgeoms(R RRRR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1Ns  R tleftR!trighttbottoms 20x40+0+80s 50x30+135+0s 80x80+220+75s 40x30+100+170R+tyestonis 20x40+40+80s 50x30+175+35s 80x80+180+110s 40x30+100+135tfilltboths 100x200+0+0s 200x100+100+0s160x100+140+100s40x100+100+100(RR#R-(RR R1((R RRRRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_expandLs"cCs2|j\}}}}}|jdd|jdd|jdd|jdd|jd||j|j||||g|jd||j|j|||g|j|j|g|jtd|f|jd|WdQX|jtd|jddWdQXdS(NR R!tin_scan't pack %s inside itselfsbad window path name ".foo"s.foo(RR#R$R%R"R(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_inds" c sj\}}}fd}|dddddd|dddddd'|d dddd d|d dddd ddd |dddddddd|dddddd(dd|d dddd ddd|d dddd ddd dd|ddddd ddd)dd|dddddd|dddddd*|ddddd d|ddddd ddd |ddddd ddd+|d ddddddd|d!ddddd,dd|d#dddd ddd|d$dddd ddd dd|d%dddd ddd-ddjdd&jjdj|jd&jd d&jjd j|jd&dS(.Ncstjjj|jdtddjjjj|jj|dS(NR+RDRE(t pack_forgetR#R-RR.R$R/(tgeom1tgeom2tkwargs(R RR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1ws    s 20x40+260+80s 240x200+0+0R R@R(is 20x40+250+80i is 60x40+240+80R's 30x40+260+80s 250x200+0+0iRDtxs 20x40+249+80i is 30x40+255+80is 20x40+140+0s 300x160+0+40R!s 20x40+120+0ii(s 60x40+120+0s 30x40+135+0s 30x40+130+0s 260x40+20+0s 260x40+25+0is 300x40+0+0s 280x40+10+0s 280x40+5+0t1c(i i(i i(ii(ii((ii(ii(ii(RR#R$t pack_infot_strt winfo_pixels(RR RRR1((R RRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt#test_pack_configure_padx_ipadx_fillusB      c sj\}}}fd}|dddddd|dddddd'|d dddd d|d dddd ddd |dddddddd|dddddd(dd|d dddd ddd|d dddd ddd dd|ddddd ddd)dd|dddddd|dddddd*|ddddd d|ddddd ddd |ddddd ddd+|d ddddddd|d!ddddd,dd|d#dddd ddd|d$dddd ddd dd|d%dddd ddd-ddjdd&jjdj|jd&jd d&jjd j|jd&dS(.Ncstjjj|jdtddjjjj|jj|dS(NR+RDRE(RIR#R-RR.R$R/(RJRKRL(R RR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1s    s 20x40+280+80s 280x200+0+0R R@R*is 20x40+280+70i is 20x80+280+60R)s 20x50+280+75iRDRMs 20x40+280+69i is 20x50+280+70is 20x40+140+20s 300x120+0+80R!s 20x40+140+0ii(s 20x80+140+0s 20x50+140+10s 300x130+0+70s 20x50+140+5s 300x40+0+20s 300x40+0+25is 300x80+0+0s 300x50+0+10s 300x50+0+5RN(i i(i i(ii(ii((ii(ii(ii(RR#R$RORPRQ(RR RRR1((R RRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt#test_pack_configure_pady_ipady_fillsB      cstj\}}}fd}|ddd|ddd|dd d |d d d dS(Ncs}jd|jjd|jdtddjjjj|jj|dS(NR R+RDRE(R#R$ROR-RR.R/(R RJRK(R RR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1s  R!s 20x40+140+0s 300x160+0+40RAs 20x40+140+160s 300x160+0+0R?s 20x40+0+80s 280x200+20+0R@s 20x40+280+80s 280x200+0+0(R(RR RRR1((R RRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_sides cCs|j\}}}}}|j|j|j|j|j|||g|j|j|j||g|j|j|j||g|jdS(N(RR#R$R%RI(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_forgets     cCs|j\}}}}}|jtd||jWdQX|j|jddd|dddtdd d d d d dddd |j}|j|t|j|dd|j|d|j d|j|dd|j|d||j|d |j d|j|d|j d|j|d |j d|j|d|j d|j|dd|j}|j|t|j|dd|j|d|j d|j|dd |j|d||j|d |j d |j|d|j d|j|d |j d |j|d|j d|j|dddS(Nswindow "%s" isn't packedR R@RGR,R6R+RDRMR'iR(i R)iR*iR:itnonetinR!i(ii(ii( RR"RROR#R-tassertIsInstancetdictR$RP(RR R RRRtinfo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_infos8 '  cCs|j\}}}}}|jdddd|j|jt|jj|j|jd|j|j d|jt |jj|j|jd|j|j ddS(NR i,Riii(( Rt configureR#tpack_propagatetFalseRR.R$twinfo_reqwidthtwinfo_reqheightR-(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_propagates     cCs~|j\}}}}}|j|jg|j|j|j|g|j|j|j||gdS(N(RR$R%R#(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_slavess   N(t__name__t __module__tNonet test_keysRR&R;R=RFRHRRRSRTRUR[RaRb(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR s      * *   t PlaceTestcBseZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZRS(c Cstj|jdddddd}|jdtj|dddd dd d d }|jd dddtj|dddddd d d }|jj|||fS(NR i,Ritbdis 300x200+0+0iiTitrelieftraisedRMi0tyi&ii<(RRRRRtplace_configureR.(Rtttftf2((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRs$ '' cCs|j\}}}|j|jd|jtdtjt||jd|WdQXt d kr|j|jdn|jtd|jddWdQX|jd||j|jddS( Nts!can't place %s relative to itselfRGiisbad window path nametspamtplace(ii( RR$t winfo_managerR"RtretescapetstrRlR(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_in$s  c Cs5|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jddd d |j|jdd |jj|j|jd |jtd |jd|ddWdQXdS(NRGRMt0i2idt100iitrelxis-10isbad screen distance "spam"Rq( RRlR$t place_infoRR.twinfo_xR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_x1s   c Cs5|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jddd d |j|jdd |jj|j|jd |jtd |jd|ddWdQXdS(NRGRkRxi(i2t50iZitrelyis-10insbad screen distance "spam"Rq( RRlR$R{RR.twinfo_yR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_yBs   c Cs/|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jdd|j|jdd |jj|j|jd |jtd |jd|dd WdQXdS( NRGRzRxi2g?s0.5i}it1is-expected floating-point number but got "spam"Rq( RRlR$R{RR.R|R"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relxSs   c Cs/|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jdd|j|jdd |jj|j|jd |jtd |jd|dd WdQXdS( NRGRRxi(g?s0.5iPiRixs-expected floating-point number but got "spam"Rq( RRlR$R{RR.RR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relyes   c Cstj|j}|jtd|jddWdQX|jtd|jddWdQXx8dD]0}|jd||j|jd|qkWdS(Nsbad anchor "j"R,tjsambiguous anchor ""RpR2R3R4R5R6R7R8R9R:( R2R3R4R5R6R7R8R9R:(RRRR"RRlR$R{(RRntvalue((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_anchorws cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS(NRGR ixRpisbad screen distance "abcd"tabcd(RRlRR.R$t winfo_widthR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_widths  cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS(NRGRixRpi<sbad screen distance "abcd"R(RRlRR.R$t winfo_heightR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_heights  cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS( NRGtrelwidthg?iKRpis-expected floating-point number but got "abcd"R(RRlRR.R$RR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relwidths  cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS( NRGt relheightg?i(Rpi<s-expected floating-point number but got "abcd"R(RRlRR.R$RR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relheights  cCstj|j}|jtd|jddWdQX|jtd|jddWdQXx8d D]0}|jd||j|jd|qkWdS( Nsbad bordermode "j"t bordermodeRsambiguous bordermode ""Rptinsidetoutsidetignore(RRR(RRRR"RRlR$R{(RRnR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_bordermodes cCstj|j}|jdddd|jj|j|jj|j|j|jt |jdWdQXdS(NR i2Ri( RRRRlR.t place_forgett assertFalsetwinfo_ismappedt assertRaisest TypeError(Rtfoo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_forgets   cCs|j\}}}|jd|dddddddd d d d d dddddddd |j}|j|t|j|dd|j|dd|j|dd|j|dd|j|d d|j|d d|j|dd|j|dd|j|dd|j|dd|j|dd|j|dd|jt|jdWdQXdS(NRGRMiRkiR iRiRzg?Rg?Rg333333?Rg?R,R5RRRt2t3t4s0.1s0.2s0.3s0.4i(RRlR{RXRYR$RR(RRmRnRoRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_infos('  cCstj|j}tj|j}|j|jg|jd||j|j|g|jt|jdWdQXdS(NRGi(RRRR$t place_slavesRlRR(RRtbar((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_slavessN(RcRdReRfRRwR}RRRRRRRRRRRR(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRgs      tGridTestcBseZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!RS(c Cs|jj\}}x@t|dD].}|jj|ddddddddq&Wx@t|dD].}|jj|ddddddddqiW|jjdtt|jdS(NitweightitminsizetpadtuniformRp( Rt grid_sizetrangetgrid_columnconfiguretgrid_rowconfiguretgrid_propagatetsuperRttearDown(Rtcolstrowsti((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRs,,cCstj|j}|j|ji|j|j|jd|j|j|jd|jd|j|jd|jd|jidd6dd|j|jd|jd|j|jd|jddS(NRWtcolumnitrowii(RtButtonRR$t grid_infotgrid_configureRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configures ###cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns5bad column value "-1": must be a non-negative integerRii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_columns cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns4bad columnspan value "0": must be a positive integert columnspanii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_columnspans cCstj|j}tj|j}|j|ji|j|j|jd|j|jd||j|jd||ji|jd6|j|jd|jdS(NRWRG(RRRRR$RR(RRnR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_in s cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jt t d|j dS(Ns6bad ipadx value "-1": must be positive screen distanceR'iis.5c( RRRR"RRR$RRPRRtscaling(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_ipadxs#cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jt t d|j dS(Ns6bad ipady value "-1": must be positive screen distanceR)iis.5c( RRRR"RRR$RRPRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_ipady!s#cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jd |jdd|j|jd|jt t d|j dS( Ns4bad pad value "-1": must be positive screen distanceR(iii is.5c(i i(i i( RRRR"RRR$RRPRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_padx,s##cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jd |jdd|j|jd|jt t d|j dS( Ns4bad pad value "-1": must be positive screen distanceR*iii is.5c(i i(i i( RRRR"RRR$RRPRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_pady9s##cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns9bad (row|grid) value "-1": must be a non-negative integerRii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_rowFs cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns1bad rowspan value "0": must be a positive integertrowspanii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_rownspanNs cCstj|jdd}|jtd|jddWdQX|jdd|j|jdd|jdd|j|jdddS( NRRsbad stickyness value "glue"tstickytglueR3sn,s,e,wtnesw(RRRR"RRR$R(RRn((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_stickyVsc Cs|jt|jjWdQX|j|jjdidd6dd6dd6dd6|jtd|jjddWdQX|jjddd |jtd |jjdWdQXtj |j}|j d dd dt dkr[|jjddd|jtd|jjdWdQX|j|jjdddn|j|jjddd |j|jjdddt dkr|jj|dd|j|jjdddndS(NiRRRRsbad option "-foo"Riis*must specify a single element on retrievalRRiitallsexpected integer but got "all"i i(ii(ii(ii(ii( RRRRR$ReR"RRRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_columnconfigure_s,#   " cCs|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRi (R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt!test_grid_columnconfigure_minsizews c Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsexpected integer but got "bad"iRtbads-invalid arg "-weight": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt test_grid_columnconfigure_weight~sc Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRs*invalid arg "-pad": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_columnconfigure_padscCsY|jjddd|j|jjddd|j|jjddddS(NiRR(RRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt!test_grid_columnconfigure_uniformsc Cs|jt|jjWdQX|j|jjdidd6dd6dd6dd6|jtd|jjddWdQX|jjddd |jtd |jjdWdQXtj |j}|j d dd dt dkr[|jjddd|jtd|jjdWdQX|j|jjdddn|j|jjddd |j|jjdddt dkr|jj|dd|j|jjdddndS(NiRRRRsbad option "-foo"Riis*must specify a single element on retrievalRRiiRsexpected integer but got "all"i i(ii(ii(ii(ii( RRRRR$ReR"RRRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigures,#   " cCs|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRi (R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_minsizes c Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsexpected integer but got "bad"iRRs-invalid arg "-weight": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_weightsc Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRs*invalid arg "-pad": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_padscCsY|jjddd|j|jjddd|j|jjddddS(NiRR(RRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_uniformscCstj|j}tj|j}|jdddddddddddd d d |j|jj|g|j|j|j|jjg|j|ji|jdd dd |j}|j|d|jd |j|d|jd |j|d|jd |j|d|jd |j|d|jd |j|d|jd |j|d ddS(NRiRRRR(iR*iRtnsiiRp( RRRRR$t grid_slavest grid_forgetRRP(RRRRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_forgets$!   cCstj|j}tj|j}|jdddddddddddd d d |j|jj|g|j|j|j|jjg|j|ji|jdd dd |j}|j|d|jd |j|d|jd |j|d|jd|j|d|jd|j|d|jd|j|d|jd |j|d d dS( NRiRRRR(iR*iRRi( RRRRR$Rt grid_removeRRP(RRRRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_removes$!   cCsUtj|j}|j|ji|jdddddddddddd d d |j}|j|t|j|d |j|j|d|jd|j|d|jd|j|d|jd|j|d|jd|j|d|jd|j|d|jd |j|d d dS( NRiRRRR(iR*iRRRW( RRRR$RRRXRYRP(RRRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_infos! cCs|j|jjd|j|jjddd|j|jjddddd|jtd|jjddWdQX|jtd|jjddWdQX|jtd|jjddddWdQX|jtd|jjddddWdQX|jt!|jjdddddWdQX|j}|jd|jdtj |ddd dd d }tj |dd d d d d }|j dddd|j dddd|jj |j|jd|j|jddd|j|jddddd|j|jddd|j|jddddd|j|jddddd|j|jddddddS(Niisexpected integer but got "x"RMs1x1+0+0RpR iKRRRiZRRRii iii (iiii(iiii(iiii(iiii(iiiKiK(iiii(iKiKiZiZ(iiii(iiii(iiii( R$Rt grid_bboxR"RRRRRRRR.(RRmtf1Ro((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_bboxs8%"   !! """cCs|jt|jjWdQX|jt|jjdWdQX|jt|jjdddWdQX|jtd|jjddWdQX|jtd|jjddWdQX|j}|jd|jdtj|d d d d d ddd}|j |jddd|j |jj |j |jddd|j |jddd|j |jddd|j |jddd|j |jddd|j |jddd|j |jd dd|j |jddd|j |jdd d|j |jddd |j |jddd!dS("Nisbad screen distance "x"RMRksbad screen distance "y"RNs1x1+0+0RpR iRidthighlightthicknessRRi iiiiie(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii( RRRt grid_locationR"RRRRR$RR.(RRmRn((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_location&s:     c Cs|j|jjt|jt|jjttWdQX|jjt|j|jjtj |jdddddd}|j dddd|jj |j|j d|j|j d|jttj |jdd dd dd }|j d |dddd|jj |j|j d|j|j d|jt|jj |j|j d |j|j d dS( NR idRRRRiRiKiURRG(R$RRR-RRR^RRRRR.RR(RRntg((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_propagateFs($  $   cCs|jt|jjdWdQX|j|jjdtj|j}|jdddd|j|jjd |jdddd|j|jjd dS( NiRRiiii(ii(ii(ii(RRRRR$RtScaleR(RRn((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_size\scCs|j|jjgtj|j}|jddddtj|j}|jddddtj|j}|jddddtj|j}|jdddd|j|jj||||g|j|jjdd|g|j|jjdd|||g|j|jjdd|g|j|jjdd|||g|j|jjdddd||gdS(NRiRi(R$RRRtLabelR(RR RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_slavesfs%"("(N("RcRdReRfRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRs>                t__main__(tunittestRttTkinterRRttest.test_supportRRttest_ttk.supportRRRt widget_testsRRtTestCaseR RgRt tests_guiRc(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyts      PK]TDtest_tkinter/__init__.pycnu[ zfc@sdS(N((((s9/usr/lib64/python2.7/lib-tk/test/test_tkinter/__init__.pyttPK]=,,test_tkinter/test_variables.pycnu[ zfc@sddlZddlZddlmZmZmZmZmZmZm Z dej fdYZ de fdYZ de fdYZ d e fd YZd e fd YZd e fdYZe e eeefZedkrddlmZeendS(iN(tVariablet StringVartIntVart DoubleVart BooleanVartTcltTclErrortTestBasecBseZdZdZRS(cCst|_dS(N(Rtroot(tself((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pytsetUp scCs |`dS(N(R(R ((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttearDown s(t__name__t __module__R R (((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRs t TestVariablecBsYeZdZdZdZdZdZdZdZdZ dZ RS( cGs"|jj|jjdd|S(Ntinfotexists(Rt getbooleantcall(R targs((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt info_existsscCs?t|j}|jd|j|jt|ddS(Nts ^PY_VAR(\d+)$(RRt assertEqualtgettassertRegexpMatcheststr(R tv((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test_defaultscCsEt|jdd}|jd|j|jdt|dS(Ns sample stringtvarname(RRRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_name_and_valuescCs^|j|jdt|jdd}|j|jd~|j|jddS(NRs sample string(t assertFalseRRRt assertTrue(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test___del__s cCsv|j|jdt|jdd}t|jdd}~|j|jd~|j|jddS(NRtname(RRRR(R tv1tv2((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_dont_unset_not_existing&scCsxt|jdd}t|jdd}|j||t|jdd}t|jdd}|j||dS(NR!tabc(RRRRtassertNotEqual(R R"R#tv3tv4((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test___eq__0s cCs-|jtt|jddWdQXdS(NR!i{(t assertRaisest TypeErrorRR(R ((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_invalid_name:sc Cs|jtt|jddWdQX|jt|jjddWdQX|jt|jjddWdQXdS(NR!svarnametvalue(R*t ValueErrorRRt globalsetvartsetvar(R ((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_null_in_name>s csot|j}t|}gfd}fd}|jd|}|jd|}|jt|jd|fd|fg|jg|jd|jd|ddfgg|j|jd |ddfggt|j}|j d||jt|j||j t |j ddWdQX|jt|j||j d|d f|jt|j||j|jd |ddfgg|j d||j|jd|fg|j|jgg~t j |jd |jd|ddfgdS( Ncsjd|dS(Ntread(R2(tappend(R(ttrace(s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt read_tracerJscsjd|dS(Ntwrite(R6(R3(R(R4(s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt write_tracerLstrtwutspamR6RtwR2i+teggs(RRRttrace_variableRtsortedt trace_vinfotsetRt trace_vdeleteR*Rtgctcollect(R RtvnameR5R7tcb1tcb2R((R4s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test_traceFsF .      ( R R RRRR R$R)R,R1RG(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRs      t TestStringVarcBs#eZdZdZdZRS(cCs)t|j}|jd|jdS(NR(RRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRzscCsXt|jdd}|jd|j|jjdd|jd|jdS(NR%R!R-(RRRRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_get~scCsXt|jdd}|jd|j|jjdd|jd|jdS(NsabcdefR!svalue(RRRRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test_get_nulls(R R RRIRJ(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRHxs  t TestIntVarcBs#eZdZdZdZRS(cCs)t|j}|jd|jdS(Ni(RRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRscCsXt|jdd}|jd|j|jjdd|jd|jdS(Ni{R!t345iY(RRRRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRIscCst|jdd}|jjdd|jt|jWdQX|jjdd|jt|jWdQXdS(NR!R-s345.0(RRR/R*R.R(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_invalid_values(R R RRIRM(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRKs  t TestDoubleVarcBs,eZdZdZdZdZRS(cCs)t|j}|jd|jdS(Ng(RRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRscCsXt|jdd}|jd|j|jjdd|jd|jdS(NgGz?R!s3.45g @(RRtassertAlmostEqualRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRIscCst|jdd}|jd|j|jjdd|jd|j|jjdd|jd|jdS(NgGz?R!s3.45g @t456i(RRRORR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_get_from_ints cCsLt|jdd}|jjdd|jt|jWdQXdS(NR!R-(RRR/R*R.R(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRMs(R R RRIRQRM(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRNs   tTestBooleanVarcBs,eZdZdZdZdZRS(cCs)t|j}|j|jtdS(N(RRtassertIsRtFalse(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRscCst|jtd}|j|jt|jjdd|j|jt|jjd|jjrudnd|j|jt|jjdd|j|jt|jjd|jjrdnd|j|jt|jjdd|j|jt|jjdd |j|jt|jjdd |j|jt|jjdd |j|jtdS( NR!t0i*iil*lltonu0uon(RRtTrueRSRR/RTt wantobjects(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRIs$((cCs|jjrdnd}|jjr0dnd}t|jdd}|jt|j|jjd||jd|j|jjd||jd|j|jjd||jd|j|jjd||jd|j|jjd||jd|j|jjd||jd |j|jjd||jd |j|jjd||jd |j|jjd|dS( Nit1iRUR!i*l*lRVu0uon(RRXRR@RWRt globalgetvar(R ttruetfalseR((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_sets*         cCs|jjrdnd}t|jdd}|jt|jdWdQX|j|jjd||jjdd|jt|j WdQX|jjdd|jt|j WdQXdS(NiRUR!R-s1.0( RRXRR*RR@RRZR/R(R R\R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_invalid_value_domains(R R RRIR]R^(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRRs   t__main__(t run_unittest(tunittestRBtTkinterRRRRRRRtTestCaseRRRHRKRNRRt tests_guiR t test.supportR`(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyts  4 h?   PK]TDtest_tkinter/__init__.pyonu[ zfc@sdS(N((((s9/usr/lib64/python2.7/lib-tk/test/test_tkinter/__init__.pyttPK]prtest_tkinter/test_font.pynu[import unittest import Tkinter as tkinter import tkFont as font from test.test_support import requires, run_unittest, gc_collect from test_ttk.support import AbstractTkTest requires('gui') fontname = "TkDefaultFont" class FontTest(AbstractTkTest, unittest.TestCase): @classmethod def setUpClass(cls): AbstractTkTest.setUpClass.__func__(cls) try: cls.font = font.Font(root=cls.root, name=fontname, exists=True) except tkinter.TclError: cls.font = font.Font(root=cls.root, name=fontname, exists=False) def test_configure(self): options = self.font.configure() self.assertGreaterEqual(set(options), {'family', 'size', 'weight', 'slant', 'underline', 'overstrike'}) for key in options: self.assertEqual(self.font.cget(key), options[key]) self.assertEqual(self.font[key], options[key]) for key in 'family', 'weight', 'slant': self.assertIsInstance(options[key], str) self.assertIsInstance(self.font.cget(key), str) self.assertIsInstance(self.font[key], str) sizetype = int if self.wantobjects else str for key in 'size', 'underline', 'overstrike': self.assertIsInstance(options[key], sizetype) self.assertIsInstance(self.font.cget(key), sizetype) self.assertIsInstance(self.font[key], sizetype) def test_unicode_family(self): family = u'MS \u30b4\u30b7\u30c3\u30af' try: f = font.Font(root=self.root, family=family, exists=True) except tkinter.TclError: f = font.Font(root=self.root, family=family, exists=False) self.assertEqual(f.cget('family'), family) del f gc_collect() def test_actual(self): options = self.font.actual() self.assertGreaterEqual(set(options), {'family', 'size', 'weight', 'slant', 'underline', 'overstrike'}) for key in options: self.assertEqual(self.font.actual(key), options[key]) for key in 'family', 'weight', 'slant': self.assertIsInstance(options[key], str) self.assertIsInstance(self.font.actual(key), str) sizetype = int if self.wantobjects else str for key in 'size', 'underline', 'overstrike': self.assertIsInstance(options[key], sizetype) self.assertIsInstance(self.font.actual(key), sizetype) def test_name(self): self.assertEqual(self.font.name, fontname) self.assertEqual(str(self.font), fontname) def test_eq(self): font1 = font.Font(root=self.root, name=fontname, exists=True) font2 = font.Font(root=self.root, name=fontname, exists=True) self.assertIsNot(font1, font2) self.assertEqual(font1, font2) self.assertNotEqual(font1, font1.copy()) self.assertNotEqual(font1, 0) self.assertNotIn(font1, [0]) def test_measure(self): self.assertIsInstance(self.font.measure('abc'), int) def test_metrics(self): metrics = self.font.metrics() self.assertGreaterEqual(set(metrics), {'ascent', 'descent', 'linespace', 'fixed'}) for key in metrics: self.assertEqual(self.font.metrics(key), metrics[key]) self.assertIsInstance(metrics[key], int) self.assertIsInstance(self.font.metrics(key), int) def test_families(self): families = font.families(self.root) self.assertIsInstance(families, tuple) self.assertTrue(families) for family in families: self.assertIsInstance(family, (str, unicode)) self.assertTrue(family) def test_names(self): names = font.names(self.root) self.assertIsInstance(names, tuple) self.assertTrue(names) for name in names: self.assertIsInstance(name, (str, unicode)) self.assertTrue(name) self.assertIn(fontname, names) tests_gui = (FontTest, ) if __name__ == "__main__": run_unittest(*tests_gui) PK]=,,test_tkinter/test_variables.pyonu[ zfc@sddlZddlZddlmZmZmZmZmZmZm Z dej fdYZ de fdYZ de fdYZ d e fd YZd e fd YZd e fdYZe e eeefZedkrddlmZeendS(iN(tVariablet StringVartIntVart DoubleVart BooleanVartTcltTclErrortTestBasecBseZdZdZRS(cCst|_dS(N(Rtroot(tself((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pytsetUp scCs |`dS(N(R(R ((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttearDown s(t__name__t __module__R R (((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRs t TestVariablecBsYeZdZdZdZdZdZdZdZdZ dZ RS( cGs"|jj|jjdd|S(Ntinfotexists(Rt getbooleantcall(R targs((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt info_existsscCs?t|j}|jd|j|jt|ddS(Nts ^PY_VAR(\d+)$(RRt assertEqualtgettassertRegexpMatcheststr(R tv((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test_defaultscCsEt|jdd}|jd|j|jdt|dS(Ns sample stringtvarname(RRRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_name_and_valuescCs^|j|jdt|jdd}|j|jd~|j|jddS(NRs sample string(t assertFalseRRRt assertTrue(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test___del__s cCsv|j|jdt|jdd}t|jdd}~|j|jd~|j|jddS(NRtname(RRRR(R tv1tv2((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_dont_unset_not_existing&scCsxt|jdd}t|jdd}|j||t|jdd}t|jdd}|j||dS(NR!tabc(RRRRtassertNotEqual(R R"R#tv3tv4((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test___eq__0s cCs-|jtt|jddWdQXdS(NR!i{(t assertRaisest TypeErrorRR(R ((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_invalid_name:sc Cs|jtt|jddWdQX|jt|jjddWdQX|jt|jjddWdQXdS(NR!svarnametvalue(R*t ValueErrorRRt globalsetvartsetvar(R ((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_null_in_name>s csot|j}t|}gfd}fd}|jd|}|jd|}|jt|jd|fd|fg|jg|jd|jd|ddfgg|j|jd |ddfggt|j}|j d||jt|j||j t |j ddWdQX|jt|j||j d|d f|jt|j||j|jd |ddfgg|j d||j|jd|fg|j|jgg~t j |jd |jd|ddfgdS( Ncsjd|dS(Ntread(R2(tappend(R(ttrace(s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt read_tracerJscsjd|dS(Ntwrite(R6(R3(R(R4(s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt write_tracerLstrtwutspamR6RtwR2i+teggs(RRRttrace_variableRtsortedt trace_vinfotsetRt trace_vdeleteR*Rtgctcollect(R RtvnameR5R7tcb1tcb2R((R4s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test_traceFsF .      ( R R RRRR R$R)R,R1RG(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRs      t TestStringVarcBs#eZdZdZdZRS(cCs)t|j}|jd|jdS(NR(RRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRzscCsXt|jdd}|jd|j|jjdd|jd|jdS(NR%R!R-(RRRRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_get~scCsXt|jdd}|jd|j|jjdd|jd|jdS(NsabcdefR!svalue(RRRRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyt test_get_nulls(R R RRIRJ(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRHxs  t TestIntVarcBs#eZdZdZdZRS(cCs)t|j}|jd|jdS(Ni(RRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRscCsXt|jdd}|jd|j|jjdd|jd|jdS(Ni{R!t345iY(RRRRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRIscCst|jdd}|jjdd|jt|jWdQX|jjdd|jt|jWdQXdS(NR!R-s345.0(RRR/R*R.R(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_invalid_values(R R RRIRM(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRKs  t TestDoubleVarcBs,eZdZdZdZdZRS(cCs)t|j}|jd|jdS(Ng(RRRR(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRscCsXt|jdd}|jd|j|jjdd|jd|jdS(NgGz?R!s3.45g @(RRtassertAlmostEqualRR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRIscCst|jdd}|jd|j|jjdd|jd|j|jjdd|jd|jdS(NgGz?R!s3.45g @t456i(RRRORR/(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_get_from_ints cCsLt|jdd}|jjdd|jt|jWdQXdS(NR!R-(RRR/R*R.R(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRMs(R R RRIRQRM(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRNs   tTestBooleanVarcBs,eZdZdZdZdZRS(cCs)t|j}|j|jtdS(N(RRtassertIsRtFalse(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRscCst|jtd}|j|jt|jjdd|j|jt|jjd|jjrudnd|j|jt|jjdd|j|jt|jjd|jjrdnd|j|jt|jjdd|j|jt|jjdd |j|jt|jjdd |j|jt|jjdd |j|jtdS( NR!t0i*iil*lltonu0uon(RRtTrueRSRR/RTt wantobjects(R R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRIs$((cCs|jjrdnd}|jjr0dnd}t|jdd}|jt|j|jjd||jd|j|jjd||jd|j|jjd||jd|j|jjd||jd|j|jjd||jd|j|jjd||jd |j|jjd||jd |j|jjd||jd |j|jjd|dS( Nit1iRUR!i*l*lRVu0uon(RRXRR@RWRt globalgetvar(R ttruetfalseR((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_sets*         cCs|jjrdnd}t|jdd}|jt|jdWdQX|j|jjd||jjdd|jt|j WdQX|jjdd|jt|j WdQXdS(NiRUR!R-s1.0( RRXRR*RR@RRZR/R(R R\R((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyttest_invalid_value_domains(R R RRIR]R^(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyRRs   t__main__(t run_unittest(tunittestRBtTkinterRRRRRRRtTestCaseRRRHRKRNRRt tests_guiR t test.supportR`(((s?/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_variables.pyts  4 h?   PK]*test_tkinter/test_misc.pycnu[ zfc@sddlZddlZddlmZmZddlmZeddeejfdYZ e fZ e dkree ndS(iN(trequirest run_unittest(tAbstractTkTesttguitMiscTestcBs#eZdZdZdZRS(cs|j}idd6ddfd}|j|jddd<|jd|}|j||jjdd|jj|jjdd|\}}|j|jdd|j t j |jj|WdQXdd<|jd|dd}|j|jdd |jd |}|j||jjdd|jj|jjdd|\}}|j ||jdd |j t j |jj|WdQXdS( Nitcountics||ds   o  PK]VItest_tkinter/test_font.pycnu[ zfc@sddlZddlZddlZddlmZmZmZddl m Z eddZ de ej fdYZ e fZedkreendS( iN(trequirest run_unittestt gc_collect(tAbstractTkTesttguit TkDefaultFonttFontTestcBsheZedZdZdZdZdZdZdZ dZ dZ d Z RS( cCswtjj|y(tjd|jdtdt|_Wn8tj k rrtjd|jdtdt |_nXdS(Ntroottnametexists( Rt setUpClasst__func__tfonttFontRtfontnametTruettkintertTclErrortFalse(tcls((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyR s (cCsL|jj}|jt|ddddddhxI|D]A}|j|jj||||j|j|||q>WxUdD]M}|j||t|j|jj|t|j|j|tqW|jrt nt}xUdD]M}|j||||j|jj|||j|j||qWdS( Ntfamilytsizetweighttslantt underlinet overstrike(RRR(RRR( R t configuretassertGreaterEqualtsett assertEqualtcgettassertIsInstancetstrt wantobjectstint(tselftoptionstkeytsizetype((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyttest_configures    cCsd}y%tjd|jd|dt}Wn5tjk rbtjd|jd|dt}nX|j|jd|~t dS(NuMS ゴシックRRR ( R R RRRRRRRR(R#Rtf((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyttest_unicode_family&s%%cCs|jj}|jt|ddddddhx.|D]&}|j|jj|||q>Wx>dD]6}|j||t|j|jj|tqoW|jrtnt}x>dD]6}|j||||j|jj||qWdS( NRRRRRR(RRR(RRR( R tactualRRRRR R!R"(R#R$R%R&((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_actual0s $   cCs3|j|jjt|jt|jtdS(N(RR RRR (R#((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_name>scCstjd|jdtdt}tjd|jdtdt}|j|||j|||j||j|j|d|j |dgdS(NRRR i( R R RRRt assertIsNotRtassertNotEqualtcopyt assertNotIn(R#tfont1tfont2((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyttest_eqBs!!cCs |j|jjdtdS(Ntabc(RR tmeasureR"(R#((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_measureKscCs|jj}|jt|ddddhx^|D]V}|j|jj||||j||t|j|jj|tq8WdS(Ntascenttdescentt linespacetfixed(R tmetricsRRRRR"(R#R;R%((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_metricsNs  cCsgtj|j}|j|t|j|x1|D])}|j|ttf|j|q6WdS(N(R tfamiliesRRttuplet assertTrueR tunicode(R#R=R((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_familiesWs   cCswtj|j}|j|t|j|x1|D])}|j|ttf|j|q6W|jt |dS(N( R tnamesRRR>R?R R@tassertInR(R#RBR((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_names_s  ( t__name__t __module__t classmethodR R'R)R+R,R3R6R<RARD(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyR s     t__main__(tunittesttTkinterRttkFontR ttest.test_supportRRRttest_ttk.supportRRtTestCaseRt tests_guiRE(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyts    ]  PK]6Зtest_tkinter/test_loadtk.pynu[import os import sys import unittest from test import test_support from Tkinter import Tcl, TclError test_support.requires('gui') class TkLoadTest(unittest.TestCase): @unittest.skipIf('DISPLAY' not in os.environ, 'No $DISPLAY set.') def testLoadTk(self): tcl = Tcl() self.assertRaises(TclError,tcl.winfo_geometry) tcl.loadtk() self.assertEqual('1x1+0+0', tcl.winfo_geometry()) tcl.destroy() def testLoadTkFailure(self): old_display = None if sys.platform.startswith(('win', 'darwin', 'cygwin')): # no failure possible on windows? # XXX Maybe on tk older than 8.4.13 it would be possible, # see tkinter.h. return with test_support.EnvironmentVarGuard() as env: if 'DISPLAY' in os.environ: del env['DISPLAY'] # on some platforms, deleting environment variables # doesn't actually carry through to the process level # because they don't support unsetenv # If that's the case, abort. display = os.popen('echo $DISPLAY').read().strip() if display: return tcl = Tcl() self.assertRaises(TclError, tcl.winfo_geometry) self.assertRaises(TclError, tcl.loadtk) tests_gui = (TkLoadTest, ) if __name__ == "__main__": test_support.run_unittest(*tests_gui) PK]ltest_tkinter/test_widgets.pycnu[ zfc@sTddlZddlZddlmZddlZddlZddlmZmZddl m Z m Z m Z m Z ddlmZmZmZmZmZmZmZmZmZmZeddeefdYZeed eejfd YZeed eejfd YZeed eejfdYZdeefdYZeedeejfdYZeedeejfdYZ eedeejfdYZ!eedeejfdYZ"eedeejfdYZ#de#ejfdYZ$eeedeejfdYZ%eede%ejfd YZ&eed!eejfd"YZ'eeed#eejfd$YZ(eeed%eejfd&YZ)eeed'eejfd(YZ*eeed)eejfd*YZ+eed+eejfd,YZ,eed-eejfd.YZ-eeed/eejfd0YZ.e e(e!e%eeee)e#e-e.e$e,e"e*e+e&e'egZ/e0d1krPee/ndS(2iN(tTclError(trequirest run_unittest(t tcl_versiont requires_tcltget_tk_patchlevelt widget_eq( tadd_standard_optionstnoconvt noconv_metht int_roundt pixels_roundtAbstractWidgetTesttStandardOptionsTeststIntegerSizeTeststPixelSizeTestst setUpModuletguitAbstractToplevelTestcBs2eZeZdZdZdZdZRS(cCso|j}|j|d|jjj|j|dddd|jdd}|j|dddS(NtclasstFooterrmsgs2can't modify -class option after widget is createdtclass_(tcreatet assertEqualt __class__t__name__ttitletcheckInvalidParam(tselftwidgettwidget2((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_classs  cCsc|j}|j|dd|j|dddd|jdd}|j|dddS(NtcolormapttnewRs5can't modify -colormap option after widget is created(RRR(RRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_colormaps  cCs|j}|j|d|jr(dnd|j|dddd|jdt}|j|d|jrvdnddS(Nt containerit0iRs6can't modify -container option after widget is createdt1(RRt wantobjectsRtTrue(RRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_container's  #cCsc|j}|j|dd|j|dddd|jdd}|j|dddS(NtvisualR"tdefaultRs3can't modify -visual option after widget is created(RRR(RRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_visual/s  (Rt __module__R t_conv_pad_pixelsR R$R*R-(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs   t ToplevelTestcBs2eZdZdZdZdZdZRS(t backgroundt borderwidthRR!R%tcursortheightthighlightbackgroundthighlightcolorthighlightthicknesstmenutpadxtpadytrelieftscreent takefocustuseR+twidthcKstj|j|S(N(ttkintertTopleveltroot(Rtkwargs((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRBscCsN|j}tj|j}|j|d|dt|j|dddS(NR8teqR"(RR@tMenuRBt checkParamR(RRR8((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_menuEs cCs|j}|j|ddytjd}Wntk rQ|jdnX|j|d|dd|jd|}|j|d|dS(NR<R"tDISPLAYsNo $DISPLAY set.Rs3can't modify -screen option after widget is created(RRtostenvirontKeyErrortskipTestR(RRtdisplayR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_screenKs  cCsl|j}|j|dd|jdt}d|j}|jd|}|j|d|dS(NR>R"R%s%#x(RRR)twinfo_id(RRtparenttwidR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_useWs  (R1R2RR!R%R3R4R5R6R7R8R9R:R;R<R=R>R+R?(RR.tOPTIONSRRGRNRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyR08s   t FrameTestcBseZdZdZRS(R1R2RR!R%R3R4R5R6R7R9R:R;R=R+R?cKstj|j|S(N(R@tFrameRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRjs(R1R2RR!R%R3R4R5R6R7R9R:R;R=R+R?(RR.RSR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRTas tLabelFrameTestcBs)eZdZdZdZdZRS(R1R2RR!R%R3tfontt foregroundR4R5R6R7t labelanchort labelwidgetR9R:R;R=ttextR+R?cKstj|j|S(N(R@t LabelFrameRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRyscCsW|j}|j|ddddddddd d d d d |j|dddS(NRYtetentestntnetnwtstsetswtwtwntwstcenter(RtcheckEnumParamR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_labelanchor|s   cCsQ|j}tj|jdddd}|j|d|dd|jdS(NR[tMupptnametfooRZtexpecteds.foo(RR@tLabelRBRFtdestroy(RRtlabel((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_labelwidgets (R1R2RR!R%R3RWRXR4R5R6R7RYRZR9R:R;R=R[R+R?(RR.RSRRkRs(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRVns  tAbstractLabelTestcBseZeZdZRS(c Cs2|j}|j|ddddddddS(NR7ig?g@iit10p(RtcheckPixelsParam(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_highlightthicknesss  (RR.R t _conv_pixelsRw(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRtst LabelTestcBseZdZdZRS(tactivebackgroundtactiveforegroundtanchorR1tbitmapR2tcompoundR3tdisabledforegroundRWRXR4R5R6R7timagetjustifyR9R:R;tstateR=R[t textvariablet underlineR?t wraplengthcKstj|j|S(N(R@RpRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs(RzR{R|R1R}R2R~R3RRWRXR4R5R6R7RRR9R:R;RR=R[RRR?R(RR.RSR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRyst ButtonTestc Bs eZd"Zd Zd!ZRS(#RzR{R|R1R}R2tcommandR~R3R,RRWRXR4R5R6R7RRt overreliefR9R:R;t repeatdelaytrepeatintervalRR=R[RRR?RcKstj|j|S(N(R@tButtonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs)|j}|j|dddddS(NR,tactivetdisabledtnormal(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_defaults ( RzR{R|R1R}R2RR~R3R,RRWRXR4R5R6R7RRRR9R:R;RRRR=R[RRR?R(RR.RSRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs tCheckbuttonTestc&Bs)eZd)Zd&Zd'Zd(ZRS(*RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7Rt indicatoronRt offrelieftoffvaluetonvalueRR9R:R;t selectcolort selectimageRR=R[Rt tristateimaget tristatevalueRtvariableR?RcKstj|j|S(N(R@t CheckbuttonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs,|j}|j|ddddddS(NRigffffff@R"s any string(Rt checkParams(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_offvalues cCs,|j}|j|ddddddS(NRigffffff@R"s any string(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_onvalues (&RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7RRRRRRRR9R:R;RRRR=R[RRRRRR?R(RR.RSRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs  tRadiobuttonTestc%Bs eZd'Zd%Zd&ZRS((RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7RRRRRR9R:R;RRRR=R[RRRRtvalueRR?RcKstj|j|S(N(R@t RadiobuttonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs,|j}|j|ddddddS(NRigffffff@R"s any string(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_values (%RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7RRRRRR9R:R;RRRR=R[RRRRRRR?R(RR.RSRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs tMenubuttonTestcBseZd(ZeeZdZdZd Ze j j Z e j ejd!kd"d#Zd$Zd%Zd&Zd'ZRS()RzR{R|R1R}R2R~R3t directionRRWRXR4R5R6R7RRRR8R9R:R;RR=R[RRR?RcKstj|j|S(N(R@t MenubuttonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs/|j}|j|dddddddS(NRtabovetbelowtflushtlefttright(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_directions  cCs/|j}|j|dddddtdS(NR4idiitconv(RtcheckIntegerParamtstr(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_heights tdarwins"crashes with Cocoa Tk (issue19733)c Cs|j}tjd|jdd}|j|d|dtd}|jtj}d|dZd?ZRS(BtautoseparatorsR1t blockcursorR2R3tendlineRRWRXR4R5R6R7tinactiveselectbackgroundRRRRtinsertunfocussedRtmaxundoR9R:R;RRRtsetgridtspacing1tspacing2tspacing3t startlineRttabsttabstyleR=tundoR?RRtyscrollcommandiicKstj|j|S(N(R@tTextRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_autoseparatorss cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_blockcursors cCs|j}djdtdD}|jd||j|dddd|j|dd dd|j|dd d d |j|dd |j|dd|j|ddd ddS(Ns css|] }dVqdS(sLine %dN((t.0ti((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys sidtendRiRoR"iRRsexpected integer but got "spam"i2R#ii s1-startline must be less than or equal to -endline(RtjointrangetinsertRFR(RRR[((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_endlines cCs^|j}|j|ddddd|j|dddd|j|dd dddS( NR4idgLY@gfffffY@t3ciRoii(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs cCs)|j}|j|dddddS(NRiii(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_maxundos cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_inactiveselectbackgrounds icCs)|j}|j|dddddS(NRthollowRtsolid(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_insertunfocusseds  c Cs>|j}|j|ddddddtdtd kdS( NRg?g@iRuRt keep_origii(ii(RRvRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_selectborderwidth$s  cCsE|j}|j|ddddd|j|dddddS( NR igffffff5@g6@s0.5ciRoi(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_spacing1*s cCsE|j}|j|ddddd|j|dddddS( NR!ig@gffffff@s0.1ciRoi(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_spacing2/s cCsE|j}|j|ddddd|j|dddddS( NR"igffffff5@g6@s0.5ciRoi(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_spacing34s cCs|j}djdtdD}|jd||j|dddd|j|dd dd|j|dd d d |j|dd |j|dd|j|ddd ddS(Ns css|] }dVqdS(sLine %dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys <sidR-R#iRoR"iRRsexpected integer but got "spam"i Ri2iFs1-startline must be less than or equal to -endline(RR.R/R0RFR(RRR[((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_startline9s cCsK|j}tdkr1|j|dddn|j|ddddS(NiiRRR(ii(RRRRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRGs  c Cs|j}tdkr7|j|ddd dn|j|dd|j|dd d d|j|dd d d|j|dddddtdkdS(Niii R$gffffff$@g333334@t1it2iRos10.2s20.7s10.2 20.7 1i 2is2c left 4c 6c centert2cRt4ct6cRiRRsbad screen distance "spam"R8(iii (gffffff$@g333334@R>R?(s10.2s20.7R>R?(gffffff$@g333334@R>R?(s10.2s20.7R>R?(R@RRARBRi(ii(RRRFRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_tabsNs  cCs&|j}|j|ddddS(NR%ttabulart wordprocessor(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_tabstyle]s cCs |j}|j|ddS(NR&(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_undobs cCsU|j}|j|dd|j|dddd|j|dddddS(NR?iinRoii(RRRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRfs cCsQ|j}tdkr4|j|ddddn|j|dddddS(NiiRtcharRtword(ii(RRRRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRls  cCs|j}|j|jd|j|jd|jtj|jd|jtj|jd|jtj|j|jtj|jdddS(Ns1.1R-R(RRRt assertIsNoneRR@RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRss ()RR1RR2R3RRRWRXR4R5R6R7RRRRRRRRR9R:R;RRRRR R!R"R#RR$R%R=R&R?RRR'(ii(RR.RSRR)t _stringifyRR)RR*R1RR3R4R7R9R:R;R<R=RRCRFRGRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRsB               t CanvasTestcBsheZd#ZeeZeZdZdZ dZ dZ dZ d Z d!Zd"ZRS($R1R2t closeenoughtconfineR3R4R5R6R7RRRRRtoffsetR;t scrollregionRRRRR=RtxscrollincrementR'tyscrollincrementR?cKstj|j|S(N(R@tCanvasRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRsc Cs2|j}|j|ddddddtdS(NRMig333333@g @iR(RRtfloat(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_closeenoughs cCs |j}|j|ddS(NRN(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_confines c Cs|j}|j|dd|j|dddddddd d d |j|dd |j|dd |j|dddS(NROs0,0R`RaR]RdRcReRfRbRis10,20s#5,6R(RRRRFR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_offsets  cCs|j}|j|dd|j|dd dd|j|dd|j|ddd d |j|dd |j|dd |j|dddS(NRPs 0 0 200 150iiiRoR"RRsbad scrollRegion "spam"(iiii(iiiR(iii(iiiii(RRFR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_scrollregions cCs,|j}|j|ddddddS(NRRRRs0bad state value "{}": must be normal or disabled(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs c Cs2|j}|j|ddddddddS(NRQi(igD@gE@is0.5i(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_xscrollincrements  c Cs2|j}|j|ddddddddS(NRRi igffffff&@g333333+@is0.1i(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_yscrollincrements  (R1R2RMRNR3R4R5R6R7RRRRRROR;RPRRRRR=RRQR'RRR?(RR.RSRR RxR)RKRRURVRWRXRRYRZ(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRL}s(      t ListboxTestcBseZd,ZdZdZedddejjZdZ dZ d Z d!Z d"Z d#Zd$Zd%Zd&Zd'Zd(Zd)Zd*Zd+ZRS(-t activestyleR1R2R3RRRWRXR4R5R6R7Rt listvariableR;RRRt selectmodeRRR=R?RR'cKstj|j|S(N(R@tListboxRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs)|j}|j|dddddS(NR\tdotboxRR(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_activestyles  iiicCs5|j}tj|j}|j|d|dS(NR](RR@t DoubleVarRBtcheckVariableParam(RRtvar((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_listvariables cCs\|j}|j|dd|j|dd|j|dd|j|dddS(NR^tsingletbrowsetmultipletextended(RRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_selectmodes  cCs&|j}|j|ddddS(NRRR(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs c Cs|j}|jtd|jdWdQXdj}|jd|x-t|D]\}}|j|d|q[W|jt|jWdQX|jtd|jdWdQX|j |jddd|j |jddd|j |jd dd|jd}|j |t x|j D]s\}}|j t|dt|d krD|j ||jd||j |d|jd|qDqDWdS(Nsitem number "0" out of rangeis)red orange yellow green blue white violetR-R1sbad listbox index "red"tredt BackgroundR"tviolets@0,0iii(R1R1RlR"Rk(R1R1RlR"Rm(R1R1RlR"Rk(ii(RtassertRaisesRegexpRt itemconfiguretsplitR0t enumerateRRRtassertIsInstancetdicttitemstassertIntlentitemcget(RRtcolorsR,tcolortdtktv((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigures0  c Cs|j}|jddddd|jdi||6|j|jd|d||j|jd|||jtd|jdid |6WdQXdS( NR-RRRRziisunknown color name "spam"R(RR0RoRRwRnR(RRmRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcheck_itemconfigures  cCs|jdddS(NR1s#ff0000(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_background scCs|jdddS(Ntbgs#ff0000(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_bgscCs|jdddS(Ntfgs#110022(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_fgscCs|jdddS(NRXs#110022(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_foregroundscCs|jdddS(NRs#110022(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt#test_itemconfigure_selectbackgroundscCs|jdddS(NRs#654321(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt#test_itemconfigure_selectforegroundscCs|j}|jddtdD|j|j|jd|j|jd|j|jd|jt|jd|jt|jd|jt |j|jt |jdddS(Nicss|]}d|VqdS(sel%dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys siii Ri( RR0R/tpackRRRJRRRR(Rtlb((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_boxs   cCs|j}|jddtdD|jdtj|jdd|jd|j|jd|j t |jddS( Nicss|]}d|VqdS(sel%dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys +siiiii(iiii( RR0R/tselection_clearR@tENDt selection_setRt curselectionRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_curselection)s   cCs|j}|jddtdD|j|jdd|j|jdd|j|jdd|j|jdd |j|jd d |j|jdd d|j|jd dd|j|jd dd|j|jddd|jt|jd|jt|jd|jt|j|jt|jdd|jt|jddd|jt|jddS(Nicss|]}d|VqdS(sel%dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys 4sitel0itel3R-tel7R"iitel4tel5tel6Riig333333@(RRR(RRR((R( RR0R/RtgetRRRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_get2s"  (R\R1R2R3RRRWRXR4R5R6R7RR]R;RRRR^RRR=R?RR'(RR.RSRRaRR t test_justifyRReRjRR}R~RRRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyR[s2             t ScaleTestcBseZd+ZdZdZd Zd!Zd"Zd#Zd$Z d%Z d&Z d'Z d(Z d)Zd*ZRS(,RzR1t bigincrementR2RR3tdigitsRWRXRR5R6R7RrtlengthtorientR;RRt resolutiont showvaluet sliderlengtht sliderreliefRR=t tickintervalRt troughcolorRR?tverticalcKstj|j|S(N(R@tScaleRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRSscCs)|j}|j|dddddS(NRg(@g7@i(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_bigincrementVs cCs&|j}|j|ddddS(NRii(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_digitsZs cCs/|j}|j|dddddtdS(NRidg-@g333333.@R(RRtround(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyR^s cCs6|j}|j|dd|j|dddS(NRrs any stringR"(RRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_labelbs cCs,|j}|j|ddddddS(NRigffffff`@g33333`@t5i(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_lengthgs cCs,|j}|j|ddddddS(NRg@ig@i(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_resolutionks cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_showvalueos cCs/|j}|j|dddddddS(NRi gffffff&@g333333/@it3m(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sliderlengthss  cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sliderreliefxs c CsQ|j}|j|ddddddt|j|dddd dtdS( NRig333333@gffffff@iRiRoi(RRRRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_tickinterval|s  c Cs2|j}|j|ddddddtdS(NRi,g-@g333333.@iR(RRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs (RzR1RR2RR3RRWRXRR5R6R7RrRRR;RRRRRRRR=RRRRR?(RR.RStdefault_orientRRRRRRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRFs(           t ScrollbarTestcBs\eZdZeeZeZdZdZ dZ dZ dZ dZ dZRS(Rzt activereliefR1R2RR3telementborderwidthR5R6R7tjumpRR;RRR=RR?RcKstj|j|S(N(R@t ScrollbarRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_activereliefs cCs,|j}|j|ddddddS(NRg333333@gffffff@it1m(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_elementborderwidths cCs,|j}|j|ddddddS(NRRt horizontalRs4bad orientation "{}": must be vertical or horizontal(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_orients cCsg|j}xdD]}|j|qW|jd|jt|j|jt|jdddS(Ntarrow1tslidertarrow2R"(RRR(RtactivateRR(RtsbR]((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_activates    cCs|j}|jdd|j|jd|jt|jdd|jt|jdd|jt|jdd|jt|jd|jt|jddddS( Ng?g?tabctdefg333333?gffffff?g?(g?g?(RtsetRRRRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sets (RzRR1R2RR3RR5R6R7RRR;RRR=RR?(RR.RSRR RxR)RKRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs       tPanedWindowTestcBsgeZd2ZdZdZdZdZdZdZe ddddZ e ddddZ e ddddZ dZ dZd Zd!Zd"Zd#Zd$Zd%Zed&Zd'Zd(Zd)Zd*Ze ddd+Zd,Zd-Zd.Zd/Ze ddd0Z d1Z!RS(3R1R2R3t handlepadt handlesizeR4t opaqueresizeRtproxybackgroundtproxyborderwidtht proxyreliefR;t sashcursortsashpadt sashrelieft sashwidtht showhandleR?RcKstj|j|S(N(R@t PanedWindowRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs/|j}|j|dddddddS(NRig@gffffff@iR(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_handlepads c Cs5|j}|j|dddddddtdS(NRig"@g333333%@it2mR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_handlesizes c Cs8|j}|j|ddddddddtdS( NR4idgLY@gfffffY@iiR>R(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs !cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_opaqueresizes iiicCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_proxybackgrounds c Cs8|j}|j|ddddddddtdS( NRig?g333333@iiRuR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_proxyborderwidths  cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_proxyreliefs cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sashcursors cCs/|j}|j|dddddddS(NRig?g@iR(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_sashpads cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sashreliefs c Cs5|j}|j|dddddddtdS(NRi g333333&@g333333/@iRR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sashwidths cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_showhandles c Cs8|j}|j|ddddddddtdS( NR?igfffff6y@gIy@iniRR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs !cCsQ|j}tj|}tj|}|j||j||||fS(N(RR@Rtadd(RtpRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcreate2s    cCs|j\}}}|jt|j|j|}|j|txl|jD]^\}}|jt|d|j||j|||j|d|j ||qTWdS(Nii( RRRt paneconfigureRrRsRtRRvtpanecget(RRRRRzR{R|((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigurescCsd}|j s|r(t|}n|jr@|r@t}n|j|i||6|j||j||d||j||j|||dS(NcSs|S(N((tx((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytR"i(R(RRRR(RRRRmRRot stringifyR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcheck_paneconfigures  &c Cs4|jt||j|id|6WdQXdS(NtbadValue(RnRR(RRRRmtmsg((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcheck_paneconfigure_bad$scCsN|j\}}}|j||d|t||j||dddS(Ntaftersbad window path name "badValue"(RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_after(scCsN|j\}}}|j||d|t||j||dddS(Ntbeforesbad window path name "badValue"(RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_before.sc CsW|j\}}}|j||ddddtdk|j||dddS( NR4i Riii sbad screen distance "badValue"(iii (RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_height4s cCsH|j\}}}|j||dtd|j||dddS(Nthideis)expected boolean value but got "badValue"(RRtFalseR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_hide;scCsH|j\}}}|j||ddd|j||dddS(Ntminsizei sbad screen distance "badValue"(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_minsizeBscCsH|j\}}}|j||ddd|j||dddS(NR9g?isbad screen distance "badValue"(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_padxHscCsH|j\}}}|j||ddd|j||dddS(NR:g?isbad screen distance "badValue"(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_padyNscCsH|j\}}}|j||ddd|j||dddS(Ntstickytnsewtnesws[bad stickyness value "badValue": must be a string containing zero or more of n, e, s, and w(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_stickyTscCsH|j\}}}|j||ddd|j||dddS(NtstretchtalwtalwayssEbad stretch "badValue": must be always, first, last, middle, or never(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_stretch\sc CsW|j\}}}|j||ddddtdk|j||dddS( NR?i Riii sbad screen distance "badValue"(iii (RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_widthds (R1R2R3RRR4RRRRRR;RRRRRR?("RR.RSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRsH                    tMenuTestcBseeZdZeZdZdZdZdZdZ dZ dZ dZ dZ RS(RztactiveborderwidthR{R1R2R3RRWRXt postcommandR;RR=ttearoffttearoffcommandRttypecKstj|j|S(N(R@RERB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRwscCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_postcommandzs cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_tearoff~s cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_tearoffcommands cCs#|j}|j|dddS(NRs any string(RRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_titles cCs)|j}|j|dddddS(NRRRtmenubar(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_types  cCs |j}|jdd|jt|j|jtd|jdWdQX|jd}|j|tx|j D]v\}}|j|t |j|t |j t |d|j |d||j |jd||dqW|jdS( NRrttestsbad menu entry index "foo"Rniiii(Rt add_commandRRtentryconfigureRnRRrRsRtRttupleRRvt entrycgetRq(Rtm1RzR{R|((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_entryconfigures $cCsk|j}|jdd|j|jddd|jddd|j|jddddS(NRrR itchanged(RRRRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_entryconfigure_labels  c Cs|j}tj|j}tj|j}|jd|dtdtdd|jt|j ddt||j dd||jt|j ddt|dS(NRRRRrtNonsensei( RR@t BooleanVarRBtadd_checkbuttonR)RRRRR(RRtv1tv2((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_entryconfigure_variables ((RzRR{R1R2R3RRWRXRR;RR=RRRR(RR.RSR RxRRRR R R RRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRls        t MessageTestcBs&eZdZeZdZdZRS(R|taspectR1R2R3RWRXR5R6R7RR9R:R;R=R[RR?cKstj|j|S(N(R@tMessageRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs)|j}|j|dddddS(NRiii(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_aspects (R|RR1R2R3RWRXR5R6R7RR9R:R;R=R[RR?(RR.RSR R/RR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs t__main__(1RtTkinterR@RRIRttest.test_supportRRttest_ttk.supportRRRRt widget_testsRRR R R R R RRRRtTestCaseR0RTRVRtRyRRRRRRRRRLR[RRRRRt tests_guiR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytsl    "F % (       AE h BB1  D     PK]test_tkinter/test_loadtk.pyonu[ zfc@sddlZddlZddlZddlmZddlmZmZejddej fdYZ e fZ e dkrej e ndS(iN(t test_support(tTcltTclErrortguit TkLoadTestcBs5eZejdejkddZdZRS(tDISPLAYsNo $DISPLAY set.cCsJt}|jt|j|j|jd|j|jdS(Ns1x1+0+0(Rt assertRaisesRtwinfo_geometrytloadtkt assertEqualtdestroy(tselfttcl((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyt testLoadTk s   cCsd}tjjdrdStjt}dtjkri|d=tjdj j }|ridSnt }|j t |j|j t |jWdQXdS(NtwintdarwintcygwinRs echo $DISPLAY(RRR(tNonetsystplatformt startswithRtEnvironmentVarGuardtostenvirontpopentreadtstripRRRRR(R t old_displaytenvtdisplayR ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyttestLoadTkFailures (t__name__t __module__tunittesttskipIfRRR R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyR s$t__main__(RRR!ttestRtTkinterRRtrequirestTestCaseRt tests_guiRt run_unittest(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyts    !  PK]Kww&test_tkinter/test_geometry_managers.pynu[import unittest import re import Tkinter as tkinter from Tkinter import TclError from test.test_support import requires, run_unittest from test_ttk.support import pixels_conv, tcl_version, requires_tcl from widget_tests import AbstractWidgetTest, int_round requires('gui') class PackTest(AbstractWidgetTest, unittest.TestCase): test_keys = None def create2(self): pack = tkinter.Toplevel(self.root, name='pack') pack.wm_geometry('300x200+0+0') pack.wm_minsize(1, 1) a = tkinter.Frame(pack, name='a', width=20, height=40, bg='red') b = tkinter.Frame(pack, name='b', width=50, height=30, bg='blue') c = tkinter.Frame(pack, name='c', width=80, height=80, bg='green') d = tkinter.Frame(pack, name='d', width=40, height=30, bg='yellow') return pack, a, b, c, d def test_pack_configure_after(self): pack, a, b, c, d = self.create2() with self.assertRaisesRegexp(TclError, 'window "%s" isn\'t packed' % b): a.pack_configure(after=b) with self.assertRaisesRegexp(TclError, 'bad window path name ".foo"'): a.pack_configure(after='.foo') a.pack_configure(side='top') b.pack_configure(side='top') c.pack_configure(side='top') d.pack_configure(side='top') self.assertEqual(pack.pack_slaves(), [a, b, c, d]) a.pack_configure(after=b) self.assertEqual(pack.pack_slaves(), [b, a, c, d]) a.pack_configure(after=a) self.assertEqual(pack.pack_slaves(), [b, a, c, d]) def test_pack_configure_anchor(self): pack, a, b, c, d = self.create2() def check(anchor, geom): a.pack_configure(side='top', ipadx=5, padx=10, ipady=15, pady=20, expand=True, anchor=anchor) self.root.update() self.assertEqual(a.winfo_geometry(), geom) check('n', '30x70+135+20') check('ne', '30x70+260+20') check('e', '30x70+260+65') check('se', '30x70+260+110') check('s', '30x70+135+110') check('sw', '30x70+10+110') check('w', '30x70+10+65') check('nw', '30x70+10+20') check('center', '30x70+135+65') def test_pack_configure_before(self): pack, a, b, c, d = self.create2() with self.assertRaisesRegexp(TclError, 'window "%s" isn\'t packed' % b): a.pack_configure(before=b) with self.assertRaisesRegexp(TclError, 'bad window path name ".foo"'): a.pack_configure(before='.foo') a.pack_configure(side='top') b.pack_configure(side='top') c.pack_configure(side='top') d.pack_configure(side='top') self.assertEqual(pack.pack_slaves(), [a, b, c, d]) a.pack_configure(before=d) self.assertEqual(pack.pack_slaves(), [b, c, a, d]) a.pack_configure(before=a) self.assertEqual(pack.pack_slaves(), [b, c, a, d]) def test_pack_configure_expand(self): pack, a, b, c, d = self.create2() def check(*geoms): self.root.update() self.assertEqual(a.winfo_geometry(), geoms[0]) self.assertEqual(b.winfo_geometry(), geoms[1]) self.assertEqual(c.winfo_geometry(), geoms[2]) self.assertEqual(d.winfo_geometry(), geoms[3]) a.pack_configure(side='left') b.pack_configure(side='top') c.pack_configure(side='right') d.pack_configure(side='bottom') check('20x40+0+80', '50x30+135+0', '80x80+220+75', '40x30+100+170') a.pack_configure(side='left', expand='yes') b.pack_configure(side='top', expand='on') c.pack_configure(side='right', expand=True) d.pack_configure(side='bottom', expand=1) check('20x40+40+80', '50x30+175+35', '80x80+180+110', '40x30+100+135') a.pack_configure(side='left', expand='yes', fill='both') b.pack_configure(side='top', expand='on', fill='both') c.pack_configure(side='right', expand=True, fill='both') d.pack_configure(side='bottom', expand=1, fill='both') check('100x200+0+0', '200x100+100+0', '160x100+140+100', '40x100+100+100') def test_pack_configure_in(self): pack, a, b, c, d = self.create2() a.pack_configure(side='top') b.pack_configure(side='top') c.pack_configure(side='top') d.pack_configure(side='top') a.pack_configure(in_=pack) self.assertEqual(pack.pack_slaves(), [b, c, d, a]) a.pack_configure(in_=c) self.assertEqual(pack.pack_slaves(), [b, c, d]) self.assertEqual(c.pack_slaves(), [a]) with self.assertRaisesRegexp(TclError, 'can\'t pack %s inside itself' % (a,)): a.pack_configure(in_=a) with self.assertRaisesRegexp(TclError, 'bad window path name ".foo"'): a.pack_configure(in_='.foo') def test_pack_configure_padx_ipadx_fill(self): pack, a, b, c, d = self.create2() def check(geom1, geom2, **kwargs): a.pack_forget() b.pack_forget() a.pack_configure(**kwargs) b.pack_configure(expand=True, fill='both') self.root.update() self.assertEqual(a.winfo_geometry(), geom1) self.assertEqual(b.winfo_geometry(), geom2) check('20x40+260+80', '240x200+0+0', side='right', padx=20) check('20x40+250+80', '240x200+0+0', side='right', padx=(10, 30)) check('60x40+240+80', '240x200+0+0', side='right', ipadx=20) check('30x40+260+80', '250x200+0+0', side='right', ipadx=5, padx=10) check('20x40+260+80', '240x200+0+0', side='right', padx=20, fill='x') check('20x40+249+80', '240x200+0+0', side='right', padx=(9, 31), fill='x') check('60x40+240+80', '240x200+0+0', side='right', ipadx=20, fill='x') check('30x40+260+80', '250x200+0+0', side='right', ipadx=5, padx=10, fill='x') check('30x40+255+80', '250x200+0+0', side='right', ipadx=5, padx=(5, 15), fill='x') check('20x40+140+0', '300x160+0+40', side='top', padx=20) check('20x40+120+0', '300x160+0+40', side='top', padx=(0, 40)) check('60x40+120+0', '300x160+0+40', side='top', ipadx=20) check('30x40+135+0', '300x160+0+40', side='top', ipadx=5, padx=10) check('30x40+130+0', '300x160+0+40', side='top', ipadx=5, padx=(5, 15)) check('260x40+20+0', '300x160+0+40', side='top', padx=20, fill='x') check('260x40+25+0', '300x160+0+40', side='top', padx=(25, 15), fill='x') check('300x40+0+0', '300x160+0+40', side='top', ipadx=20, fill='x') check('280x40+10+0', '300x160+0+40', side='top', ipadx=5, padx=10, fill='x') check('280x40+5+0', '300x160+0+40', side='top', ipadx=5, padx=(5, 15), fill='x') a.pack_configure(padx='1c') self.assertEqual(a.pack_info()['padx'], self._str(pack.winfo_pixels('1c'))) a.pack_configure(ipadx='1c') self.assertEqual(a.pack_info()['ipadx'], self._str(pack.winfo_pixels('1c'))) def test_pack_configure_pady_ipady_fill(self): pack, a, b, c, d = self.create2() def check(geom1, geom2, **kwargs): a.pack_forget() b.pack_forget() a.pack_configure(**kwargs) b.pack_configure(expand=True, fill='both') self.root.update() self.assertEqual(a.winfo_geometry(), geom1) self.assertEqual(b.winfo_geometry(), geom2) check('20x40+280+80', '280x200+0+0', side='right', pady=20) check('20x40+280+70', '280x200+0+0', side='right', pady=(10, 30)) check('20x80+280+60', '280x200+0+0', side='right', ipady=20) check('20x50+280+75', '280x200+0+0', side='right', ipady=5, pady=10) check('20x40+280+80', '280x200+0+0', side='right', pady=20, fill='x') check('20x40+280+69', '280x200+0+0', side='right', pady=(9, 31), fill='x') check('20x80+280+60', '280x200+0+0', side='right', ipady=20, fill='x') check('20x50+280+75', '280x200+0+0', side='right', ipady=5, pady=10, fill='x') check('20x50+280+70', '280x200+0+0', side='right', ipady=5, pady=(5, 15), fill='x') check('20x40+140+20', '300x120+0+80', side='top', pady=20) check('20x40+140+0', '300x120+0+80', side='top', pady=(0, 40)) check('20x80+140+0', '300x120+0+80', side='top', ipady=20) check('20x50+140+10', '300x130+0+70', side='top', ipady=5, pady=10) check('20x50+140+5', '300x130+0+70', side='top', ipady=5, pady=(5, 15)) check('300x40+0+20', '300x120+0+80', side='top', pady=20, fill='x') check('300x40+0+25', '300x120+0+80', side='top', pady=(25, 15), fill='x') check('300x80+0+0', '300x120+0+80', side='top', ipady=20, fill='x') check('300x50+0+10', '300x130+0+70', side='top', ipady=5, pady=10, fill='x') check('300x50+0+5', '300x130+0+70', side='top', ipady=5, pady=(5, 15), fill='x') a.pack_configure(pady='1c') self.assertEqual(a.pack_info()['pady'], self._str(pack.winfo_pixels('1c'))) a.pack_configure(ipady='1c') self.assertEqual(a.pack_info()['ipady'], self._str(pack.winfo_pixels('1c'))) def test_pack_configure_side(self): pack, a, b, c, d = self.create2() def check(side, geom1, geom2): a.pack_configure(side=side) self.assertEqual(a.pack_info()['side'], side) b.pack_configure(expand=True, fill='both') self.root.update() self.assertEqual(a.winfo_geometry(), geom1) self.assertEqual(b.winfo_geometry(), geom2) check('top', '20x40+140+0', '300x160+0+40') check('bottom', '20x40+140+160', '300x160+0+0') check('left', '20x40+0+80', '280x200+20+0') check('right', '20x40+280+80', '280x200+0+0') def test_pack_forget(self): pack, a, b, c, d = self.create2() a.pack_configure() b.pack_configure() c.pack_configure() self.assertEqual(pack.pack_slaves(), [a, b, c]) b.pack_forget() self.assertEqual(pack.pack_slaves(), [a, c]) b.pack_forget() self.assertEqual(pack.pack_slaves(), [a, c]) d.pack_forget() def test_pack_info(self): pack, a, b, c, d = self.create2() with self.assertRaisesRegexp(TclError, 'window "%s" isn\'t packed' % a): a.pack_info() a.pack_configure() b.pack_configure(side='right', in_=a, anchor='s', expand=True, fill='x', ipadx=5, padx=10, ipady=2, pady=(5, 15)) info = a.pack_info() self.assertIsInstance(info, dict) self.assertEqual(info['anchor'], 'center') self.assertEqual(info['expand'], self._str(0)) self.assertEqual(info['fill'], 'none') self.assertEqual(info['in'], pack) self.assertEqual(info['ipadx'], self._str(0)) self.assertEqual(info['ipady'], self._str(0)) self.assertEqual(info['padx'], self._str(0)) self.assertEqual(info['pady'], self._str(0)) self.assertEqual(info['side'], 'top') info = b.pack_info() self.assertIsInstance(info, dict) self.assertEqual(info['anchor'], 's') self.assertEqual(info['expand'], self._str(1)) self.assertEqual(info['fill'], 'x') self.assertEqual(info['in'], a) self.assertEqual(info['ipadx'], self._str(5)) self.assertEqual(info['ipady'], self._str(2)) self.assertEqual(info['padx'], self._str(10)) self.assertEqual(info['pady'], self._str((5, 15))) self.assertEqual(info['side'], 'right') def test_pack_propagate(self): pack, a, b, c, d = self.create2() pack.configure(width=300, height=200) a.pack_configure() pack.pack_propagate(False) self.root.update() self.assertEqual(pack.winfo_reqwidth(), 300) self.assertEqual(pack.winfo_reqheight(), 200) pack.pack_propagate(True) self.root.update() self.assertEqual(pack.winfo_reqwidth(), 20) self.assertEqual(pack.winfo_reqheight(), 40) def test_pack_slaves(self): pack, a, b, c, d = self.create2() self.assertEqual(pack.pack_slaves(), []) a.pack_configure() self.assertEqual(pack.pack_slaves(), [a]) b.pack_configure() self.assertEqual(pack.pack_slaves(), [a, b]) class PlaceTest(AbstractWidgetTest, unittest.TestCase): test_keys = None def create2(self): t = tkinter.Toplevel(self.root, width=300, height=200, bd=0) t.wm_geometry('300x200+0+0') f = tkinter.Frame(t, width=154, height=84, bd=2, relief='raised') f.place_configure(x=48, y=38) f2 = tkinter.Frame(t, width=30, height=60, bd=2, relief='raised') self.root.update() return t, f, f2 def test_place_configure_in(self): t, f, f2 = self.create2() self.assertEqual(f2.winfo_manager(), '') with self.assertRaisesRegexp(TclError, "can't place %s relative to " "itself" % re.escape(str(f2))): f2.place_configure(in_=f2) if tcl_version >= (8, 5): self.assertEqual(f2.winfo_manager(), '') with self.assertRaisesRegexp(TclError, 'bad window path name'): f2.place_configure(in_='spam') f2.place_configure(in_=f) self.assertEqual(f2.winfo_manager(), 'place') def test_place_configure_x(self): t, f, f2 = self.create2() f2.place_configure(in_=f) self.assertEqual(f2.place_info()['x'], '0') self.root.update() self.assertEqual(f2.winfo_x(), 50) f2.place_configure(x=100) self.assertEqual(f2.place_info()['x'], '100') self.root.update() self.assertEqual(f2.winfo_x(), 150) f2.place_configure(x=-10, relx=1) self.assertEqual(f2.place_info()['x'], '-10') self.root.update() self.assertEqual(f2.winfo_x(), 190) with self.assertRaisesRegexp(TclError, 'bad screen distance "spam"'): f2.place_configure(in_=f, x='spam') def test_place_configure_y(self): t, f, f2 = self.create2() f2.place_configure(in_=f) self.assertEqual(f2.place_info()['y'], '0') self.root.update() self.assertEqual(f2.winfo_y(), 40) f2.place_configure(y=50) self.assertEqual(f2.place_info()['y'], '50') self.root.update() self.assertEqual(f2.winfo_y(), 90) f2.place_configure(y=-10, rely=1) self.assertEqual(f2.place_info()['y'], '-10') self.root.update() self.assertEqual(f2.winfo_y(), 110) with self.assertRaisesRegexp(TclError, 'bad screen distance "spam"'): f2.place_configure(in_=f, y='spam') def test_place_configure_relx(self): t, f, f2 = self.create2() f2.place_configure(in_=f) self.assertEqual(f2.place_info()['relx'], '0') self.root.update() self.assertEqual(f2.winfo_x(), 50) f2.place_configure(relx=0.5) self.assertEqual(f2.place_info()['relx'], '0.5') self.root.update() self.assertEqual(f2.winfo_x(), 125) f2.place_configure(relx=1) self.assertEqual(f2.place_info()['relx'], '1') self.root.update() self.assertEqual(f2.winfo_x(), 200) with self.assertRaisesRegexp(TclError, 'expected floating-point number ' 'but got "spam"'): f2.place_configure(in_=f, relx='spam') def test_place_configure_rely(self): t, f, f2 = self.create2() f2.place_configure(in_=f) self.assertEqual(f2.place_info()['rely'], '0') self.root.update() self.assertEqual(f2.winfo_y(), 40) f2.place_configure(rely=0.5) self.assertEqual(f2.place_info()['rely'], '0.5') self.root.update() self.assertEqual(f2.winfo_y(), 80) f2.place_configure(rely=1) self.assertEqual(f2.place_info()['rely'], '1') self.root.update() self.assertEqual(f2.winfo_y(), 120) with self.assertRaisesRegexp(TclError, 'expected floating-point number ' 'but got "spam"'): f2.place_configure(in_=f, rely='spam') def test_place_configure_anchor(self): f = tkinter.Frame(self.root) with self.assertRaisesRegexp(TclError, 'bad anchor "j"'): f.place_configure(anchor='j') with self.assertRaisesRegexp(TclError, 'ambiguous anchor ""'): f.place_configure(anchor='') for value in 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center': f.place_configure(anchor=value) self.assertEqual(f.place_info()['anchor'], value) def test_place_configure_width(self): t, f, f2 = self.create2() f2.place_configure(in_=f, width=120) self.root.update() self.assertEqual(f2.winfo_width(), 120) f2.place_configure(width='') self.root.update() self.assertEqual(f2.winfo_width(), 30) with self.assertRaisesRegexp(TclError, 'bad screen distance "abcd"'): f2.place_configure(width='abcd') def test_place_configure_height(self): t, f, f2 = self.create2() f2.place_configure(in_=f, height=120) self.root.update() self.assertEqual(f2.winfo_height(), 120) f2.place_configure(height='') self.root.update() self.assertEqual(f2.winfo_height(), 60) with self.assertRaisesRegexp(TclError, 'bad screen distance "abcd"'): f2.place_configure(height='abcd') def test_place_configure_relwidth(self): t, f, f2 = self.create2() f2.place_configure(in_=f, relwidth=0.5) self.root.update() self.assertEqual(f2.winfo_width(), 75) f2.place_configure(relwidth='') self.root.update() self.assertEqual(f2.winfo_width(), 30) with self.assertRaisesRegexp(TclError, 'expected floating-point number ' 'but got "abcd"'): f2.place_configure(relwidth='abcd') def test_place_configure_relheight(self): t, f, f2 = self.create2() f2.place_configure(in_=f, relheight=0.5) self.root.update() self.assertEqual(f2.winfo_height(), 40) f2.place_configure(relheight='') self.root.update() self.assertEqual(f2.winfo_height(), 60) with self.assertRaisesRegexp(TclError, 'expected floating-point number ' 'but got "abcd"'): f2.place_configure(relheight='abcd') def test_place_configure_bordermode(self): f = tkinter.Frame(self.root) with self.assertRaisesRegexp(TclError, 'bad bordermode "j"'): f.place_configure(bordermode='j') with self.assertRaisesRegexp(TclError, 'ambiguous bordermode ""'): f.place_configure(bordermode='') for value in 'inside', 'outside', 'ignore': f.place_configure(bordermode=value) self.assertEqual(f.place_info()['bordermode'], value) def test_place_forget(self): foo = tkinter.Frame(self.root) foo.place_configure(width=50, height=50) self.root.update() foo.place_forget() self.root.update() self.assertFalse(foo.winfo_ismapped()) with self.assertRaises(TypeError): foo.place_forget(0) def test_place_info(self): t, f, f2 = self.create2() f2.place_configure(in_=f, x=1, y=2, width=3, height=4, relx=0.1, rely=0.2, relwidth=0.3, relheight=0.4, anchor='se', bordermode='outside') info = f2.place_info() self.assertIsInstance(info, dict) self.assertEqual(info['x'], '1') self.assertEqual(info['y'], '2') self.assertEqual(info['width'], '3') self.assertEqual(info['height'], '4') self.assertEqual(info['relx'], '0.1') self.assertEqual(info['rely'], '0.2') self.assertEqual(info['relwidth'], '0.3') self.assertEqual(info['relheight'], '0.4') self.assertEqual(info['anchor'], 'se') self.assertEqual(info['bordermode'], 'outside') self.assertEqual(info['x'], '1') self.assertEqual(info['x'], '1') with self.assertRaises(TypeError): f2.place_info(0) def test_place_slaves(self): foo = tkinter.Frame(self.root) bar = tkinter.Frame(self.root) self.assertEqual(foo.place_slaves(), []) bar.place_configure(in_=foo) self.assertEqual(foo.place_slaves(), [bar]) with self.assertRaises(TypeError): foo.place_slaves(0) class GridTest(AbstractWidgetTest, unittest.TestCase): test_keys = None def tearDown(self): cols, rows = self.root.grid_size() for i in range(cols + 1): self.root.grid_columnconfigure(i, weight=0, minsize=0, pad=0, uniform='') for i in range(rows + 1): self.root.grid_rowconfigure(i, weight=0, minsize=0, pad=0, uniform='') self.root.grid_propagate(1) super(GridTest, self).tearDown() def test_grid_configure(self): b = tkinter.Button(self.root) self.assertEqual(b.grid_info(), {}) b.grid_configure() self.assertEqual(b.grid_info()['in'], self.root) self.assertEqual(b.grid_info()['column'], self._str(0)) self.assertEqual(b.grid_info()['row'], self._str(0)) b.grid_configure({'column': 1}, row=2) self.assertEqual(b.grid_info()['column'], self._str(1)) self.assertEqual(b.grid_info()['row'], self._str(2)) def test_grid_configure_column(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad column value "-1": ' 'must be a non-negative integer'): b.grid_configure(column=-1) b.grid_configure(column=2) self.assertEqual(b.grid_info()['column'], self._str(2)) def test_grid_configure_columnspan(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad columnspan value "0": ' 'must be a positive integer'): b.grid_configure(columnspan=0) b.grid_configure(columnspan=2) self.assertEqual(b.grid_info()['columnspan'], self._str(2)) def test_grid_configure_in(self): f = tkinter.Frame(self.root) b = tkinter.Button(self.root) self.assertEqual(b.grid_info(), {}) b.grid_configure() self.assertEqual(b.grid_info()['in'], self.root) b.grid_configure(in_=f) self.assertEqual(b.grid_info()['in'], f) b.grid_configure({'in': self.root}) self.assertEqual(b.grid_info()['in'], self.root) def test_grid_configure_ipadx(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad ipadx value "-1": ' 'must be positive screen distance'): b.grid_configure(ipadx=-1) b.grid_configure(ipadx=1) self.assertEqual(b.grid_info()['ipadx'], self._str(1)) b.grid_configure(ipadx='.5c') self.assertEqual(b.grid_info()['ipadx'], self._str(int_round(pixels_conv('.5c') * self.scaling))) def test_grid_configure_ipady(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad ipady value "-1": ' 'must be positive screen distance'): b.grid_configure(ipady=-1) b.grid_configure(ipady=1) self.assertEqual(b.grid_info()['ipady'], self._str(1)) b.grid_configure(ipady='.5c') self.assertEqual(b.grid_info()['ipady'], self._str(int_round(pixels_conv('.5c') * self.scaling))) def test_grid_configure_padx(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad pad value "-1": ' 'must be positive screen distance'): b.grid_configure(padx=-1) b.grid_configure(padx=1) self.assertEqual(b.grid_info()['padx'], self._str(1)) b.grid_configure(padx=(10, 5)) self.assertEqual(b.grid_info()['padx'], self._str((10, 5))) b.grid_configure(padx='.5c') self.assertEqual(b.grid_info()['padx'], self._str(int_round(pixels_conv('.5c') * self.scaling))) def test_grid_configure_pady(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad pad value "-1": ' 'must be positive screen distance'): b.grid_configure(pady=-1) b.grid_configure(pady=1) self.assertEqual(b.grid_info()['pady'], self._str(1)) b.grid_configure(pady=(10, 5)) self.assertEqual(b.grid_info()['pady'], self._str((10, 5))) b.grid_configure(pady='.5c') self.assertEqual(b.grid_info()['pady'], self._str(int_round(pixels_conv('.5c') * self.scaling))) def test_grid_configure_row(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad (row|grid) value "-1": ' 'must be a non-negative integer'): b.grid_configure(row=-1) b.grid_configure(row=2) self.assertEqual(b.grid_info()['row'], self._str(2)) def test_grid_configure_rownspan(self): b = tkinter.Button(self.root) with self.assertRaisesRegexp(TclError, 'bad rowspan value "0": ' 'must be a positive integer'): b.grid_configure(rowspan=0) b.grid_configure(rowspan=2) self.assertEqual(b.grid_info()['rowspan'], self._str(2)) def test_grid_configure_sticky(self): f = tkinter.Frame(self.root, bg='red') with self.assertRaisesRegexp(TclError, 'bad stickyness value "glue"'): f.grid_configure(sticky='glue') f.grid_configure(sticky='ne') self.assertEqual(f.grid_info()['sticky'], 'ne') f.grid_configure(sticky='n,s,e,w') self.assertEqual(f.grid_info()['sticky'], 'nesw') def test_grid_columnconfigure(self): with self.assertRaises(TypeError): self.root.grid_columnconfigure() self.assertEqual(self.root.grid_columnconfigure(0), {'minsize': 0, 'pad': 0, 'uniform': None, 'weight': 0}) with self.assertRaisesRegexp(TclError, 'bad option "-foo"'): self.root.grid_columnconfigure(0, 'foo') self.root.grid_columnconfigure((0, 3), weight=2) with self.assertRaisesRegexp(TclError, 'must specify a single element on retrieval'): self.root.grid_columnconfigure((0, 3)) b = tkinter.Button(self.root) b.grid_configure(column=0, row=0) if tcl_version >= (8, 5): self.root.grid_columnconfigure('all', weight=3) with self.assertRaisesRegexp(TclError, 'expected integer but got "all"'): self.root.grid_columnconfigure('all') self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3) self.assertEqual(self.root.grid_columnconfigure(3, 'weight'), 2) self.assertEqual(self.root.grid_columnconfigure(265, 'weight'), 0) if tcl_version >= (8, 5): self.root.grid_columnconfigure(b, weight=4) self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4) def test_grid_columnconfigure_minsize(self): with self.assertRaisesRegexp(TclError, 'bad screen distance "foo"'): self.root.grid_columnconfigure(0, minsize='foo') self.root.grid_columnconfigure(0, minsize=10) self.assertEqual(self.root.grid_columnconfigure(0, 'minsize'), 10) self.assertEqual(self.root.grid_columnconfigure(0)['minsize'], 10) def test_grid_columnconfigure_weight(self): with self.assertRaisesRegexp(TclError, 'expected integer but got "bad"'): self.root.grid_columnconfigure(0, weight='bad') with self.assertRaisesRegexp(TclError, 'invalid arg "-weight": ' 'should be non-negative'): self.root.grid_columnconfigure(0, weight=-3) self.root.grid_columnconfigure(0, weight=3) self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3) self.assertEqual(self.root.grid_columnconfigure(0)['weight'], 3) def test_grid_columnconfigure_pad(self): with self.assertRaisesRegexp(TclError, 'bad screen distance "foo"'): self.root.grid_columnconfigure(0, pad='foo') with self.assertRaisesRegexp(TclError, 'invalid arg "-pad": ' 'should be non-negative'): self.root.grid_columnconfigure(0, pad=-3) self.root.grid_columnconfigure(0, pad=3) self.assertEqual(self.root.grid_columnconfigure(0, 'pad'), 3) self.assertEqual(self.root.grid_columnconfigure(0)['pad'], 3) def test_grid_columnconfigure_uniform(self): self.root.grid_columnconfigure(0, uniform='foo') self.assertEqual(self.root.grid_columnconfigure(0, 'uniform'), 'foo') self.assertEqual(self.root.grid_columnconfigure(0)['uniform'], 'foo') def test_grid_rowconfigure(self): with self.assertRaises(TypeError): self.root.grid_rowconfigure() self.assertEqual(self.root.grid_rowconfigure(0), {'minsize': 0, 'pad': 0, 'uniform': None, 'weight': 0}) with self.assertRaisesRegexp(TclError, 'bad option "-foo"'): self.root.grid_rowconfigure(0, 'foo') self.root.grid_rowconfigure((0, 3), weight=2) with self.assertRaisesRegexp(TclError, 'must specify a single element on retrieval'): self.root.grid_rowconfigure((0, 3)) b = tkinter.Button(self.root) b.grid_configure(column=0, row=0) if tcl_version >= (8, 5): self.root.grid_rowconfigure('all', weight=3) with self.assertRaisesRegexp(TclError, 'expected integer but got "all"'): self.root.grid_rowconfigure('all') self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3) self.assertEqual(self.root.grid_rowconfigure(3, 'weight'), 2) self.assertEqual(self.root.grid_rowconfigure(265, 'weight'), 0) if tcl_version >= (8, 5): self.root.grid_rowconfigure(b, weight=4) self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4) def test_grid_rowconfigure_minsize(self): with self.assertRaisesRegexp(TclError, 'bad screen distance "foo"'): self.root.grid_rowconfigure(0, minsize='foo') self.root.grid_rowconfigure(0, minsize=10) self.assertEqual(self.root.grid_rowconfigure(0, 'minsize'), 10) self.assertEqual(self.root.grid_rowconfigure(0)['minsize'], 10) def test_grid_rowconfigure_weight(self): with self.assertRaisesRegexp(TclError, 'expected integer but got "bad"'): self.root.grid_rowconfigure(0, weight='bad') with self.assertRaisesRegexp(TclError, 'invalid arg "-weight": ' 'should be non-negative'): self.root.grid_rowconfigure(0, weight=-3) self.root.grid_rowconfigure(0, weight=3) self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3) self.assertEqual(self.root.grid_rowconfigure(0)['weight'], 3) def test_grid_rowconfigure_pad(self): with self.assertRaisesRegexp(TclError, 'bad screen distance "foo"'): self.root.grid_rowconfigure(0, pad='foo') with self.assertRaisesRegexp(TclError, 'invalid arg "-pad": ' 'should be non-negative'): self.root.grid_rowconfigure(0, pad=-3) self.root.grid_rowconfigure(0, pad=3) self.assertEqual(self.root.grid_rowconfigure(0, 'pad'), 3) self.assertEqual(self.root.grid_rowconfigure(0)['pad'], 3) def test_grid_rowconfigure_uniform(self): self.root.grid_rowconfigure(0, uniform='foo') self.assertEqual(self.root.grid_rowconfigure(0, 'uniform'), 'foo') self.assertEqual(self.root.grid_rowconfigure(0)['uniform'], 'foo') def test_grid_forget(self): b = tkinter.Button(self.root) c = tkinter.Button(self.root) b.grid_configure(row=2, column=2, rowspan=2, columnspan=2, padx=3, pady=4, sticky='ns') self.assertEqual(self.root.grid_slaves(), [b]) b.grid_forget() c.grid_forget() self.assertEqual(self.root.grid_slaves(), []) self.assertEqual(b.grid_info(), {}) b.grid_configure(row=0, column=0) info = b.grid_info() self.assertEqual(info['row'], self._str(0)) self.assertEqual(info['column'], self._str(0)) self.assertEqual(info['rowspan'], self._str(1)) self.assertEqual(info['columnspan'], self._str(1)) self.assertEqual(info['padx'], self._str(0)) self.assertEqual(info['pady'], self._str(0)) self.assertEqual(info['sticky'], '') def test_grid_remove(self): b = tkinter.Button(self.root) c = tkinter.Button(self.root) b.grid_configure(row=2, column=2, rowspan=2, columnspan=2, padx=3, pady=4, sticky='ns') self.assertEqual(self.root.grid_slaves(), [b]) b.grid_remove() c.grid_remove() self.assertEqual(self.root.grid_slaves(), []) self.assertEqual(b.grid_info(), {}) b.grid_configure(row=0, column=0) info = b.grid_info() self.assertEqual(info['row'], self._str(0)) self.assertEqual(info['column'], self._str(0)) self.assertEqual(info['rowspan'], self._str(2)) self.assertEqual(info['columnspan'], self._str(2)) self.assertEqual(info['padx'], self._str(3)) self.assertEqual(info['pady'], self._str(4)) self.assertEqual(info['sticky'], 'ns') def test_grid_info(self): b = tkinter.Button(self.root) self.assertEqual(b.grid_info(), {}) b.grid_configure(row=2, column=2, rowspan=2, columnspan=2, padx=3, pady=4, sticky='ns') info = b.grid_info() self.assertIsInstance(info, dict) self.assertEqual(info['in'], self.root) self.assertEqual(info['row'], self._str(2)) self.assertEqual(info['column'], self._str(2)) self.assertEqual(info['rowspan'], self._str(2)) self.assertEqual(info['columnspan'], self._str(2)) self.assertEqual(info['padx'], self._str(3)) self.assertEqual(info['pady'], self._str(4)) self.assertEqual(info['sticky'], 'ns') def test_grid_bbox(self): self.assertEqual(self.root.grid_bbox(), (0, 0, 0, 0)) self.assertEqual(self.root.grid_bbox(0, 0), (0, 0, 0, 0)) self.assertEqual(self.root.grid_bbox(0, 0, 1, 1), (0, 0, 0, 0)) with self.assertRaisesRegexp(TclError, 'expected integer but got "x"'): self.root.grid_bbox('x', 0) with self.assertRaisesRegexp(TclError, 'expected integer but got "x"'): self.root.grid_bbox(0, 'x') with self.assertRaisesRegexp(TclError, 'expected integer but got "x"'): self.root.grid_bbox(0, 0, 'x', 0) with self.assertRaisesRegexp(TclError, 'expected integer but got "x"'): self.root.grid_bbox(0, 0, 0, 'x') with self.assertRaises(TypeError): self.root.grid_bbox(0, 0, 0, 0, 0) t = self.root # de-maximize t.wm_geometry('1x1+0+0') t.wm_geometry('') f1 = tkinter.Frame(t, width=75, height=75, bg='red') f2 = tkinter.Frame(t, width=90, height=90, bg='blue') f1.grid_configure(row=0, column=0) f2.grid_configure(row=1, column=1) self.root.update() self.assertEqual(t.grid_bbox(), (0, 0, 165, 165)) self.assertEqual(t.grid_bbox(0, 0), (0, 0, 75, 75)) self.assertEqual(t.grid_bbox(0, 0, 1, 1), (0, 0, 165, 165)) self.assertEqual(t.grid_bbox(1, 1), (75, 75, 90, 90)) self.assertEqual(t.grid_bbox(10, 10, 0, 0), (0, 0, 165, 165)) self.assertEqual(t.grid_bbox(-2, -2, -1, -1), (0, 0, 0, 0)) self.assertEqual(t.grid_bbox(10, 10, 12, 12), (165, 165, 0, 0)) def test_grid_location(self): with self.assertRaises(TypeError): self.root.grid_location() with self.assertRaises(TypeError): self.root.grid_location(0) with self.assertRaises(TypeError): self.root.grid_location(0, 0, 0) with self.assertRaisesRegexp(TclError, 'bad screen distance "x"'): self.root.grid_location('x', 'y') with self.assertRaisesRegexp(TclError, 'bad screen distance "y"'): self.root.grid_location('1c', 'y') t = self.root # de-maximize t.wm_geometry('1x1+0+0') t.wm_geometry('') f = tkinter.Frame(t, width=200, height=100, highlightthickness=0, bg='red') self.assertEqual(f.grid_location(10, 10), (-1, -1)) f.grid_configure() self.root.update() self.assertEqual(t.grid_location(-10, -10), (-1, -1)) self.assertEqual(t.grid_location(-10, 0), (-1, 0)) self.assertEqual(t.grid_location(-1, 0), (-1, 0)) self.assertEqual(t.grid_location(0, -10), (0, -1)) self.assertEqual(t.grid_location(0, -1), (0, -1)) self.assertEqual(t.grid_location(0, 0), (0, 0)) self.assertEqual(t.grid_location(200, 0), (0, 0)) self.assertEqual(t.grid_location(201, 0), (1, 0)) self.assertEqual(t.grid_location(0, 100), (0, 0)) self.assertEqual(t.grid_location(0, 101), (0, 1)) self.assertEqual(t.grid_location(201, 101), (1, 1)) def test_grid_propagate(self): self.assertEqual(self.root.grid_propagate(), True) with self.assertRaises(TypeError): self.root.grid_propagate(False, False) self.root.grid_propagate(False) self.assertFalse(self.root.grid_propagate()) f = tkinter.Frame(self.root, width=100, height=100, bg='red') f.grid_configure(row=0, column=0) self.root.update() self.assertEqual(f.winfo_width(), 100) self.assertEqual(f.winfo_height(), 100) f.grid_propagate(False) g = tkinter.Frame(self.root, width=75, height=85, bg='green') g.grid_configure(in_=f, row=0, column=0) self.root.update() self.assertEqual(f.winfo_width(), 100) self.assertEqual(f.winfo_height(), 100) f.grid_propagate(True) self.root.update() self.assertEqual(f.winfo_width(), 75) self.assertEqual(f.winfo_height(), 85) def test_grid_size(self): with self.assertRaises(TypeError): self.root.grid_size(0) self.assertEqual(self.root.grid_size(), (0, 0)) f = tkinter.Scale(self.root) f.grid_configure(row=0, column=0) self.assertEqual(self.root.grid_size(), (1, 1)) f.grid_configure(row=4, column=5) self.assertEqual(self.root.grid_size(), (6, 5)) def test_grid_slaves(self): self.assertEqual(self.root.grid_slaves(), []) a = tkinter.Label(self.root) a.grid_configure(row=0, column=1) b = tkinter.Label(self.root) b.grid_configure(row=1, column=0) c = tkinter.Label(self.root) c.grid_configure(row=1, column=1) d = tkinter.Label(self.root) d.grid_configure(row=1, column=1) self.assertEqual(self.root.grid_slaves(), [d, c, b, a]) self.assertEqual(self.root.grid_slaves(row=0), [a]) self.assertEqual(self.root.grid_slaves(row=1), [d, c, b]) self.assertEqual(self.root.grid_slaves(column=0), [b]) self.assertEqual(self.root.grid_slaves(column=1), [d, c, a]) self.assertEqual(self.root.grid_slaves(row=1, column=1), [d, c]) tests_gui = ( PackTest, PlaceTest, GridTest, ) if __name__ == '__main__': run_unittest(*tests_gui) PK]test_tkinter/test_loadtk.pycnu[ zfc@sddlZddlZddlZddlmZddlmZmZejddej fdYZ e fZ e dkrej e ndS(iN(t test_support(tTcltTclErrortguit TkLoadTestcBs5eZejdejkddZdZRS(tDISPLAYsNo $DISPLAY set.cCsJt}|jt|j|j|jd|j|jdS(Ns1x1+0+0(Rt assertRaisesRtwinfo_geometrytloadtkt assertEqualtdestroy(tselfttcl((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyt testLoadTk s   cCsd}tjjdrdStjt}dtjkri|d=tjdj j }|ridSnt }|j t |j|j t |jWdQXdS(NtwintdarwintcygwinRs echo $DISPLAY(RRR(tNonetsystplatformt startswithRtEnvironmentVarGuardtostenvirontpopentreadtstripRRRRR(R t old_displaytenvtdisplayR ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyttestLoadTkFailures (t__name__t __module__tunittesttskipIfRRR R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyR s$t__main__(RRR!ttestRtTkinterRRtrequirestTestCaseRt tests_guiRt run_unittest(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_loadtk.pyts    !  PK]% test_tkinter/test_variables.pynu[import unittest import gc from Tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl, TclError) class TestBase(unittest.TestCase): def setUp(self): self.root = Tcl() def tearDown(self): del self.root class TestVariable(TestBase): def info_exists(self, *args): return self.root.getboolean(self.root.call("info", "exists", *args)) def test_default(self): v = Variable(self.root) self.assertEqual("", v.get()) self.assertRegexpMatches(str(v), r"^PY_VAR(\d+)$") def test_name_and_value(self): v = Variable(self.root, "sample string", "varname") self.assertEqual("sample string", v.get()) self.assertEqual("varname", str(v)) def test___del__(self): self.assertFalse(self.info_exists("varname")) v = Variable(self.root, "sample string", "varname") self.assertTrue(self.info_exists("varname")) del v self.assertFalse(self.info_exists("varname")) def test_dont_unset_not_existing(self): self.assertFalse(self.info_exists("varname")) v1 = Variable(self.root, name="name") v2 = Variable(self.root, name="name") del v1 self.assertFalse(self.info_exists("name")) # shouldn't raise exception del v2 self.assertFalse(self.info_exists("name")) def test___eq__(self): # values doesn't matter, only class and name are checked v1 = Variable(self.root, name="abc") v2 = Variable(self.root, name="abc") self.assertEqual(v1, v2) v3 = Variable(self.root, name="abc") v4 = StringVar(self.root, name="abc") self.assertNotEqual(v3, v4) def test_invalid_name(self): with self.assertRaises(TypeError): Variable(self.root, name=123) def test_null_in_name(self): with self.assertRaises(ValueError): Variable(self.root, name='var\x00name') with self.assertRaises(ValueError): self.root.globalsetvar('var\x00name', "value") with self.assertRaises(ValueError): self.root.setvar('var\x00name', "value") def test_trace(self): v = Variable(self.root) vname = str(v) trace = [] def read_tracer(*args): trace.append(('read',) + args) def write_tracer(*args): trace.append(('write',) + args) cb1 = v.trace_variable('r', read_tracer) cb2 = v.trace_variable('wu', write_tracer) self.assertEqual(sorted(v.trace_vinfo()), [('r', cb1), ('wu', cb2)]) self.assertEqual(trace, []) v.set('spam') self.assertEqual(trace, [('write', vname, '', 'w')]) trace = [] v.get() self.assertEqual(trace, [('read', vname, '', 'r')]) trace = [] info = sorted(v.trace_vinfo()) v.trace_vdelete('w', cb1) # Wrong mode self.assertEqual(sorted(v.trace_vinfo()), info) with self.assertRaises(TclError): v.trace_vdelete('r', 'spam') # Wrong command name self.assertEqual(sorted(v.trace_vinfo()), info) v.trace_vdelete('r', (cb1, 43)) # Wrong arguments self.assertEqual(sorted(v.trace_vinfo()), info) v.get() self.assertEqual(trace, [('read', vname, '', 'r')]) trace = [] v.trace_vdelete('r', cb1) self.assertEqual(v.trace_vinfo(), [('wu', cb2)]) v.get() self.assertEqual(trace, []) trace = [] del write_tracer gc.collect() v.set('eggs') self.assertEqual(trace, [('write', vname, '', 'w')]) #trace = [] #del v #gc.collect() #self.assertEqual(trace, [('write', vname, '', 'u')]) class TestStringVar(TestBase): def test_default(self): v = StringVar(self.root) self.assertEqual("", v.get()) def test_get(self): v = StringVar(self.root, "abc", "name") self.assertEqual("abc", v.get()) self.root.globalsetvar("name", "value") self.assertEqual("value", v.get()) def test_get_null(self): v = StringVar(self.root, "abc\x00def", "name") self.assertEqual("abc\x00def", v.get()) self.root.globalsetvar("name", "val\x00ue") self.assertEqual("val\x00ue", v.get()) class TestIntVar(TestBase): def test_default(self): v = IntVar(self.root) self.assertEqual(0, v.get()) def test_get(self): v = IntVar(self.root, 123, "name") self.assertEqual(123, v.get()) self.root.globalsetvar("name", "345") self.assertEqual(345, v.get()) def test_invalid_value(self): v = IntVar(self.root, name="name") self.root.globalsetvar("name", "value") with self.assertRaises(ValueError): v.get() self.root.globalsetvar("name", "345.0") with self.assertRaises(ValueError): v.get() class TestDoubleVar(TestBase): def test_default(self): v = DoubleVar(self.root) self.assertEqual(0.0, v.get()) def test_get(self): v = DoubleVar(self.root, 1.23, "name") self.assertAlmostEqual(1.23, v.get()) self.root.globalsetvar("name", "3.45") self.assertAlmostEqual(3.45, v.get()) def test_get_from_int(self): v = DoubleVar(self.root, 1.23, "name") self.assertAlmostEqual(1.23, v.get()) self.root.globalsetvar("name", "3.45") self.assertAlmostEqual(3.45, v.get()) self.root.globalsetvar("name", "456") self.assertAlmostEqual(456, v.get()) def test_invalid_value(self): v = DoubleVar(self.root, name="name") self.root.globalsetvar("name", "value") with self.assertRaises(ValueError): v.get() class TestBooleanVar(TestBase): def test_default(self): v = BooleanVar(self.root) self.assertIs(v.get(), False) def test_get(self): v = BooleanVar(self.root, True, "name") self.assertIs(v.get(), True) self.root.globalsetvar("name", "0") self.assertIs(v.get(), False) self.root.globalsetvar("name", 42 if self.root.wantobjects() else 1) self.assertIs(v.get(), True) self.root.globalsetvar("name", 0) self.assertIs(v.get(), False) self.root.globalsetvar("name", 42L if self.root.wantobjects() else 1L) self.assertIs(v.get(), True) self.root.globalsetvar("name", 0L) self.assertIs(v.get(), False) self.root.globalsetvar("name", "on") self.assertIs(v.get(), True) self.root.globalsetvar("name", u"0") self.assertIs(v.get(), False) self.root.globalsetvar("name", u"on") self.assertIs(v.get(), True) def test_set(self): true = 1 if self.root.wantobjects() else "1" false = 0 if self.root.wantobjects() else "0" v = BooleanVar(self.root, name="name") v.set(True) self.assertEqual(self.root.globalgetvar("name"), true) v.set("0") self.assertEqual(self.root.globalgetvar("name"), false) v.set(42) self.assertEqual(self.root.globalgetvar("name"), true) v.set(0) self.assertEqual(self.root.globalgetvar("name"), false) v.set(42L) self.assertEqual(self.root.globalgetvar("name"), true) v.set(0L) self.assertEqual(self.root.globalgetvar("name"), false) v.set("on") self.assertEqual(self.root.globalgetvar("name"), true) v.set(u"0") self.assertEqual(self.root.globalgetvar("name"), false) v.set(u"on") self.assertEqual(self.root.globalgetvar("name"), true) def test_invalid_value_domain(self): false = 0 if self.root.wantobjects() else "0" v = BooleanVar(self.root, name="name") with self.assertRaises(TclError): v.set("value") self.assertEqual(self.root.globalgetvar("name"), false) self.root.globalsetvar("name", "value") with self.assertRaises(TclError): v.get() self.root.globalsetvar("name", "1.0") with self.assertRaises(TclError): v.get() tests_gui = (TestVariable, TestStringVar, TestIntVar, TestDoubleVar, TestBooleanVar) if __name__ == "__main__": from test.support import run_unittest run_unittest(*tests_gui) PK]!=޼test_tkinter/test_text.pynu[import unittest import Tkinter as tkinter from test.test_support import requires, run_unittest from test_ttk.support import AbstractTkTest requires('gui') class TextTest(AbstractTkTest, unittest.TestCase): def setUp(self): super(TextTest, self).setUp() self.text = tkinter.Text(self.root) def test_debug(self): text = self.text olddebug = text.debug() try: text.debug(0) self.assertEqual(text.debug(), 0) text.debug(1) self.assertEqual(text.debug(), 1) finally: text.debug(olddebug) self.assertEqual(text.debug(), olddebug) def test_search(self): text = self.text # pattern and index are obligatory arguments. self.assertRaises(tkinter.TclError, text.search, None, '1.0') self.assertRaises(tkinter.TclError, text.search, 'a', None) self.assertRaises(tkinter.TclError, text.search, None, None) # Invalid text index. self.assertRaises(tkinter.TclError, text.search, '', 0) # Check if we are getting the indices as strings -- you are likely # to get Tcl_Obj under Tk 8.5 if Tkinter doesn't convert it. text.insert('1.0', 'hi-test') self.assertEqual(text.search('-test', '1.0', 'end'), '1.2') self.assertEqual(text.search('test', '1.0', 'end'), '1.3') tests_gui = (TextTest, ) if __name__ == "__main__": run_unittest(*tests_gui) PK]-ԠԠ'test_tkinter/test_geometry_managers.pycnu[ zfc@sddlZddlZddlZddlmZddlmZmZddlm Z m Z m Z ddl m Z mZedde ejfdYZd e ejfd YZd e ejfd YZeeefZed kreendS(iN(tTclError(trequirest run_unittest(t pixels_convt tcl_versiont requires_tcl(tAbstractWidgetTestt int_roundtguitPackTestcBseZd ZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd ZRS(c Cstj|jdd}|jd|jddtj|dddddd d d }tj|dd dd ddd d}tj|ddddddd d}tj|dddd ddd d}|||||fS(Ntnametpacks 300x200+0+0itatwidthitheighti(tbgtredtbi2itbluetciPtgreentdtyellow(ttkintertTopleveltroott wm_geometryt wm_minsizetFrame(tselfR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pytcreate2s ''''cCs;|j\}}}}}|jtd||jd|WdQX|jtd|jddWdQX|jdd|jdd|jdd|jdd|j|j||||g|jd||j|j||||g|jd||j|j||||gdS(Nswindow "%s" isn't packedtaftersbad window path name ".foo"s.footsidettop(RtassertRaisesRegexpRtpack_configuret assertEqualt pack_slaves(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_afters""csj\}}}}fd}|dd|dd|dd|dd |d d |d d |dd|dd|dddS(Ncs[jddddddddd d d td |jjjj|dS( NR R!tipadxitpadxi tipadyitpadyitexpandtanchor(R#tTrueRtupdateR$twinfo_geometry(R,tgeom(R R(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pytcheck-s'  tns 30x70+135+20tnes 30x70+260+20tes 30x70+260+65tses 30x70+260+110tss 30x70+135+110tsws 30x70+10+110tws 30x70+10+65tnws 30x70+10+20tcenters 30x70+135+65(R(RR RRRR1((R RsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_anchor+s        cCs;|j\}}}}}|jtd||jd|WdQX|jtd|jddWdQX|jdd|jdd|jdd|jdd|j|j||||g|jd||j|j||||g|jd||j|j||||gdS(Nswindow "%s" isn't packedtbeforesbad window path name ".foo"s.fooR R!(RR"RR#R$R%(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_before<s""cs{j\}fd}jddjddjddjdd|ddd d jddd d jddd d jddd tjddd d|ddddjddd d ddjddd d ddjddd tddjddd ddd|dddddS(Ncsyjjjj|djj|djj|djj|ddS(Niiii(RR.R$R/(tgeoms(R RRRR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1Ns  R tleftR!trighttbottoms 20x40+0+80s 50x30+135+0s 80x80+220+75s 40x30+100+170R+tyestonis 20x40+40+80s 50x30+175+35s 80x80+180+110s 40x30+100+135tfilltboths 100x200+0+0s 200x100+100+0s160x100+140+100s40x100+100+100(RR#R-(RR R1((R RRRRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_expandLs"cCs2|j\}}}}}|jdd|jdd|jdd|jdd|jd||j|j||||g|jd||j|j|||g|j|j|g|jtd|f|jd|WdQX|jtd|jddWdQXdS(NR R!tin_scan't pack %s inside itselfsbad window path name ".foo"s.foo(RR#R$R%R"R(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_inds" c sj\}}}fd}|dddddd|dddddd'|d dddd d|d dddd ddd |dddddddd|dddddd(dd|d dddd ddd|d dddd ddd dd|ddddd ddd)dd|dddddd|dddddd*|ddddd d|ddddd ddd |ddddd ddd+|d ddddddd|d!ddddd,dd|d#dddd ddd|d$dddd ddd dd|d%dddd ddd-ddjdd&jjdj|jd&jd d&jjd j|jd&dS(.Ncstjjj|jdtddjjjj|jj|dS(NR+RDRE(t pack_forgetR#R-RR.R$R/(tgeom1tgeom2tkwargs(R RR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1ws    s 20x40+260+80s 240x200+0+0R R@R(is 20x40+250+80i is 60x40+240+80R's 30x40+260+80s 250x200+0+0iRDtxs 20x40+249+80i is 30x40+255+80is 20x40+140+0s 300x160+0+40R!s 20x40+120+0ii(s 60x40+120+0s 30x40+135+0s 30x40+130+0s 260x40+20+0s 260x40+25+0is 300x40+0+0s 280x40+10+0s 280x40+5+0t1c(i i(i i(ii(ii((ii(ii(ii(RR#R$t pack_infot_strt winfo_pixels(RR RRR1((R RRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt#test_pack_configure_padx_ipadx_fillusB      c sj\}}}fd}|dddddd|dddddd'|d dddd d|d dddd ddd |dddddddd|dddddd(dd|d dddd ddd|d dddd ddd dd|ddddd ddd)dd|dddddd|dddddd*|ddddd d|ddddd ddd |ddddd ddd+|d ddddddd|d!ddddd,dd|d#dddd ddd|d$dddd ddd dd|d%dddd ddd-ddjdd&jjdj|jd&jd d&jjd j|jd&dS(.Ncstjjj|jdtddjjjj|jj|dS(NR+RDRE(RIR#R-RR.R$R/(RJRKRL(R RR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1s    s 20x40+280+80s 280x200+0+0R R@R*is 20x40+280+70i is 20x80+280+60R)s 20x50+280+75iRDRMs 20x40+280+69i is 20x50+280+70is 20x40+140+20s 300x120+0+80R!s 20x40+140+0ii(s 20x80+140+0s 20x50+140+10s 300x130+0+70s 20x50+140+5s 300x40+0+20s 300x40+0+25is 300x80+0+0s 300x50+0+10s 300x50+0+5RN(i i(i i(ii(ii((ii(ii(ii(RR#R$RORPRQ(RR RRR1((R RRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt#test_pack_configure_pady_ipady_fillsB      cstj\}}}fd}|ddd|ddd|dd d |d d d dS(Ncs}jd|jjd|jdtddjjjj|jj|dS(NR R+RDRE(R#R$ROR-RR.R/(R RJRK(R RR(sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR1s  R!s 20x40+140+0s 300x160+0+40RAs 20x40+140+160s 300x160+0+0R?s 20x40+0+80s 280x200+20+0R@s 20x40+280+80s 280x200+0+0(R(RR RRR1((R RRsG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_configure_sides cCs|j\}}}}}|j|j|j|j|j|||g|j|j|j||g|j|j|j||g|jdS(N(RR#R$R%RI(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_forgets     cCs|j\}}}}}|jtd||jWdQX|j|jddd|dddtdd d d d d dddd |j}|j|t|j|dd|j|d|j d|j|dd|j|d||j|d |j d|j|d|j d|j|d |j d|j|d|j d|j|dd|j}|j|t|j|dd|j|d|j d|j|dd |j|d||j|d |j d |j|d|j d|j|d |j d |j|d|j d|j|dddS(Nswindow "%s" isn't packedR R@RGR,R6R+RDRMR'iR(i R)iR*iR:itnonetinR!i(ii(ii( RR"RROR#R-tassertIsInstancetdictR$RP(RR R RRRtinfo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_infos8 '  cCs|j\}}}}}|jdddd|j|jt|jj|j|jd|j|j d|jt |jj|j|jd|j|j ddS(NR i,Riii(( Rt configureR#tpack_propagatetFalseRR.R$twinfo_reqwidthtwinfo_reqheightR-(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_propagates     cCs~|j\}}}}}|j|jg|j|j|j|g|j|j|j||gdS(N(RR$R%R#(RR R RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_pack_slavess   N(t__name__t __module__tNonet test_keysRR&R;R=RFRHRRRSRTRUR[RaRb(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyR s      * *   t PlaceTestcBseZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZRS(c Cstj|jdddddd}|jdtj|dddd dd d d }|jd dddtj|dddddd d d }|jj|||fS(NR i,Ritbdis 300x200+0+0iiTitrelieftraisedRMi0tyi&ii<(RRRRRtplace_configureR.(Rtttftf2((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRs$ '' cCs|j\}}}|j|jd|jtdtjt||jd|WdQXt d kr|j|jdn|jtd|jddWdQX|jd||j|jddS( Nts!can't place %s relative to itselfRGiisbad window path nametspamtplace(ii( RR$t winfo_managerR"RtretescapetstrRlR(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_in$s  c Cs5|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jddd d |j|jdd |jj|j|jd |jtd |jd|ddWdQXdS(NRGRMt0i2idt100iitrelxis-10isbad screen distance "spam"Rq( RRlR$t place_infoRR.twinfo_xR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_x1s   c Cs5|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jddd d |j|jdd |jj|j|jd |jtd |jd|ddWdQXdS(NRGRkRxi(i2t50iZitrelyis-10insbad screen distance "spam"Rq( RRlR$R{RR.twinfo_yR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_yBs   c Cs/|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jdd|j|jdd |jj|j|jd |jtd |jd|dd WdQXdS( NRGRzRxi2g?s0.5i}it1is-expected floating-point number but got "spam"Rq( RRlR$R{RR.R|R"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relxSs   c Cs/|j\}}}|jd||j|jdd|jj|j|jd|jdd|j|jdd|jj|j|jd|jdd|j|jdd |jj|j|jd |jtd |jd|dd WdQXdS( NRGRRxi(g?s0.5iPiRixs-expected floating-point number but got "spam"Rq( RRlR$R{RR.RR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relyes   c Cstj|j}|jtd|jddWdQX|jtd|jddWdQXx8dD]0}|jd||j|jd|qkWdS(Nsbad anchor "j"R,tjsambiguous anchor ""RpR2R3R4R5R6R7R8R9R:( R2R3R4R5R6R7R8R9R:(RRRR"RRlR$R{(RRntvalue((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_anchorws cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS(NRGR ixRpisbad screen distance "abcd"tabcd(RRlRR.R$t winfo_widthR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_widths  cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS(NRGRixRpi<sbad screen distance "abcd"R(RRlRR.R$t winfo_heightR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_heights  cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS( NRGtrelwidthg?iKRpis-expected floating-point number but got "abcd"R(RRlRR.R$RR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relwidths  cCs|j\}}}|jd|dd|jj|j|jd|jdd|jj|j|jd|jtd|jddWdQXdS( NRGt relheightg?i(Rpi<s-expected floating-point number but got "abcd"R(RRlRR.R$RR"R(RRmRnRo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_relheights  cCstj|j}|jtd|jddWdQX|jtd|jddWdQXx8d D]0}|jd||j|jd|qkWdS( Nsbad bordermode "j"t bordermodeRsambiguous bordermode ""Rptinsidetoutsidetignore(RRR(RRRR"RRlR$R{(RRnR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_configure_bordermodes cCstj|j}|jdddd|jj|j|jj|j|j|jt |jdWdQXdS(NR i2Ri( RRRRlR.t place_forgett assertFalsetwinfo_ismappedt assertRaisest TypeError(Rtfoo((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_forgets   cCs|j\}}}|jd|dddddddd d d d d dddddddd |j}|j|t|j|dd|j|dd|j|dd|j|dd|j|d d|j|d d|j|dd|j|dd|j|dd|j|dd|j|dd|j|dd|jt|jdWdQXdS(NRGRMiRkiR iRiRzg?Rg?Rg333333?Rg?R,R5RRRt2t3t4s0.1s0.2s0.3s0.4i(RRlR{RXRYR$RR(RRmRnRoRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_infos('  cCstj|j}tj|j}|j|jg|jd||j|j|g|jt|jdWdQXdS(NRGi(RRRR$t place_slavesRlRR(RRtbar((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_place_slavessN(RcRdReRfRRwR}RRRRRRRRRRRR(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRgs      tGridTestcBseZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!RS(c Cs|jj\}}x@t|dD].}|jj|ddddddddq&Wx@t|dD].}|jj|ddddddddqiW|jjdtt|jdS(NitweightitminsizetpadtuniformRp( Rt grid_sizetrangetgrid_columnconfiguretgrid_rowconfiguretgrid_propagatetsuperRttearDown(Rtcolstrowsti((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRs,,cCstj|j}|j|ji|j|j|jd|j|j|jd|jd|j|jd|jd|jidd6dd|j|jd|jd|j|jd|jddS(NRWtcolumnitrowii(RtButtonRR$t grid_infotgrid_configureRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configures ###cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns5bad column value "-1": must be a non-negative integerRii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_columns cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns4bad columnspan value "0": must be a positive integert columnspanii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_columnspans cCstj|j}tj|j}|j|ji|j|j|jd|j|jd||j|jd||ji|jd6|j|jd|jdS(NRWRG(RRRRR$RR(RRnR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_in s cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jt t d|j dS(Ns6bad ipadx value "-1": must be positive screen distanceR'iis.5c( RRRR"RRR$RRPRRtscaling(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_ipadxs#cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jt t d|j dS(Ns6bad ipady value "-1": must be positive screen distanceR)iis.5c( RRRR"RRR$RRPRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_ipady!s#cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jd |jdd|j|jd|jt t d|j dS( Ns4bad pad value "-1": must be positive screen distanceR(iii is.5c(i i(i i( RRRR"RRR$RRPRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_padx,s##cCstj|j}|jtd|jddWdQX|jdd|j|jd|jd|jdd|j|jd|jd |jdd|j|jd|jt t d|j dS( Ns4bad pad value "-1": must be positive screen distanceR*iii is.5c(i i(i i( RRRR"RRR$RRPRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_pady9s##cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns9bad (row|grid) value "-1": must be a non-negative integerRii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_rowFs cCsrtj|j}|jtd|jddWdQX|jdd|j|jd|jddS(Ns1bad rowspan value "0": must be a positive integertrowspanii( RRRR"RRR$RRP(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_rownspanNs cCstj|jdd}|jtd|jddWdQX|jdd|j|jdd|jdd|j|jdddS( NRRsbad stickyness value "glue"tstickytglueR3sn,s,e,wtnesw(RRRR"RRR$R(RRn((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_configure_stickyVsc Cs|jt|jjWdQX|j|jjdidd6dd6dd6dd6|jtd|jjddWdQX|jjddd |jtd |jjdWdQXtj |j}|j d dd dt dkr[|jjddd|jtd|jjdWdQX|j|jjdddn|j|jjddd |j|jjdddt dkr|jj|dd|j|jjdddndS(NiRRRRsbad option "-foo"Riis*must specify a single element on retrievalRRiitallsexpected integer but got "all"i i(ii(ii(ii(ii( RRRRR$ReR"RRRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_columnconfigure_s,#   " cCs|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRi (R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt!test_grid_columnconfigure_minsizews c Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsexpected integer but got "bad"iRtbads-invalid arg "-weight": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt test_grid_columnconfigure_weight~sc Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRs*invalid arg "-pad": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_columnconfigure_padscCsY|jjddd|j|jjddd|j|jjddddS(NiRR(RRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyt!test_grid_columnconfigure_uniformsc Cs|jt|jjWdQX|j|jjdidd6dd6dd6dd6|jtd|jjddWdQX|jjddd |jtd |jjdWdQXtj |j}|j d dd dt dkr[|jjddd|jtd|jjdWdQX|j|jjdddn|j|jjddd |j|jjdddt dkr|jj|dd|j|jjdddndS(NiRRRRsbad option "-foo"Riis*must specify a single element on retrievalRRiiRsexpected integer but got "all"i i(ii(ii(ii(ii( RRRRR$ReR"RRRRR(RR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigures,#   " cCs|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRi (R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_minsizes c Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsexpected integer but got "bad"iRRs-invalid arg "-weight": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_weightsc Cs|jtd|jjdddWdQX|jtd|jjdddWdQX|jjddd|j|jjddd|j|jjddddS(Nsbad screen distance "foo"iRRs*invalid arg "-pad": should be non-negativeii(R"RRRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_padscCsY|jjddd|j|jjddd|j|jjddddS(NiRR(RRR$(R((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_rowconfigure_uniformscCstj|j}tj|j}|jdddddddddddd d d |j|jj|g|j|j|j|jjg|j|ji|jdd dd |j}|j|d|jd |j|d|jd |j|d|jd |j|d|jd |j|d|jd |j|d|jd |j|d ddS(NRiRRRR(iR*iRtnsiiRp( RRRRR$t grid_slavest grid_forgetRRP(RRRRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_forgets$!   cCstj|j}tj|j}|jdddddddddddd d d |j|jj|g|j|j|j|jjg|j|ji|jdd dd |j}|j|d|jd |j|d|jd |j|d|jd|j|d|jd|j|d|jd|j|d|jd |j|d d dS( NRiRRRR(iR*iRRi( RRRRR$Rt grid_removeRRP(RRRRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_removes$!   cCsUtj|j}|j|ji|jdddddddddddd d d |j}|j|t|j|d |j|j|d|jd|j|d|jd|j|d|jd|j|d|jd|j|d|jd|j|d|jd |j|d d dS( NRiRRRR(iR*iRRRW( RRRR$RRRXRYRP(RRRZ((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_infos! cCs|j|jjd|j|jjddd|j|jjddddd|jtd|jjddWdQX|jtd|jjddWdQX|jtd|jjddddWdQX|jtd|jjddddWdQX|jt!|jjdddddWdQX|j}|jd|jdtj |ddd dd d }tj |dd d d d d }|j dddd|j dddd|jj |j|jd|j|jddd|j|jddddd|j|jddd|j|jddddd|j|jddddd|j|jddddddS(Niisexpected integer but got "x"RMs1x1+0+0RpR iKRRRiZRRRii iii (iiii(iiii(iiii(iiii(iiiKiK(iiii(iKiKiZiZ(iiii(iiii(iiii( R$Rt grid_bboxR"RRRRRRRR.(RRmtf1Ro((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_bboxs8%"   !! """cCs|jt|jjWdQX|jt|jjdWdQX|jt|jjdddWdQX|jtd|jjddWdQX|jtd|jjddWdQX|j}|jd|jdtj|d d d d d ddd}|j |jddd|j |jj |j |jddd|j |jddd|j |jddd|j |jddd|j |jddd|j |jddd|j |jd dd|j |jddd|j |jdd d|j |jddd |j |jddd!dS("Nisbad screen distance "x"RMRksbad screen distance "y"RNs1x1+0+0RpR iRidthighlightthicknessRRi iiiiie(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii( RRRt grid_locationR"RRRRR$RR.(RRmRn((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_location&s:     c Cs|j|jjt|jt|jjttWdQX|jjt|j|jjtj |jdddddd}|j dddd|jj |j|j d|j|j d|jttj |jdd dd dd }|j d |dddd|jj |j|j d|j|j d|jt|jj |j|j d |j|j d dS( NR idRRRRiRiKiURRG(R$RRR-RRR^RRRRR.RR(RRntg((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_propagateFs($  $   cCs|jt|jjdWdQX|j|jjdtj|j}|jdddd|j|jjd |jdddd|j|jjd dS( NiRRiiii(ii(ii(ii(RRRRR$RtScaleR(RRn((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_size\scCs|j|jjgtj|j}|jddddtj|j}|jddddtj|j}|jddddtj|j}|jdddd|j|jj||||g|j|jjdd|g|j|jjdd|||g|j|jjdd|g|j|jjdd|||g|j|jjdddd||gdS(NRiRi(R$RRRtLabelR(RR RRR((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyttest_grid_slavesfs%"("(N("RcRdReRfRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyRs>                t__main__(tunittestRttTkinterRRttest.test_supportRRttest_ttk.supportRRRt widget_testsRRtTestCaseR RgRt tests_guiRc(((sG/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_geometry_managers.pyts      PK]3,O'>'>test_tkinter/test_images.pycnu[ zfc@sddlZddlZddlZddljZddlmZm Z ej ddeej fdYZ deej fdYZ deej fd YZe e efZed krejendS( iN(tAbstractTkTestt requires_tcltguitMiscTestcBseZdZdZRS(cCsC|jj}|j|t|jd||jd|dS(Ntphototbitmap(troott image_typestassertIsInstancettupletassertIn(tselfR((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_image_types scCs#|jj}|j|tdS(N(Rt image_namesRR (R R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_image_namess(t__name__t __module__R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR s tBitmapImageTestcBsVeZedZdZdZdZdZdZdZ dZ RS(cCs,tjj|tjddd|_dS(Ns python.xbmtsubdirt imghdrdata(Rt setUpClasst__func__tsupporttfindfilettestfile(tcls((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyRsc Cstjdd|jddddd|j}|jt|d|j|jd|j|jd |j|jd |j d|jj ~|j d|jj dS( Ns ::img::testtmastert foregroundtyellowt backgroundtbluetfileRi( ttkintert BitmapImageRRt assertEqualtstrttypetwidththeightR R t assertNotIn(R timage((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_files  c Cst|jd}|j}WdQXtjdd|jddddd|}|jt|d|j|jd |j|j d |j|j d |j d|jj ~|j d|jj dS( Ntrbs ::img::testRRRRRtdataRi(topenRtreadR R!RR"R#R$R%R&R R R'(R tfR+R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_data*s  cCs0|j|t|j|jj||dS(N(RR#R"Rt splitlist(R tactualtexpected((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytassertEqualStrList8scCstjdd|j}|j|ddt|jd}|j}WdQX|jd||j|ddddd|f|j|j d|j|j d|j|d d |jd ||j|d d ddd|fdS( Ns ::img::testRR+s-data {} {} {} {}R*s-datatitmaskdatas-maskdata {} {} {} {}s -maskdata( R R!RR"R,RR-t configureR3R%R&(R R(R.R+((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_data<s  cCstjdd|j}|j|dd|jd|j|j|ddddd|jf|j|jd|j|jd|j|dd |jd|j|j|dd ddd|jfdS( Ns ::img::testRRs-file {} {} {} {}s-fileR4itmaskfiles-maskfile {} {} {} {}s -maskfile( R R!RR"R6RR3R%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_fileLs  cCsTtjdd|j}|j|dd|jdd|j|dddS(Ns ::img::testRRs-background {} {} {} {}Rs-background {} {} {} blue(R R!RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_backgroundZscCsTtjdd|j}|j|dd|jdd|j|dddS(Ns ::img::testRRs!-foreground {} {} #000000 #000000Rs -foreground {} {} #000000 yellow(R R!RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_foreground`s   ( RRt classmethodRR)R/R3R7R9R:R;(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyRs     tPhotoImageTestcBseZedZdZdZdZdZdZdZ dZ dZ d Z d Z ed d d Zed d dZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cCs,tjj|tjddd|_dS(Ns python.gifRR(RRRRRR(R((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyRkscCstjdd|jd|jS(Ns ::img::testRR(R t PhotoImageRR(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytcreatepscGs-tjdkr|jr|Stj|SdS(Ng333333!@(R t TkVersiont wantobjectst_join(R targs((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt colorlisttscCstjd|dd}tjdd|jd|}|jt|d|j|jd|j|jd|j|j d|j|d d |j|d||j d|jj ~|j d|jj dS( Nspython.RRs ::img::testRRRiR+R4( RRR R>RR"R#R$R%R&R R R'(R textRR(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytcheck_create_from_filezs cCs,tjd|dd}t|d}|j}WdQXtjdd|jd|}|jt|d|j|j d|j|j d |j|j d |j|d|j r|n |j d |j|d d |jd|jj~|jd|jjdS( Nspython.RRR*s ::img::testRR+Ritlatin1RR4(RRR,R-R R>RR"R#R$R%R&RAtdecodeR R R'(R RERR.R+R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytcheck_create_from_datas cCs|jddS(Ntppm(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_ppm_filescCs|jddS(NRJ(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_ppm_datascCs|jddS(Ntpgm(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_pgm_filescCs|jddS(NRM(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_pgm_datascCs|jddS(Ntgif(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_gif_filescCs|jddS(NRP(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_gif_datasiicCs|jddS(Ntpng(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_png_filescCs|jddS(NRS(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_png_datascCstjdd|j}|j|ddt|jd}|j}WdQX|jd||j|d|jr|n |j d|j|j d|j|j ddS(Ns ::img::testRR+R4R*RGi( R R>RR"R,RR-R6RARHR%R&(R R(R.R+((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR7scCstjdd|j}|j|dd|jd|jdd|j|d|jradnd|j|jd|j|jddS( Ns ::img::testRtformatR4RRPi(RP( R R>RR"R6RRAR%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_formatscCstjdd|j}|j|dd|jd|j|j|d|j|j|jd|j|jddS(Ns ::img::testRRR4i(R R>RR"R6RR%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR9s cCsTtjdd|j}|j|dd|jdd|j|dddS(Ns ::img::testRtgammas1.0g@s2.0(R R>RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_gammascCstjdd|j}|j|dd|j|dd|jdd|jdd|j|dd|j|dd |j|jd|j|jddS( Ns ::img::testRR%t0R&ii t20t10(R R>RR"R6R%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_width_heightscCsxtjdd|j}|j|dd|jdd|j|dd|jdd|j|dddS(Ns ::img::testRtpaletteR4it256s3/4/2(R R>RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_palettes cCsq|j}|j|j|jd|j|jd|j|jdd|jddddS(Niiii(R?tblankR"R%R&tgetRD(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_blanks   cCsp|j}|j}|j|jd|j|jd|j|jdd|jdddS(Niii(R?tcopyR"R%R&Rb(R R(timage2((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_copys   cCs|j}|jdd}|j|jd|j|jd|j|jdd|jdd|jd}|j|jd|j|jd|j|jdd|jdddS(Niiiii(R?t subsampleR"R%R&Rb(R R(Re((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_subsamples (cCs)|j}|jdd}|j|jd|j|jd|j|jdd|jdd|j|jd d |jdd|jd}|j|jd|j|jd|j|jdd |jdd|j|jd d |jdddS( Niii i0iiiii ii i (R?tzoomR"R%R&Rb(R R(Re((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_zooms (((cCs|j}|jddd|j|jdd|jddd|j|jdd|jdtjdkr}d ndd|j|jdd |jddd|j|jdd |jddd|jddf|j|jdd|jddd|j|jdd|jddd|j|jdd|jddd|j|jdd|jddddS(Ns{red green} {blue yellow}ttoiiiiig333333!@iis#f00s#00ff00s #000000fffs #ffffffff0000i(ii(s#f00s#00ff00(s #000000fffs #ffffffff0000(R?tputR"RbRDR R@(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_puts + +++++cCs|j}|j|jdd|jddd|j|jdd|jddd|j|jdd|jddd|jtj|jdd|jtj|jdd|jtj|jd d|jtj|jdd dS( Niii>itiiiii(R?R"RbRDt assertRaisesR tTclError(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_get s +++c Cs|j}|jtjtj|jtjtjdd|jdddtj}|j t |d|j |j d|j |j d|j |j d|j |jdd|jdd|j |jd d |jd d |jtjdd d dtjdd|jdd dtj}|j t |d|j |j d|j |j d|j |j d|j |jdd|jd d|j |jdd|jdd dS(Ns ::img::test2RRVRJRRiiiiRPt from_coordsiii s ::img::test3iiii(iiii (R?t addCleanupRtunlinktTESTFNtwriteR R>RR"R#R$R%R&Rb(R R(Retimage3((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_write*s,  (( ((RRR<RR?RDRFRIRKRLRNRORQRRRRTRUR7RWR9RYR]R`RcRfRhRjRmRpRw(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR=is4                  t__main__(tunittesttTkinterR tttkttest.test_supportt test_supportRttest_ttk.supportRRtrequirestTestCaseRRR=t tests_guiRt run_unittest(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyts     R PK]VItest_tkinter/test_font.pyonu[ zfc@sddlZddlZddlZddlmZmZmZddl m Z eddZ de ej fdYZ e fZedkreendS( iN(trequirest run_unittestt gc_collect(tAbstractTkTesttguit TkDefaultFonttFontTestcBsheZedZdZdZdZdZdZdZ dZ dZ d Z RS( cCswtjj|y(tjd|jdtdt|_Wn8tj k rrtjd|jdtdt |_nXdS(Ntroottnametexists( Rt setUpClasst__func__tfonttFontRtfontnametTruettkintertTclErrortFalse(tcls((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyR s (cCsL|jj}|jt|ddddddhxI|D]A}|j|jj||||j|j|||q>WxUdD]M}|j||t|j|jj|t|j|j|tqW|jrt nt}xUdD]M}|j||||j|jj|||j|j||qWdS( Ntfamilytsizetweighttslantt underlinet overstrike(RRR(RRR( R t configuretassertGreaterEqualtsett assertEqualtcgettassertIsInstancetstrt wantobjectstint(tselftoptionstkeytsizetype((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyttest_configures    cCsd}y%tjd|jd|dt}Wn5tjk rbtjd|jd|dt}nX|j|jd|~t dS(NuMS ゴシックRRR ( R R RRRRRRRR(R#Rtf((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyttest_unicode_family&s%%cCs|jj}|jt|ddddddhx.|D]&}|j|jj|||q>Wx>dD]6}|j||t|j|jj|tqoW|jrtnt}x>dD]6}|j||||j|jj||qWdS( NRRRRRR(RRR(RRR( R tactualRRRRR R!R"(R#R$R%R&((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_actual0s $   cCs3|j|jjt|jt|jtdS(N(RR RRR (R#((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_name>scCstjd|jdtdt}tjd|jdtdt}|j|||j|||j||j|j|d|j |dgdS(NRRR i( R R RRRt assertIsNotRtassertNotEqualtcopyt assertNotIn(R#tfont1tfont2((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyttest_eqBs!!cCs |j|jjdtdS(Ntabc(RR tmeasureR"(R#((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_measureKscCs|jj}|jt|ddddhx^|D]V}|j|jj||||j||t|j|jj|tq8WdS(Ntascenttdescentt linespacetfixed(R tmetricsRRRRR"(R#R;R%((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_metricsNs  cCsgtj|j}|j|t|j|x1|D])}|j|ttf|j|q6WdS(N(R tfamiliesRRttuplet assertTrueR tunicode(R#R=R((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_familiesWs   cCswtj|j}|j|t|j|x1|D])}|j|ttf|j|q6W|jt |dS(N( R tnamesRRR>R?R R@tassertInR(R#RBR((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyt test_names_s  ( t__name__t __module__t classmethodR R'R)R+R,R3R6R<RARD(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyR s     t__main__(tunittesttTkinterRttkFontR ttest.test_supportRRRttest_ttk.supportRRtTestCaseRt tests_guiRE(((s:/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_font.pyts    ]  PK]ltest_tkinter/test_widgets.pyonu[ zfc@sTddlZddlZddlmZddlZddlZddlmZmZddl m Z m Z m Z m Z ddlmZmZmZmZmZmZmZmZmZmZeddeefdYZeed eejfd YZeed eejfd YZeed eejfdYZdeefdYZeedeejfdYZeedeejfdYZ eedeejfdYZ!eedeejfdYZ"eedeejfdYZ#de#ejfdYZ$eeedeejfdYZ%eede%ejfd YZ&eed!eejfd"YZ'eeed#eejfd$YZ(eeed%eejfd&YZ)eeed'eejfd(YZ*eeed)eejfd*YZ+eed+eejfd,YZ,eed-eejfd.YZ-eeed/eejfd0YZ.e e(e!e%eeee)e#e-e.e$e,e"e*e+e&e'egZ/e0d1krPee/ndS(2iN(tTclError(trequirest run_unittest(t tcl_versiont requires_tcltget_tk_patchlevelt widget_eq( tadd_standard_optionstnoconvt noconv_metht int_roundt pixels_roundtAbstractWidgetTesttStandardOptionsTeststIntegerSizeTeststPixelSizeTestst setUpModuletguitAbstractToplevelTestcBs2eZeZdZdZdZdZRS(cCso|j}|j|d|jjj|j|dddd|jdd}|j|dddS(NtclasstFooterrmsgs2can't modify -class option after widget is createdtclass_(tcreatet assertEqualt __class__t__name__ttitletcheckInvalidParam(tselftwidgettwidget2((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_classs  cCsc|j}|j|dd|j|dddd|jdd}|j|dddS(NtcolormapttnewRs5can't modify -colormap option after widget is created(RRR(RRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_colormaps  cCs|j}|j|d|jr(dnd|j|dddd|jdt}|j|d|jrvdnddS(Nt containerit0iRs6can't modify -container option after widget is createdt1(RRt wantobjectsRtTrue(RRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_container's  #cCsc|j}|j|dd|j|dddd|jdd}|j|dddS(NtvisualR"tdefaultRs3can't modify -visual option after widget is created(RRR(RRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_visual/s  (Rt __module__R t_conv_pad_pixelsR R$R*R-(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs   t ToplevelTestcBs2eZdZdZdZdZdZRS(t backgroundt borderwidthRR!R%tcursortheightthighlightbackgroundthighlightcolorthighlightthicknesstmenutpadxtpadytrelieftscreent takefocustuseR+twidthcKstj|j|S(N(ttkintertTopleveltroot(Rtkwargs((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRBscCsN|j}tj|j}|j|d|dt|j|dddS(NR8teqR"(RR@tMenuRBt checkParamR(RRR8((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_menuEs cCs|j}|j|ddytjd}Wntk rQ|jdnX|j|d|dd|jd|}|j|d|dS(NR<R"tDISPLAYsNo $DISPLAY set.Rs3can't modify -screen option after widget is created(RRtostenvirontKeyErrortskipTestR(RRtdisplayR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_screenKs  cCsl|j}|j|dd|jdt}d|j}|jd|}|j|d|dS(NR>R"R%s%#x(RRR)twinfo_id(RRtparenttwidR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_useWs  (R1R2RR!R%R3R4R5R6R7R8R9R:R;R<R=R>R+R?(RR.tOPTIONSRRGRNRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyR08s   t FrameTestcBseZdZdZRS(R1R2RR!R%R3R4R5R6R7R9R:R;R=R+R?cKstj|j|S(N(R@tFrameRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRjs(R1R2RR!R%R3R4R5R6R7R9R:R;R=R+R?(RR.RSR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRTas tLabelFrameTestcBs)eZdZdZdZdZRS(R1R2RR!R%R3tfontt foregroundR4R5R6R7t labelanchort labelwidgetR9R:R;R=ttextR+R?cKstj|j|S(N(R@t LabelFrameRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRyscCsW|j}|j|ddddddddd d d d d |j|dddS(NRYtetentestntnetnwtstsetswtwtwntwstcenter(RtcheckEnumParamR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_labelanchor|s   cCsQ|j}tj|jdddd}|j|d|dd|jdS(NR[tMupptnametfooRZtexpecteds.foo(RR@tLabelRBRFtdestroy(RRtlabel((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_labelwidgets (R1R2RR!R%R3RWRXR4R5R6R7RYRZR9R:R;R=R[R+R?(RR.RSRRkRs(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRVns  tAbstractLabelTestcBseZeZdZRS(c Cs2|j}|j|ddddddddS(NR7ig?g@iit10p(RtcheckPixelsParam(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_highlightthicknesss  (RR.R t _conv_pixelsRw(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRtst LabelTestcBseZdZdZRS(tactivebackgroundtactiveforegroundtanchorR1tbitmapR2tcompoundR3tdisabledforegroundRWRXR4R5R6R7timagetjustifyR9R:R;tstateR=R[t textvariablet underlineR?t wraplengthcKstj|j|S(N(R@RpRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs(RzR{R|R1R}R2R~R3RRWRXR4R5R6R7RRR9R:R;RR=R[RRR?R(RR.RSR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRyst ButtonTestc Bs eZd"Zd Zd!ZRS(#RzR{R|R1R}R2tcommandR~R3R,RRWRXR4R5R6R7RRt overreliefR9R:R;t repeatdelaytrepeatintervalRR=R[RRR?RcKstj|j|S(N(R@tButtonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs)|j}|j|dddddS(NR,tactivetdisabledtnormal(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_defaults ( RzR{R|R1R}R2RR~R3R,RRWRXR4R5R6R7RRRR9R:R;RRRR=R[RRR?R(RR.RSRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs tCheckbuttonTestc&Bs)eZd)Zd&Zd'Zd(ZRS(*RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7Rt indicatoronRt offrelieftoffvaluetonvalueRR9R:R;t selectcolort selectimageRR=R[Rt tristateimaget tristatevalueRtvariableR?RcKstj|j|S(N(R@t CheckbuttonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs,|j}|j|ddddddS(NRigffffff@R"s any string(Rt checkParams(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_offvalues cCs,|j}|j|ddddddS(NRigffffff@R"s any string(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_onvalues (&RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7RRRRRRRR9R:R;RRRR=R[RRRRRR?R(RR.RSRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs  tRadiobuttonTestc%Bs eZd'Zd%Zd&ZRS((RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7RRRRRR9R:R;RRRR=R[RRRRtvalueRR?RcKstj|j|S(N(R@t RadiobuttonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs,|j}|j|ddddddS(NRigffffff@R"s any string(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_values (%RzR{R|R1R}R2RR~R3RRWRXR4R5R6R7RRRRRR9R:R;RRRR=R[RRRRRRR?R(RR.RSRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs tMenubuttonTestcBseZd(ZeeZdZdZd Ze j j Z e j ejd!kd"d#Zd$Zd%Zd&Zd'ZRS()RzR{R|R1R}R2R~R3t directionRRWRXR4R5R6R7RRRR8R9R:R;RR=R[RRR?RcKstj|j|S(N(R@t MenubuttonRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs/|j}|j|dddddddS(NRtabovetbelowtflushtlefttright(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_directions  cCs/|j}|j|dddddtdS(NR4idiitconv(RtcheckIntegerParamtstr(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_heights tdarwins"crashes with Cocoa Tk (issue19733)c Cs|j}tjd|jdd}|j|d|dtd}|jtj}d|dZd?ZRS(BtautoseparatorsR1t blockcursorR2R3tendlineRRWRXR4R5R6R7tinactiveselectbackgroundRRRRtinsertunfocussedRtmaxundoR9R:R;RRRtsetgridtspacing1tspacing2tspacing3t startlineRttabsttabstyleR=tundoR?RRtyscrollcommandiicKstj|j|S(N(R@tTextRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_autoseparatorss cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_blockcursors cCs|j}djdtdD}|jd||j|dddd|j|dd dd|j|dd d d |j|dd |j|dd|j|ddd ddS(Ns css|] }dVqdS(sLine %dN((t.0ti((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys sidtendRiRoR"iRRsexpected integer but got "spam"i2R#ii s1-startline must be less than or equal to -endline(RtjointrangetinsertRFR(RRR[((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_endlines cCs^|j}|j|ddddd|j|dddd|j|dd dddS( NR4idgLY@gfffffY@t3ciRoii(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs cCs)|j}|j|dddddS(NRiii(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_maxundos cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_inactiveselectbackgrounds icCs)|j}|j|dddddS(NRthollowRtsolid(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_insertunfocusseds  c Cs>|j}|j|ddddddtdtd kdS( NRg?g@iRuRt keep_origii(ii(RRvRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_selectborderwidth$s  cCsE|j}|j|ddddd|j|dddddS( NR igffffff5@g6@s0.5ciRoi(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_spacing1*s cCsE|j}|j|ddddd|j|dddddS( NR!ig@gffffff@s0.1ciRoi(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_spacing2/s cCsE|j}|j|ddddd|j|dddddS( NR"igffffff5@g6@s0.5ciRoi(RRvRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_spacing34s cCs|j}djdtdD}|jd||j|dddd|j|dd dd|j|dd d d |j|dd |j|dd|j|ddd ddS(Ns css|] }dVqdS(sLine %dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys <sidR-R#iRoR"iRRsexpected integer but got "spam"i Ri2iFs1-startline must be less than or equal to -endline(RR.R/R0RFR(RRR[((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_startline9s cCsK|j}tdkr1|j|dddn|j|ddddS(NiiRRR(ii(RRRRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRGs  c Cs|j}tdkr7|j|ddd dn|j|dd|j|dd d d|j|dd d d|j|dddddtdkdS(Niii R$gffffff$@g333334@t1it2iRos10.2s20.7s10.2 20.7 1i 2is2c left 4c 6c centert2cRt4ct6cRiRRsbad screen distance "spam"R8(iii (gffffff$@g333334@R>R?(s10.2s20.7R>R?(gffffff$@g333334@R>R?(s10.2s20.7R>R?(R@RRARBRi(ii(RRRFRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_tabsNs  cCs&|j}|j|ddddS(NR%ttabulart wordprocessor(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_tabstyle]s cCs |j}|j|ddS(NR&(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_undobs cCsU|j}|j|dd|j|dddd|j|dddddS(NR?iinRoii(RRRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRfs cCsQ|j}tdkr4|j|ddddn|j|dddddS(NiiRtcharRtword(ii(RRRRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRls  cCs|j}|j|jd|j|jd|jtj|jd|jtj|jd|jtj|j|jtj|jdddS(Ns1.1R-R(RRRt assertIsNoneRR@RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRss ()RR1RR2R3RRRWRXR4R5R6R7RRRRRRRRR9R:R;RRRRR R!R"R#RR$R%R=R&R?RRR'(ii(RR.RSRR)t _stringifyRR)RR*R1RR3R4R7R9R:R;R<R=RRCRFRGRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRsB               t CanvasTestcBsheZd#ZeeZeZdZdZ dZ dZ dZ d Z d!Zd"ZRS($R1R2t closeenoughtconfineR3R4R5R6R7RRRRRtoffsetR;t scrollregionRRRRR=RtxscrollincrementR'tyscrollincrementR?cKstj|j|S(N(R@tCanvasRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRsc Cs2|j}|j|ddddddtdS(NRMig333333@g @iR(RRtfloat(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_closeenoughs cCs |j}|j|ddS(NRN(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_confines c Cs|j}|j|dd|j|dddddddd d d |j|dd |j|dd |j|dddS(NROs0,0R`RaR]RdRcReRfRbRis10,20s#5,6R(RRRRFR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_offsets  cCs|j}|j|dd|j|dd dd|j|dd|j|ddd d |j|dd |j|dd |j|dddS(NRPs 0 0 200 150iiiRoR"RRsbad scrollRegion "spam"(iiii(iiiR(iii(iiiii(RRFR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_scrollregions cCs,|j}|j|ddddddS(NRRRRs0bad state value "{}": must be normal or disabled(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs c Cs2|j}|j|ddddddddS(NRQi(igD@gE@is0.5i(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_xscrollincrements  c Cs2|j}|j|ddddddddS(NRRi igffffff&@g333333+@is0.1i(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_yscrollincrements  (R1R2RMRNR3R4R5R6R7RRRRRROR;RPRRRRR=RRQR'RRR?(RR.RSRR RxR)RKRRURVRWRXRRYRZ(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRL}s(      t ListboxTestcBseZd,ZdZdZedddejjZdZ dZ d Z d!Z d"Z d#Zd$Zd%Zd&Zd'Zd(Zd)Zd*Zd+ZRS(-t activestyleR1R2R3RRRWRXR4R5R6R7Rt listvariableR;RRRt selectmodeRRR=R?RR'cKstj|j|S(N(R@tListboxRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs)|j}|j|dddddS(NR\tdotboxRR(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_activestyles  iiicCs5|j}tj|j}|j|d|dS(NR](RR@t DoubleVarRBtcheckVariableParam(RRtvar((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_listvariables cCs\|j}|j|dd|j|dd|j|dd|j|dddS(NR^tsingletbrowsetmultipletextended(RRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_selectmodes  cCs&|j}|j|ddddS(NRRR(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs c Cs|j}|jtd|jdWdQXdj}|jd|x-t|D]\}}|j|d|q[W|jt|jWdQX|jtd|jdWdQX|j |jddd|j |jddd|j |jd dd|jd}|j |t x|j D]s\}}|j t|dt|d krD|j ||jd||j |d|jd|qDqDWdS(Nsitem number "0" out of rangeis)red orange yellow green blue white violetR-R1sbad listbox index "red"tredt BackgroundR"tviolets@0,0iii(R1R1RlR"Rk(R1R1RlR"Rm(R1R1RlR"Rk(ii(RtassertRaisesRegexpRt itemconfiguretsplitR0t enumerateRRRtassertIsInstancetdicttitemstassertIntlentitemcget(RRtcolorsR,tcolortdtktv((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigures0  c Cs|j}|jddddd|jdi||6|j|jd|d||j|jd|||jtd|jdid |6WdQXdS( NR-RRRRziisunknown color name "spam"R(RR0RoRRwRnR(RRmRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcheck_itemconfigures  cCs|jdddS(NR1s#ff0000(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_background scCs|jdddS(Ntbgs#ff0000(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_bgscCs|jdddS(Ntfgs#110022(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_fgscCs|jdddS(NRXs#110022(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_itemconfigure_foregroundscCs|jdddS(NRs#110022(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt#test_itemconfigure_selectbackgroundscCs|jdddS(NRs#654321(R~(R((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt#test_itemconfigure_selectforegroundscCs|j}|jddtdD|j|j|jd|j|jd|j|jd|jt|jd|jt|jd|jt |j|jt |jdddS(Nicss|]}d|VqdS(sel%dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys siii Ri( RR0R/tpackRRRJRRRR(Rtlb((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_boxs   cCs|j}|jddtdD|jdtj|jdd|jd|j|jd|j t |jddS( Nicss|]}d|VqdS(sel%dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys +siiiii(iiii( RR0R/tselection_clearR@tENDt selection_setRt curselectionRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_curselection)s   cCs|j}|jddtdD|j|jdd|j|jdd|j|jdd|j|jdd |j|jd d |j|jdd d|j|jd dd|j|jd dd|j|jddd|jt|jd|jt|jd|jt|j|jt|jdd|jt|jddd|jt|jddS(Nicss|]}d|VqdS(sel%dN((R+R,((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pys 4sitel0itel3R-tel7R"iitel4tel5tel6Riig333333@(RRR(RRR((R( RR0R/RtgetRRRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_get2s"  (R\R1R2R3RRRWRXR4R5R6R7RR]R;RRRR^RRR=R?RR'(RR.RSRRaRR t test_justifyRReRjRR}R~RRRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyR[s2             t ScaleTestcBseZd+ZdZdZd Zd!Zd"Zd#Zd$Z d%Z d&Z d'Z d(Z d)Zd*ZRS(,RzR1t bigincrementR2RR3tdigitsRWRXRR5R6R7RrtlengthtorientR;RRt resolutiont showvaluet sliderlengtht sliderreliefRR=t tickintervalRt troughcolorRR?tverticalcKstj|j|S(N(R@tScaleRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRSscCs)|j}|j|dddddS(NRg(@g7@i(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_bigincrementVs cCs&|j}|j|ddddS(NRii(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_digitsZs cCs/|j}|j|dddddtdS(NRidg-@g333333.@R(RRtround(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyR^s cCs6|j}|j|dd|j|dddS(NRrs any stringR"(RRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_labelbs cCs,|j}|j|ddddddS(NRigffffff`@g33333`@t5i(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_lengthgs cCs,|j}|j|ddddddS(NRg@ig@i(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_resolutionks cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_showvalueos cCs/|j}|j|dddddddS(NRi gffffff&@g333333/@it3m(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sliderlengthss  cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sliderreliefxs c CsQ|j}|j|ddddddt|j|dddd dtdS( NRig333333@gffffff@iRiRoi(RRRRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_tickinterval|s  c Cs2|j}|j|ddddddtdS(NRi,g-@g333333.@iR(RRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs (RzR1RR2RR3RRWRXRR5R6R7RrRRR;RRRRRRRR=RRRRR?(RR.RStdefault_orientRRRRRRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRFs(           t ScrollbarTestcBs\eZdZeeZeZdZdZ dZ dZ dZ dZ dZRS(Rzt activereliefR1R2RR3telementborderwidthR5R6R7tjumpRR;RRR=RR?RcKstj|j|S(N(R@t ScrollbarRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_activereliefs cCs,|j}|j|ddddddS(NRg333333@gffffff@it1m(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_elementborderwidths cCs,|j}|j|ddddddS(NRRt horizontalRs4bad orientation "{}": must be vertical or horizontal(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_orients cCsg|j}xdD]}|j|qW|jd|jt|j|jt|jdddS(Ntarrow1tslidertarrow2R"(RRR(RtactivateRR(RtsbR]((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_activates    cCs|j}|jdd|j|jd|jt|jdd|jt|jdd|jt|jdd|jt|jd|jt|jddddS( Ng?g?tabctdefg333333?gffffff?g?(g?g?(RtsetRRRRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sets (RzRR1R2RR3RR5R6R7RRR;RRR=RR?(RR.RSRR RxR)RKRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs       tPanedWindowTestcBsgeZd2ZdZdZdZdZdZdZe ddddZ e ddddZ e ddddZ dZ dZd Zd!Zd"Zd#Zd$Zd%Zed&Zd'Zd(Zd)Zd*Ze ddd+Zd,Zd-Zd.Zd/Ze ddd0Z d1Z!RS(3R1R2R3t handlepadt handlesizeR4t opaqueresizeRtproxybackgroundtproxyborderwidtht proxyreliefR;t sashcursortsashpadt sashrelieft sashwidtht showhandleR?RcKstj|j|S(N(R@t PanedWindowRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs/|j}|j|dddddddS(NRig@gffffff@iR(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_handlepads c Cs5|j}|j|dddddddtdS(NRig"@g333333%@it2mR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_handlesizes c Cs8|j}|j|ddddddddtdS( NR4idgLY@gfffffY@iiR>R(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs !cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_opaqueresizes iiicCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_proxybackgrounds c Cs8|j}|j|ddddddddtdS( NRig?g333333@iiRuR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_proxyborderwidths  cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_proxyreliefs cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sashcursors cCs/|j}|j|dddddddS(NRig?g@iR(RRv(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_sashpads cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sashreliefs c Cs5|j}|j|dddddddtdS(NRi g333333&@g333333/@iRR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_sashwidths cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_showhandles c Cs8|j}|j|ddddddddtdS( NR?igfffff6y@gIy@iniRR(RRvR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs !cCsQ|j}tj|}tj|}|j||j||||fS(N(RR@Rtadd(RtpRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcreate2s    cCs|j\}}}|jt|j|j|}|j|txl|jD]^\}}|jt|d|j||j|||j|d|j ||qTWdS(Nii( RRRt paneconfigureRrRsRtRRvtpanecget(RRRRRzR{R|((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigurescCsd}|j s|r(t|}n|jr@|r@t}n|j|i||6|j||j||d||j||j|||dS(NcSs|S(N((tx((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytR"i(R(RRRR(RRRRmRRot stringifyR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcheck_paneconfigures  &c Cs4|jt||j|id|6WdQXdS(NtbadValue(RnRR(RRRRmtmsg((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytcheck_paneconfigure_bad$scCsN|j\}}}|j||d|t||j||dddS(Ntaftersbad window path name "badValue"(RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_after(scCsN|j\}}}|j||d|t||j||dddS(Ntbeforesbad window path name "badValue"(RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_before.sc CsW|j\}}}|j||ddddtdk|j||dddS( NR4i Riii sbad screen distance "badValue"(iii (RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_height4s cCsH|j\}}}|j||dtd|j||dddS(Nthideis)expected boolean value but got "badValue"(RRtFalseR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_hide;scCsH|j\}}}|j||ddd|j||dddS(Ntminsizei sbad screen distance "badValue"(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_minsizeBscCsH|j\}}}|j||ddd|j||dddS(NR9g?isbad screen distance "badValue"(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_padxHscCsH|j\}}}|j||ddd|j||dddS(NR:g?isbad screen distance "badValue"(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_padyNscCsH|j\}}}|j||ddd|j||dddS(Ntstickytnsewtnesws[bad stickyness value "badValue": must be a string containing zero or more of n, e, s, and w(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_stickyTscCsH|j\}}}|j||ddd|j||dddS(NtstretchtalwtalwayssEbad stretch "badValue": must be always, first, last, middle, or never(RRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_stretch\sc CsW|j\}}}|j||ddddtdk|j||dddS( NR?i Riii sbad screen distance "badValue"(iii (RRRR(RRRR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_paneconfigure_widthds (R1R2R3RRR4RRRRRR;RRRRRR?("RR.RSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRsH                    tMenuTestcBseeZdZeZdZdZdZdZdZ dZ dZ dZ dZ RS(RztactiveborderwidthR{R1R2R3RRWRXt postcommandR;RR=ttearoffttearoffcommandRttypecKstj|j|S(N(R@RERB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRwscCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_postcommandzs cCs |j}|j|ddS(NR(RR (RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_tearoff~s cCs |j}|j|ddS(NR(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_tearoffcommands cCs#|j}|j|dddS(NRs any string(RRF(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_titles cCs)|j}|j|dddddS(NRRRtmenubar(RRj(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_types  cCs |j}|jdd|jt|j|jtd|jdWdQX|jd}|j|tx|j D]v\}}|j|t |j|t |j t |d|j |d||j |jd||dqW|jdS( NRrttestsbad menu entry index "foo"Rniiii(Rt add_commandRRtentryconfigureRnRRrRsRtRttupleRRvt entrycgetRq(Rtm1RzR{R|((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_entryconfigures $cCsk|j}|jdd|j|jddd|jddd|j|jddddS(NRrR itchanged(RRRRR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_entryconfigure_labels  c Cs|j}tj|j}tj|j}|jd|dtdtdd|jt|j ddt||j dd||jt|j ddt|dS(NRRRRrtNonsensei( RR@t BooleanVarRBtadd_checkbuttonR)RRRRR(RRtv1tv2((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyttest_entryconfigure_variables ((RzRR{R1R2R3RRWRXRR;RR=RRRR(RR.RSR RxRRRR R R RRR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRls        t MessageTestcBs&eZdZeZdZdZRS(R|taspectR1R2R3RWRXR5R6R7RR9R:R;R=R[RR?cKstj|j|S(N(R@tMessageRB(RRC((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRscCs)|j}|j|dddddS(NRiii(RR(RR((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyt test_aspects (R|RR1R2R3RWRXR5R6R7RR9R:R;R=R[RR?(RR.RSR R/RR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pyRs t__main__(1RtTkinterR@RRIRttest.test_supportRRttest_ttk.supportRRRRt widget_testsRRR R R R R RRRRtTestCaseR0RTRVRtRyRRRRRRRRRLR[RRRRRt tests_guiR(((s=/usr/lib64/python2.7/lib-tk/test/test_tkinter/test_widgets.pytsl    "F % (       AE h BB1  D     PK]rtest_tkinter/test_misc.pynu[import unittest import Tkinter as tkinter from test.test_support import requires, run_unittest from test_ttk.support import AbstractTkTest requires('gui') class MiscTest(AbstractTkTest, unittest.TestCase): def test_after(self): root = self.root cbcount = {'count': 0} def callback(start=0, step=1): cbcount['count'] = start + step # Without function, sleeps for ms. self.assertIsNone(root.after(1)) # Set up with callback with no args. cbcount['count'] = 0 timer1 = root.after(0, callback) self.assertIn(timer1, root.tk.call('after', 'info')) (script, _) = root.tk.splitlist(root.tk.call('after', 'info', timer1)) root.update() # Process all pending events. self.assertEqual(cbcount['count'], 1) with self.assertRaises(tkinter.TclError): root.tk.call(script) # Set up with callback with args. cbcount['count'] = 0 timer1 = root.after(0, callback, 42, 11) root.update() # Process all pending events. self.assertEqual(cbcount['count'], 53) # Cancel before called. timer1 = root.after(1000, callback) self.assertIn(timer1, root.tk.call('after', 'info')) (script, _) = root.tk.splitlist(root.tk.call('after', 'info', timer1)) root.after_cancel(timer1) # Cancel this event. self.assertEqual(cbcount['count'], 53) with self.assertRaises(tkinter.TclError): root.tk.call(script) def test_after_idle(self): root = self.root cbcount = {'count': 0} def callback(start=0, step=1): cbcount['count'] = start + step # Set up with callback with no args. cbcount['count'] = 0 idle1 = root.after_idle(callback) self.assertIn(idle1, root.tk.call('after', 'info')) (script, _) = root.tk.splitlist(root.tk.call('after', 'info', idle1)) root.update_idletasks() # Process all pending events. self.assertEqual(cbcount['count'], 1) with self.assertRaises(tkinter.TclError): root.tk.call(script) # Set up with callback with args. cbcount['count'] = 0 idle1 = root.after_idle(callback, 42, 11) root.update_idletasks() # Process all pending events. self.assertEqual(cbcount['count'], 53) # Cancel before called. idle1 = root.after_idle(callback) self.assertIn(idle1, root.tk.call('after', 'info')) (script, _) = root.tk.splitlist(root.tk.call('after', 'info', idle1)) root.after_cancel(idle1) # Cancel this event. self.assertEqual(cbcount['count'], 53) with self.assertRaises(tkinter.TclError): root.tk.call(script) def test_after_cancel(self): root = self.root cbcount = {'count': 0} def callback(): cbcount['count'] += 1 timer1 = root.after(5000, callback) idle1 = root.after_idle(callback) # No value for id raises a ValueError. with self.assertRaises(ValueError): root.after_cancel(None) # Cancel timer event. cbcount['count'] = 0 (script, _) = root.tk.splitlist(root.tk.call('after', 'info', timer1)) root.tk.call(script) self.assertEqual(cbcount['count'], 1) root.after_cancel(timer1) with self.assertRaises(tkinter.TclError): root.tk.call(script) self.assertEqual(cbcount['count'], 1) with self.assertRaises(tkinter.TclError): root.tk.call('after', 'info', timer1) # Cancel same event - nothing happens. root.after_cancel(timer1) # Cancel idle event. cbcount['count'] = 0 (script, _) = root.tk.splitlist(root.tk.call('after', 'info', idle1)) root.tk.call(script) self.assertEqual(cbcount['count'], 1) root.after_cancel(idle1) with self.assertRaises(tkinter.TclError): root.tk.call(script) self.assertEqual(cbcount['count'], 1) with self.assertRaises(tkinter.TclError): root.tk.call('after', 'info', idle1) tests_gui = (MiscTest, ) if __name__ == "__main__": run_unittest(*tests_gui) PK]3,O'>'>test_tkinter/test_images.pyonu[ zfc@sddlZddlZddlZddljZddlmZm Z ej ddeej fdYZ deej fdYZ deej fd YZe e efZed krejendS( iN(tAbstractTkTestt requires_tcltguitMiscTestcBseZdZdZRS(cCsC|jj}|j|t|jd||jd|dS(Ntphototbitmap(troott image_typestassertIsInstancettupletassertIn(tselfR((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_image_types scCs#|jj}|j|tdS(N(Rt image_namesRR (R R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_image_namess(t__name__t __module__R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR s tBitmapImageTestcBsVeZedZdZdZdZdZdZdZ dZ RS(cCs,tjj|tjddd|_dS(Ns python.xbmtsubdirt imghdrdata(Rt setUpClasst__func__tsupporttfindfilettestfile(tcls((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyRsc Cstjdd|jddddd|j}|jt|d|j|jd|j|jd |j|jd |j d|jj ~|j d|jj dS( Ns ::img::testtmastert foregroundtyellowt backgroundtbluetfileRi( ttkintert BitmapImageRRt assertEqualtstrttypetwidththeightR R t assertNotIn(R timage((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_files  c Cst|jd}|j}WdQXtjdd|jddddd|}|jt|d|j|jd |j|j d |j|j d |j d|jj ~|j d|jj dS( Ntrbs ::img::testRRRRRtdataRi(topenRtreadR R!RR"R#R$R%R&R R R'(R tfR+R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_data*s  cCs0|j|t|j|jj||dS(N(RR#R"Rt splitlist(R tactualtexpected((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytassertEqualStrList8scCstjdd|j}|j|ddt|jd}|j}WdQX|jd||j|ddddd|f|j|j d|j|j d|j|d d |jd ||j|d d ddd|fdS( Ns ::img::testRR+s-data {} {} {} {}R*s-datatitmaskdatas-maskdata {} {} {} {}s -maskdata( R R!RR"R,RR-t configureR3R%R&(R R(R.R+((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_data<s  cCstjdd|j}|j|dd|jd|j|j|ddddd|jf|j|jd|j|jd|j|dd |jd|j|j|dd ddd|jfdS( Ns ::img::testRRs-file {} {} {} {}s-fileR4itmaskfiles-maskfile {} {} {} {}s -maskfile( R R!RR"R6RR3R%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_fileLs  cCsTtjdd|j}|j|dd|jdd|j|dddS(Ns ::img::testRRs-background {} {} {} {}Rs-background {} {} {} blue(R R!RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_backgroundZscCsTtjdd|j}|j|dd|jdd|j|dddS(Ns ::img::testRRs!-foreground {} {} #000000 #000000Rs -foreground {} {} #000000 yellow(R R!RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_foreground`s   ( RRt classmethodRR)R/R3R7R9R:R;(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyRs     tPhotoImageTestcBseZedZdZdZdZdZdZdZ dZ dZ d Z d Z ed d d Zed d dZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(cCs,tjj|tjddd|_dS(Ns python.gifRR(RRRRRR(R((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyRkscCstjdd|jd|jS(Ns ::img::testRR(R t PhotoImageRR(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytcreatepscGs-tjdkr|jr|Stj|SdS(Ng333333!@(R t TkVersiont wantobjectst_join(R targs((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt colorlisttscCstjd|dd}tjdd|jd|}|jt|d|j|jd|j|jd|j|j d|j|d d |j|d||j d|jj ~|j d|jj dS( Nspython.RRs ::img::testRRRiR+R4( RRR R>RR"R#R$R%R&R R R'(R textRR(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytcheck_create_from_filezs cCs,tjd|dd}t|d}|j}WdQXtjdd|jd|}|jt|d|j|j d|j|j d |j|j d |j|d|j r|n |j d |j|d d |jd|jj~|jd|jjdS( Nspython.RRR*s ::img::testRR+Ritlatin1RR4(RRR,R-R R>RR"R#R$R%R&RAtdecodeR R R'(R RERR.R+R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pytcheck_create_from_datas cCs|jddS(Ntppm(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_ppm_filescCs|jddS(NRJ(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_ppm_datascCs|jddS(Ntpgm(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_pgm_filescCs|jddS(NRM(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_pgm_datascCs|jddS(Ntgif(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_gif_filescCs|jddS(NRP(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_gif_datasiicCs|jddS(Ntpng(RF(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_png_filescCs|jddS(NRS(RI(R ((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_create_from_png_datascCstjdd|j}|j|ddt|jd}|j}WdQX|jd||j|d|jr|n |j d|j|j d|j|j ddS(Ns ::img::testRR+R4R*RGi( R R>RR"R,RR-R6RARHR%R&(R R(R.R+((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR7scCstjdd|j}|j|dd|jd|jdd|j|d|jradnd|j|jd|j|jddS( Ns ::img::testRtformatR4RRPi(RP( R R>RR"R6RRAR%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_formatscCstjdd|j}|j|dd|jd|j|j|d|j|j|jd|j|jddS(Ns ::img::testRRR4i(R R>RR"R6RR%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR9s cCsTtjdd|j}|j|dd|jdd|j|dddS(Ns ::img::testRtgammas1.0g@s2.0(R R>RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_gammascCstjdd|j}|j|dd|j|dd|jdd|jdd|j|dd|j|dd |j|jd|j|jddS( Ns ::img::testRR%t0R&ii t20t10(R R>RR"R6R%R&(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_width_heightscCsxtjdd|j}|j|dd|jdd|j|dd|jdd|j|dddS(Ns ::img::testRtpaletteR4it256s3/4/2(R R>RR"R6(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_configure_palettes cCsq|j}|j|j|jd|j|jd|j|jdd|jddddS(Niiii(R?tblankR"R%R&tgetRD(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_blanks   cCsp|j}|j}|j|jd|j|jd|j|jdd|jdddS(Niii(R?tcopyR"R%R&Rb(R R(timage2((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_copys   cCs|j}|jdd}|j|jd|j|jd|j|jdd|jdd|jd}|j|jd|j|jd|j|jdd|jdddS(Niiiii(R?t subsampleR"R%R&Rb(R R(Re((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_subsamples (cCs)|j}|jdd}|j|jd|j|jd|j|jdd|jdd|j|jd d |jdd|jd}|j|jd|j|jd|j|jdd |jdd|j|jd d |jdddS( Niii i0iiiii ii i (R?tzoomR"R%R&Rb(R R(Re((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_zooms (((cCs|j}|jddd|j|jdd|jddd|j|jdd|jdtjdkr}d ndd|j|jdd |jddd|j|jdd |jddd|jddf|j|jdd|jddd|j|jdd|jddd|j|jdd|jddd|j|jdd|jddddS(Ns{red green} {blue yellow}ttoiiiiig333333!@iis#f00s#00ff00s #000000fffs #ffffffff0000i(ii(s#f00s#00ff00(s #000000fffs #ffffffff0000(R?tputR"RbRDR R@(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_puts + +++++cCs|j}|j|jdd|jddd|j|jdd|jddd|j|jdd|jddd|jtj|jdd|jtj|jdd|jtj|jd d|jtj|jdd dS( Niii>itiiiii(R?R"RbRDt assertRaisesR tTclError(R R(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyttest_get s +++c Cs|j}|jtjtj|jtjtjdd|jdddtj}|j t |d|j |j d|j |j d|j |j d|j |jdd|jdd|j |jd d |jd d |jtjdd d dtjdd|jdd dtj}|j t |d|j |j d|j |j d|j |j d|j |jdd|jd d|j |jdd|jdd dS(Ns ::img::test2RRVRJRRiiiiRPt from_coordsiii s ::img::test3iiii(iiii (R?t addCleanupRtunlinktTESTFNtwriteR R>RR"R#R$R%R&Rb(R R(Retimage3((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyt test_write*s,  (( ((RRR<RR?RDRFRIRKRLRNRORQRRRRTRUR7RWR9RYR]R`RcRfRhRjRmRpRw(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyR=is4                  t__main__(tunittesttTkinterR tttkttest.test_supportt test_supportRttest_ttk.supportRRtrequirestTestCaseRRR=t tests_guiRt run_unittest(((s</usr/lib64/python2.7/lib-tk/test/test_tkinter/test_images.pyts     R PK] test_tkinter/test_widgets.pynu[import unittest import Tkinter as tkinter from Tkinter import TclError import os import sys from test.test_support import requires, run_unittest from test_ttk.support import (tcl_version, requires_tcl, get_tk_patchlevel, widget_eq) from widget_tests import ( add_standard_options, noconv, noconv_meth, int_round, pixels_round, AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests, setUpModule) requires('gui') class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests): _conv_pad_pixels = noconv_meth def test_class(self): widget = self.create() self.assertEqual(widget['class'], widget.__class__.__name__.title()) self.checkInvalidParam(widget, 'class', 'Foo', errmsg="can't modify -class option after widget is created") widget2 = self.create(class_='Foo') self.assertEqual(widget2['class'], 'Foo') def test_colormap(self): widget = self.create() self.assertEqual(widget['colormap'], '') self.checkInvalidParam(widget, 'colormap', 'new', errmsg="can't modify -colormap option after widget is created") widget2 = self.create(colormap='new') self.assertEqual(widget2['colormap'], 'new') def test_container(self): widget = self.create() self.assertEqual(widget['container'], 0 if self.wantobjects else '0') self.checkInvalidParam(widget, 'container', 1, errmsg="can't modify -container option after widget is created") widget2 = self.create(container=True) self.assertEqual(widget2['container'], 1 if self.wantobjects else '1') def test_visual(self): widget = self.create() self.assertEqual(widget['visual'], '') self.checkInvalidParam(widget, 'visual', 'default', errmsg="can't modify -visual option after widget is created") widget2 = self.create(visual='default') self.assertEqual(widget2['visual'], 'default') @add_standard_options(StandardOptionsTests) class ToplevelTest(AbstractToplevelTest, unittest.TestCase): OPTIONS = ( 'background', 'borderwidth', 'class', 'colormap', 'container', 'cursor', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'menu', 'padx', 'pady', 'relief', 'screen', 'takefocus', 'use', 'visual', 'width', ) def create(self, **kwargs): return tkinter.Toplevel(self.root, **kwargs) def test_menu(self): widget = self.create() menu = tkinter.Menu(self.root) self.checkParam(widget, 'menu', menu, eq=widget_eq) self.checkParam(widget, 'menu', '') def test_screen(self): widget = self.create() self.assertEqual(widget['screen'], '') try: display = os.environ['DISPLAY'] except KeyError: self.skipTest('No $DISPLAY set.') self.checkInvalidParam(widget, 'screen', display, errmsg="can't modify -screen option after widget is created") widget2 = self.create(screen=display) self.assertEqual(widget2['screen'], display) def test_use(self): widget = self.create() self.assertEqual(widget['use'], '') parent = self.create(container=True) # hex() adds the 'L' suffix for longs wid = '%#x' % parent.winfo_id() widget2 = self.create(use=wid) self.assertEqual(widget2['use'], wid) @add_standard_options(StandardOptionsTests) class FrameTest(AbstractToplevelTest, unittest.TestCase): OPTIONS = ( 'background', 'borderwidth', 'class', 'colormap', 'container', 'cursor', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'padx', 'pady', 'relief', 'takefocus', 'visual', 'width', ) def create(self, **kwargs): return tkinter.Frame(self.root, **kwargs) @add_standard_options(StandardOptionsTests) class LabelFrameTest(AbstractToplevelTest, unittest.TestCase): OPTIONS = ( 'background', 'borderwidth', 'class', 'colormap', 'container', 'cursor', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'labelanchor', 'labelwidget', 'padx', 'pady', 'relief', 'takefocus', 'text', 'visual', 'width', ) def create(self, **kwargs): return tkinter.LabelFrame(self.root, **kwargs) def test_labelanchor(self): widget = self.create() self.checkEnumParam(widget, 'labelanchor', 'e', 'en', 'es', 'n', 'ne', 'nw', 's', 'se', 'sw', 'w', 'wn', 'ws') self.checkInvalidParam(widget, 'labelanchor', 'center') def test_labelwidget(self): widget = self.create() label = tkinter.Label(self.root, text='Mupp', name='foo') self.checkParam(widget, 'labelwidget', label, expected='.foo') label.destroy() class AbstractLabelTest(AbstractWidgetTest, IntegerSizeTests): _conv_pixels = noconv_meth def test_highlightthickness(self): widget = self.create() self.checkPixelsParam(widget, 'highlightthickness', 0, 1.3, 2.6, 6, -2, '10p') @add_standard_options(StandardOptionsTests) class LabelTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'activeforeground', 'anchor', 'background', 'bitmap', 'borderwidth', 'compound', 'cursor', 'disabledforeground', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'image', 'justify', 'padx', 'pady', 'relief', 'state', 'takefocus', 'text', 'textvariable', 'underline', 'width', 'wraplength', ) def create(self, **kwargs): return tkinter.Label(self.root, **kwargs) @add_standard_options(StandardOptionsTests) class ButtonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'activeforeground', 'anchor', 'background', 'bitmap', 'borderwidth', 'command', 'compound', 'cursor', 'default', 'disabledforeground', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'image', 'justify', 'overrelief', 'padx', 'pady', 'relief', 'repeatdelay', 'repeatinterval', 'state', 'takefocus', 'text', 'textvariable', 'underline', 'width', 'wraplength') def create(self, **kwargs): return tkinter.Button(self.root, **kwargs) def test_default(self): widget = self.create() self.checkEnumParam(widget, 'default', 'active', 'disabled', 'normal') @add_standard_options(StandardOptionsTests) class CheckbuttonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'activeforeground', 'anchor', 'background', 'bitmap', 'borderwidth', 'command', 'compound', 'cursor', 'disabledforeground', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'image', 'indicatoron', 'justify', 'offrelief', 'offvalue', 'onvalue', 'overrelief', 'padx', 'pady', 'relief', 'selectcolor', 'selectimage', 'state', 'takefocus', 'text', 'textvariable', 'tristateimage', 'tristatevalue', 'underline', 'variable', 'width', 'wraplength', ) def create(self, **kwargs): return tkinter.Checkbutton(self.root, **kwargs) def test_offvalue(self): widget = self.create() self.checkParams(widget, 'offvalue', 1, 2.3, '', 'any string') def test_onvalue(self): widget = self.create() self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string') @add_standard_options(StandardOptionsTests) class RadiobuttonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'activeforeground', 'anchor', 'background', 'bitmap', 'borderwidth', 'command', 'compound', 'cursor', 'disabledforeground', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'image', 'indicatoron', 'justify', 'offrelief', 'overrelief', 'padx', 'pady', 'relief', 'selectcolor', 'selectimage', 'state', 'takefocus', 'text', 'textvariable', 'tristateimage', 'tristatevalue', 'underline', 'value', 'variable', 'width', 'wraplength', ) def create(self, **kwargs): return tkinter.Radiobutton(self.root, **kwargs) def test_value(self): widget = self.create() self.checkParams(widget, 'value', 1, 2.3, '', 'any string') @add_standard_options(StandardOptionsTests) class MenubuttonTest(AbstractLabelTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'activeforeground', 'anchor', 'background', 'bitmap', 'borderwidth', 'compound', 'cursor', 'direction', 'disabledforeground', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'image', 'indicatoron', 'justify', 'menu', 'padx', 'pady', 'relief', 'state', 'takefocus', 'text', 'textvariable', 'underline', 'width', 'wraplength', ) _conv_pixels = staticmethod(pixels_round) def create(self, **kwargs): return tkinter.Menubutton(self.root, **kwargs) def test_direction(self): widget = self.create() self.checkEnumParam(widget, 'direction', 'above', 'below', 'flush', 'left', 'right') def test_height(self): widget = self.create() self.checkIntegerParam(widget, 'height', 100, -100, 0, conv=str) test_highlightthickness = StandardOptionsTests.test_highlightthickness.im_func @unittest.skipIf(sys.platform == 'darwin', 'crashes with Cocoa Tk (issue19733)') def test_image(self): widget = self.create() image = tkinter.PhotoImage(master=self.root, name='image1') self.checkParam(widget, 'image', image, conv=str) errmsg = 'image "spam" doesn\'t exist' with self.assertRaises(tkinter.TclError) as cm: widget['image'] = 'spam' if errmsg is not None: self.assertEqual(str(cm.exception), errmsg) with self.assertRaises(tkinter.TclError) as cm: widget.configure({'image': 'spam'}) if errmsg is not None: self.assertEqual(str(cm.exception), errmsg) def test_menu(self): widget = self.create() menu = tkinter.Menu(widget, name='menu') self.checkParam(widget, 'menu', menu, eq=widget_eq) menu.destroy() def test_padx(self): widget = self.create() self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, '12m') self.checkParam(widget, 'padx', -2, expected=0) def test_pady(self): widget = self.create() self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, '12m') self.checkParam(widget, 'pady', -2, expected=0) def test_width(self): widget = self.create() self.checkIntegerParam(widget, 'width', 402, -402, 0, conv=str) class OptionMenuTest(MenubuttonTest, unittest.TestCase): def create(self, default='b', values=('a', 'b', 'c'), **kwargs): return tkinter.OptionMenu(self.root, None, default, *values, **kwargs) @add_standard_options(IntegerSizeTests, StandardOptionsTests) class EntryTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'background', 'borderwidth', 'cursor', 'disabledbackground', 'disabledforeground', 'exportselection', 'font', 'foreground', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'insertbackground', 'insertborderwidth', 'insertofftime', 'insertontime', 'insertwidth', 'invalidcommand', 'justify', 'readonlybackground', 'relief', 'selectbackground', 'selectborderwidth', 'selectforeground', 'show', 'state', 'takefocus', 'textvariable', 'validate', 'validatecommand', 'width', 'xscrollcommand', ) def create(self, **kwargs): return tkinter.Entry(self.root, **kwargs) def test_disabledbackground(self): widget = self.create() self.checkColorParam(widget, 'disabledbackground') def test_insertborderwidth(self): widget = self.create(insertwidth=100) self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, 2.6, 6, -2, '10p') # insertborderwidth is bounded above by a half of insertwidth. self.checkParam(widget, 'insertborderwidth', 60, expected=100//2) def test_insertwidth(self): widget = self.create() self.checkPixelsParam(widget, 'insertwidth', 1.3, 3.6, '10p') self.checkParam(widget, 'insertwidth', 0.1, expected=2) self.checkParam(widget, 'insertwidth', -2, expected=2) if pixels_round(0.9) <= 0: self.checkParam(widget, 'insertwidth', 0.9, expected=2) else: self.checkParam(widget, 'insertwidth', 0.9, expected=1) def test_invalidcommand(self): widget = self.create() self.checkCommandParam(widget, 'invalidcommand') self.checkCommandParam(widget, 'invcmd') def test_readonlybackground(self): widget = self.create() self.checkColorParam(widget, 'readonlybackground') def test_show(self): widget = self.create() self.checkParam(widget, 'show', '*') self.checkParam(widget, 'show', '') self.checkParam(widget, 'show', ' ') def test_state(self): widget = self.create() self.checkEnumParam(widget, 'state', 'disabled', 'normal', 'readonly') def test_validate(self): widget = self.create() self.checkEnumParam(widget, 'validate', 'all', 'key', 'focus', 'focusin', 'focusout', 'none') def test_validatecommand(self): widget = self.create() self.checkCommandParam(widget, 'validatecommand') self.checkCommandParam(widget, 'vcmd') @add_standard_options(StandardOptionsTests) class SpinboxTest(EntryTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'background', 'borderwidth', 'buttonbackground', 'buttoncursor', 'buttondownrelief', 'buttonuprelief', 'command', 'cursor', 'disabledbackground', 'disabledforeground', 'exportselection', 'font', 'foreground', 'format', 'from', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'increment', 'insertbackground', 'insertborderwidth', 'insertofftime', 'insertontime', 'insertwidth', 'invalidcommand', 'justify', 'relief', 'readonlybackground', 'repeatdelay', 'repeatinterval', 'selectbackground', 'selectborderwidth', 'selectforeground', 'state', 'takefocus', 'textvariable', 'to', 'validate', 'validatecommand', 'values', 'width', 'wrap', 'xscrollcommand', ) def create(self, **kwargs): return tkinter.Spinbox(self.root, **kwargs) test_show = None def test_buttonbackground(self): widget = self.create() self.checkColorParam(widget, 'buttonbackground') def test_buttoncursor(self): widget = self.create() self.checkCursorParam(widget, 'buttoncursor') def test_buttondownrelief(self): widget = self.create() self.checkReliefParam(widget, 'buttondownrelief') def test_buttonuprelief(self): widget = self.create() self.checkReliefParam(widget, 'buttonuprelief') def test_format(self): widget = self.create() self.checkParam(widget, 'format', '%2f') self.checkParam(widget, 'format', '%2.2f') self.checkParam(widget, 'format', '%.2f') self.checkParam(widget, 'format', '%2.f') self.checkInvalidParam(widget, 'format', '%2e-1f') self.checkInvalidParam(widget, 'format', '2.2') self.checkInvalidParam(widget, 'format', '%2.-2f') self.checkParam(widget, 'format', '%-2.02f') self.checkParam(widget, 'format', '% 2.02f') self.checkParam(widget, 'format', '% -2.200f') self.checkParam(widget, 'format', '%09.200f') self.checkInvalidParam(widget, 'format', '%d') def test_from(self): widget = self.create() self.checkParam(widget, 'to', 100.0) self.checkFloatParam(widget, 'from', -10, 10.2, 11.7) self.checkInvalidParam(widget, 'from', 200, errmsg='-to value must be greater than -from value') def test_increment(self): widget = self.create() self.checkFloatParam(widget, 'increment', -1, 1, 10.2, 12.8, 0) def test_to(self): widget = self.create() self.checkParam(widget, 'from', -100.0) self.checkFloatParam(widget, 'to', -10, 10.2, 11.7) self.checkInvalidParam(widget, 'to', -200, errmsg='-to value must be greater than -from value') def test_values(self): # XXX widget = self.create() self.assertEqual(widget['values'], '') self.checkParam(widget, 'values', 'mon tue wed thur') self.checkParam(widget, 'values', ('mon', 'tue', 'wed', 'thur'), expected='mon tue wed thur') self.checkParam(widget, 'values', (42, 3.14, '', 'any string'), expected='42 3.14 {} {any string}') self.checkParam(widget, 'values', '') def test_wrap(self): widget = self.create() self.checkBooleanParam(widget, 'wrap') def test_bbox(self): widget = self.create() self.assertIsBoundingBox(widget.bbox(0)) self.assertRaises(tkinter.TclError, widget.bbox, 'noindex') self.assertRaises(tkinter.TclError, widget.bbox, None) self.assertRaises(TypeError, widget.bbox) self.assertRaises(TypeError, widget.bbox, 0, 1) def test_selection_element(self): widget = self.create() self.assertEqual(widget.selection_element(), "none") widget.selection_element("buttonup") self.assertEqual(widget.selection_element(), "buttonup") widget.selection_element("buttondown") self.assertEqual(widget.selection_element(), "buttondown") @add_standard_options(StandardOptionsTests) class TextTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'autoseparators', 'background', 'blockcursor', 'borderwidth', 'cursor', 'endline', 'exportselection', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'inactiveselectbackground', 'insertbackground', 'insertborderwidth', 'insertofftime', 'insertontime', 'insertunfocussed', 'insertwidth', 'maxundo', 'padx', 'pady', 'relief', 'selectbackground', 'selectborderwidth', 'selectforeground', 'setgrid', 'spacing1', 'spacing2', 'spacing3', 'startline', 'state', 'tabs', 'tabstyle', 'takefocus', 'undo', 'width', 'wrap', 'xscrollcommand', 'yscrollcommand', ) if tcl_version < (8, 5): _stringify = True def create(self, **kwargs): return tkinter.Text(self.root, **kwargs) def test_autoseparators(self): widget = self.create() self.checkBooleanParam(widget, 'autoseparators') @requires_tcl(8, 5) def test_blockcursor(self): widget = self.create() self.checkBooleanParam(widget, 'blockcursor') @requires_tcl(8, 5) def test_endline(self): widget = self.create() text = '\n'.join('Line %d' for i in range(100)) widget.insert('end', text) self.checkParam(widget, 'endline', 200, expected='') self.checkParam(widget, 'endline', -10, expected='') self.checkInvalidParam(widget, 'endline', 'spam', errmsg='expected integer but got "spam"') self.checkParam(widget, 'endline', 50) self.checkParam(widget, 'startline', 15) self.checkInvalidParam(widget, 'endline', 10, errmsg='-startline must be less than or equal to -endline') def test_height(self): widget = self.create() self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, '3c') self.checkParam(widget, 'height', -100, expected=1) self.checkParam(widget, 'height', 0, expected=1) def test_maxundo(self): widget = self.create() self.checkIntegerParam(widget, 'maxundo', 0, 5, -1) @requires_tcl(8, 5) def test_inactiveselectbackground(self): widget = self.create() self.checkColorParam(widget, 'inactiveselectbackground') @requires_tcl(8, 6) def test_insertunfocussed(self): widget = self.create() self.checkEnumParam(widget, 'insertunfocussed', 'hollow', 'none', 'solid') def test_selectborderwidth(self): widget = self.create() self.checkPixelsParam(widget, 'selectborderwidth', 1.3, 2.6, -2, '10p', conv=noconv, keep_orig=tcl_version >= (8, 5)) def test_spacing1(self): widget = self.create() self.checkPixelsParam(widget, 'spacing1', 20, 21.4, 22.6, '0.5c') self.checkParam(widget, 'spacing1', -5, expected=0) def test_spacing2(self): widget = self.create() self.checkPixelsParam(widget, 'spacing2', 5, 6.4, 7.6, '0.1c') self.checkParam(widget, 'spacing2', -1, expected=0) def test_spacing3(self): widget = self.create() self.checkPixelsParam(widget, 'spacing3', 20, 21.4, 22.6, '0.5c') self.checkParam(widget, 'spacing3', -10, expected=0) @requires_tcl(8, 5) def test_startline(self): widget = self.create() text = '\n'.join('Line %d' for i in range(100)) widget.insert('end', text) self.checkParam(widget, 'startline', 200, expected='') self.checkParam(widget, 'startline', -10, expected='') self.checkInvalidParam(widget, 'startline', 'spam', errmsg='expected integer but got "spam"') self.checkParam(widget, 'startline', 10) self.checkParam(widget, 'endline', 50) self.checkInvalidParam(widget, 'startline', 70, errmsg='-startline must be less than or equal to -endline') def test_state(self): widget = self.create() if tcl_version < (8, 5): self.checkParams(widget, 'state', 'disabled', 'normal') else: self.checkEnumParam(widget, 'state', 'disabled', 'normal') def test_tabs(self): widget = self.create() if get_tk_patchlevel() < (8, 5, 11): self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'), expected=('10.2', '20.7', '1i', '2i')) else: self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i')) self.checkParam(widget, 'tabs', '10.2 20.7 1i 2i', expected=('10.2', '20.7', '1i', '2i')) self.checkParam(widget, 'tabs', '2c left 4c 6c center', expected=('2c', 'left', '4c', '6c', 'center')) self.checkInvalidParam(widget, 'tabs', 'spam', errmsg='bad screen distance "spam"', keep_orig=tcl_version >= (8, 5)) @requires_tcl(8, 5) def test_tabstyle(self): widget = self.create() self.checkEnumParam(widget, 'tabstyle', 'tabular', 'wordprocessor') def test_undo(self): widget = self.create() self.checkBooleanParam(widget, 'undo') def test_width(self): widget = self.create() self.checkIntegerParam(widget, 'width', 402) self.checkParam(widget, 'width', -402, expected=1) self.checkParam(widget, 'width', 0, expected=1) def test_wrap(self): widget = self.create() if tcl_version < (8, 5): self.checkParams(widget, 'wrap', 'char', 'none', 'word') else: self.checkEnumParam(widget, 'wrap', 'char', 'none', 'word') def test_bbox(self): widget = self.create() self.assertIsBoundingBox(widget.bbox('1.1')) self.assertIsNone(widget.bbox('end')) self.assertRaises(tkinter.TclError, widget.bbox, 'noindex') self.assertRaises(tkinter.TclError, widget.bbox, None) self.assertRaises(tkinter.TclError, widget.bbox) self.assertRaises(tkinter.TclError, widget.bbox, '1.1', 'end') @add_standard_options(PixelSizeTests, StandardOptionsTests) class CanvasTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'background', 'borderwidth', 'closeenough', 'confine', 'cursor', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'insertbackground', 'insertborderwidth', 'insertofftime', 'insertontime', 'insertwidth', 'offset', 'relief', 'scrollregion', 'selectbackground', 'selectborderwidth', 'selectforeground', 'state', 'takefocus', 'xscrollcommand', 'xscrollincrement', 'yscrollcommand', 'yscrollincrement', 'width', ) _conv_pixels = staticmethod(int_round) _stringify = True def create(self, **kwargs): return tkinter.Canvas(self.root, **kwargs) def test_closeenough(self): widget = self.create() self.checkFloatParam(widget, 'closeenough', 24, 2.4, 3.6, -3, conv=float) def test_confine(self): widget = self.create() self.checkBooleanParam(widget, 'confine') def test_offset(self): widget = self.create() self.assertEqual(widget['offset'], '0,0') self.checkParams(widget, 'offset', 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center') self.checkParam(widget, 'offset', '10,20') self.checkParam(widget, 'offset', '#5,6') self.checkInvalidParam(widget, 'offset', 'spam') def test_scrollregion(self): widget = self.create() self.checkParam(widget, 'scrollregion', '0 0 200 150') self.checkParam(widget, 'scrollregion', (0, 0, 200, 150), expected='0 0 200 150') self.checkParam(widget, 'scrollregion', '') self.checkInvalidParam(widget, 'scrollregion', 'spam', errmsg='bad scrollRegion "spam"') self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200, 'spam')) self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200)) self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200, 150, 0)) def test_state(self): widget = self.create() self.checkEnumParam(widget, 'state', 'disabled', 'normal', errmsg='bad state value "{}": must be normal or disabled') def test_xscrollincrement(self): widget = self.create() self.checkPixelsParam(widget, 'xscrollincrement', 40, 0, 41.2, 43.6, -40, '0.5i') def test_yscrollincrement(self): widget = self.create() self.checkPixelsParam(widget, 'yscrollincrement', 10, 0, 11.2, 13.6, -10, '0.1i') @add_standard_options(IntegerSizeTests, StandardOptionsTests) class ListboxTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'activestyle', 'background', 'borderwidth', 'cursor', 'disabledforeground', 'exportselection', 'font', 'foreground', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'justify', 'listvariable', 'relief', 'selectbackground', 'selectborderwidth', 'selectforeground', 'selectmode', 'setgrid', 'state', 'takefocus', 'width', 'xscrollcommand', 'yscrollcommand', ) def create(self, **kwargs): return tkinter.Listbox(self.root, **kwargs) def test_activestyle(self): widget = self.create() self.checkEnumParam(widget, 'activestyle', 'dotbox', 'none', 'underline') test_justify = requires_tcl(8, 6, 5)(StandardOptionsTests.test_justify.im_func) def test_listvariable(self): widget = self.create() var = tkinter.DoubleVar(self.root) self.checkVariableParam(widget, 'listvariable', var) def test_selectmode(self): widget = self.create() self.checkParam(widget, 'selectmode', 'single') self.checkParam(widget, 'selectmode', 'browse') self.checkParam(widget, 'selectmode', 'multiple') self.checkParam(widget, 'selectmode', 'extended') def test_state(self): widget = self.create() self.checkEnumParam(widget, 'state', 'disabled', 'normal') def test_itemconfigure(self): widget = self.create() with self.assertRaisesRegexp(TclError, 'item number "0" out of range'): widget.itemconfigure(0) colors = 'red orange yellow green blue white violet'.split() widget.insert('end', *colors) for i, color in enumerate(colors): widget.itemconfigure(i, background=color) with self.assertRaises(TypeError): widget.itemconfigure() with self.assertRaisesRegexp(TclError, 'bad listbox index "red"'): widget.itemconfigure('red') self.assertEqual(widget.itemconfigure(0, 'background'), ('background', 'background', 'Background', '', 'red')) self.assertEqual(widget.itemconfigure('end', 'background'), ('background', 'background', 'Background', '', 'violet')) self.assertEqual(widget.itemconfigure('@0,0', 'background'), ('background', 'background', 'Background', '', 'red')) d = widget.itemconfigure(0) self.assertIsInstance(d, dict) for k, v in d.items(): self.assertIn(len(v), (2, 5)) if len(v) == 5: self.assertEqual(v, widget.itemconfigure(0, k)) self.assertEqual(v[4], widget.itemcget(0, k)) def check_itemconfigure(self, name, value): widget = self.create() widget.insert('end', 'a', 'b', 'c', 'd') widget.itemconfigure(0, **{name: value}) self.assertEqual(widget.itemconfigure(0, name)[4], value) self.assertEqual(widget.itemcget(0, name), value) with self.assertRaisesRegexp(TclError, 'unknown color name "spam"'): widget.itemconfigure(0, **{name: 'spam'}) def test_itemconfigure_background(self): self.check_itemconfigure('background', '#ff0000') def test_itemconfigure_bg(self): self.check_itemconfigure('bg', '#ff0000') def test_itemconfigure_fg(self): self.check_itemconfigure('fg', '#110022') def test_itemconfigure_foreground(self): self.check_itemconfigure('foreground', '#110022') def test_itemconfigure_selectbackground(self): self.check_itemconfigure('selectbackground', '#110022') def test_itemconfigure_selectforeground(self): self.check_itemconfigure('selectforeground', '#654321') def test_box(self): lb = self.create() lb.insert(0, *('el%d' % i for i in range(8))) lb.pack() self.assertIsBoundingBox(lb.bbox(0)) self.assertIsNone(lb.bbox(-1)) self.assertIsNone(lb.bbox(10)) self.assertRaises(TclError, lb.bbox, 'noindex') self.assertRaises(TclError, lb.bbox, None) self.assertRaises(TypeError, lb.bbox) self.assertRaises(TypeError, lb.bbox, 0, 1) def test_curselection(self): lb = self.create() lb.insert(0, *('el%d' % i for i in range(8))) lb.selection_clear(0, tkinter.END) lb.selection_set(2, 4) lb.selection_set(6) self.assertEqual(lb.curselection(), (2, 3, 4, 6)) self.assertRaises(TypeError, lb.curselection, 0) def test_get(self): lb = self.create() lb.insert(0, *('el%d' % i for i in range(8))) self.assertEqual(lb.get(0), 'el0') self.assertEqual(lb.get(3), 'el3') self.assertEqual(lb.get('end'), 'el7') self.assertEqual(lb.get(8), '') self.assertEqual(lb.get(-1), '') self.assertEqual(lb.get(3, 5), ('el3', 'el4', 'el5')) self.assertEqual(lb.get(5, 'end'), ('el5', 'el6', 'el7')) self.assertEqual(lb.get(5, 0), ()) self.assertEqual(lb.get(0, 0), ('el0',)) self.assertRaises(TclError, lb.get, 'noindex') self.assertRaises(TclError, lb.get, None) self.assertRaises(TypeError, lb.get) self.assertRaises(TclError, lb.get, 'end', 'noindex') self.assertRaises(TypeError, lb.get, 1, 2, 3) self.assertRaises(TclError, lb.get, 2.4) @add_standard_options(PixelSizeTests, StandardOptionsTests) class ScaleTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'background', 'bigincrement', 'borderwidth', 'command', 'cursor', 'digits', 'font', 'foreground', 'from', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'label', 'length', 'orient', 'relief', 'repeatdelay', 'repeatinterval', 'resolution', 'showvalue', 'sliderlength', 'sliderrelief', 'state', 'takefocus', 'tickinterval', 'to', 'troughcolor', 'variable', 'width', ) default_orient = 'vertical' def create(self, **kwargs): return tkinter.Scale(self.root, **kwargs) def test_bigincrement(self): widget = self.create() self.checkFloatParam(widget, 'bigincrement', 12.4, 23.6, -5) def test_digits(self): widget = self.create() self.checkIntegerParam(widget, 'digits', 5, 0) def test_from(self): widget = self.create() self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=round) def test_label(self): widget = self.create() self.checkParam(widget, 'label', 'any string') self.checkParam(widget, 'label', '') def test_length(self): widget = self.create() self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i') def test_resolution(self): widget = self.create() self.checkFloatParam(widget, 'resolution', 4.2, 0, 6.7, -2) def test_showvalue(self): widget = self.create() self.checkBooleanParam(widget, 'showvalue') def test_sliderlength(self): widget = self.create() self.checkPixelsParam(widget, 'sliderlength', 10, 11.2, 15.6, -3, '3m') def test_sliderrelief(self): widget = self.create() self.checkReliefParam(widget, 'sliderrelief') def test_tickinterval(self): widget = self.create() self.checkFloatParam(widget, 'tickinterval', 1, 4.3, 7.6, 0, conv=round) self.checkParam(widget, 'tickinterval', -2, expected=2, conv=round) def test_to(self): widget = self.create() self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=round) @add_standard_options(PixelSizeTests, StandardOptionsTests) class ScrollbarTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'activerelief', 'background', 'borderwidth', 'command', 'cursor', 'elementborderwidth', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'jump', 'orient', 'relief', 'repeatdelay', 'repeatinterval', 'takefocus', 'troughcolor', 'width', ) _conv_pixels = staticmethod(int_round) _stringify = True default_orient = 'vertical' def create(self, **kwargs): return tkinter.Scrollbar(self.root, **kwargs) def test_activerelief(self): widget = self.create() self.checkReliefParam(widget, 'activerelief') def test_elementborderwidth(self): widget = self.create() self.checkPixelsParam(widget, 'elementborderwidth', 4.3, 5.6, -2, '1m') def test_orient(self): widget = self.create() self.checkEnumParam(widget, 'orient', 'vertical', 'horizontal', errmsg='bad orientation "{}": must be vertical or horizontal') def test_activate(self): sb = self.create() for e in ('arrow1', 'slider', 'arrow2'): sb.activate(e) sb.activate('') self.assertRaises(TypeError, sb.activate) self.assertRaises(TypeError, sb.activate, 'arrow1', 'arrow2') def test_set(self): sb = self.create() sb.set(0.2, 0.4) self.assertEqual(sb.get(), (0.2, 0.4)) self.assertRaises(TclError, sb.set, 'abc', 'def') self.assertRaises(TclError, sb.set, 0.6, 'def') self.assertRaises(TclError, sb.set, 0.6, None) self.assertRaises(TclError, sb.set, 0.6) self.assertRaises(TclError, sb.set, 0.6, 0.7, 0.8) @add_standard_options(StandardOptionsTests) class PanedWindowTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'background', 'borderwidth', 'cursor', 'handlepad', 'handlesize', 'height', 'opaqueresize', 'orient', 'proxybackground', 'proxyborderwidth', 'proxyrelief', 'relief', 'sashcursor', 'sashpad', 'sashrelief', 'sashwidth', 'showhandle', 'width', ) default_orient = 'horizontal' def create(self, **kwargs): return tkinter.PanedWindow(self.root, **kwargs) def test_handlepad(self): widget = self.create() self.checkPixelsParam(widget, 'handlepad', 5, 6.4, 7.6, -3, '1m') def test_handlesize(self): widget = self.create() self.checkPixelsParam(widget, 'handlesize', 8, 9.4, 10.6, -3, '2m', conv=noconv) def test_height(self): widget = self.create() self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i', conv=noconv) def test_opaqueresize(self): widget = self.create() self.checkBooleanParam(widget, 'opaqueresize') @requires_tcl(8, 6, 5) def test_proxybackground(self): widget = self.create() self.checkColorParam(widget, 'proxybackground') @requires_tcl(8, 6, 5) def test_proxyborderwidth(self): widget = self.create() self.checkPixelsParam(widget, 'proxyborderwidth', 0, 1.3, 2.9, 6, -2, '10p', conv=noconv) @requires_tcl(8, 6, 5) def test_proxyrelief(self): widget = self.create() self.checkReliefParam(widget, 'proxyrelief') def test_sashcursor(self): widget = self.create() self.checkCursorParam(widget, 'sashcursor') def test_sashpad(self): widget = self.create() self.checkPixelsParam(widget, 'sashpad', 8, 1.3, 2.6, -2, '2m') def test_sashrelief(self): widget = self.create() self.checkReliefParam(widget, 'sashrelief') def test_sashwidth(self): widget = self.create() self.checkPixelsParam(widget, 'sashwidth', 10, 11.1, 15.6, -3, '1m', conv=noconv) def test_showhandle(self): widget = self.create() self.checkBooleanParam(widget, 'showhandle') def test_width(self): widget = self.create() self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i', conv=noconv) def create2(self): p = self.create() b = tkinter.Button(p) c = tkinter.Button(p) p.add(b) p.add(c) return p, b, c def test_paneconfigure(self): p, b, c = self.create2() self.assertRaises(TypeError, p.paneconfigure) d = p.paneconfigure(b) self.assertIsInstance(d, dict) for k, v in d.items(): self.assertEqual(len(v), 5) self.assertEqual(v, p.paneconfigure(b, k)) self.assertEqual(v[4], p.panecget(b, k)) def check_paneconfigure(self, p, b, name, value, expected, stringify=False): conv = lambda x: x if not self.wantobjects or stringify: expected = str(expected) if self.wantobjects and stringify: conv = str p.paneconfigure(b, **{name: value}) self.assertEqual(conv(p.paneconfigure(b, name)[4]), expected) self.assertEqual(conv(p.panecget(b, name)), expected) def check_paneconfigure_bad(self, p, b, name, msg): with self.assertRaisesRegexp(TclError, msg): p.paneconfigure(b, **{name: 'badValue'}) def test_paneconfigure_after(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'after', c, str(c)) self.check_paneconfigure_bad(p, b, 'after', 'bad window path name "badValue"') def test_paneconfigure_before(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'before', c, str(c)) self.check_paneconfigure_bad(p, b, 'before', 'bad window path name "badValue"') def test_paneconfigure_height(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'height', 10, 10, stringify=get_tk_patchlevel() < (8, 5, 11)) self.check_paneconfigure_bad(p, b, 'height', 'bad screen distance "badValue"') @requires_tcl(8, 5) def test_paneconfigure_hide(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'hide', False, 0) self.check_paneconfigure_bad(p, b, 'hide', 'expected boolean value but got "badValue"') def test_paneconfigure_minsize(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'minsize', 10, 10) self.check_paneconfigure_bad(p, b, 'minsize', 'bad screen distance "badValue"') def test_paneconfigure_padx(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'padx', 1.3, 1) self.check_paneconfigure_bad(p, b, 'padx', 'bad screen distance "badValue"') def test_paneconfigure_pady(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'pady', 1.3, 1) self.check_paneconfigure_bad(p, b, 'pady', 'bad screen distance "badValue"') def test_paneconfigure_sticky(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'sticky', 'nsew', 'nesw') self.check_paneconfigure_bad(p, b, 'sticky', 'bad stickyness value "badValue": must ' 'be a string containing zero or more of ' 'n, e, s, and w') @requires_tcl(8, 5) def test_paneconfigure_stretch(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'stretch', 'alw', 'always') self.check_paneconfigure_bad(p, b, 'stretch', 'bad stretch "badValue": must be ' 'always, first, last, middle, or never') def test_paneconfigure_width(self): p, b, c = self.create2() self.check_paneconfigure(p, b, 'width', 10, 10, stringify=get_tk_patchlevel() < (8, 5, 11)) self.check_paneconfigure_bad(p, b, 'width', 'bad screen distance "badValue"') @add_standard_options(StandardOptionsTests) class MenuTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'activebackground', 'activeborderwidth', 'activeforeground', 'background', 'borderwidth', 'cursor', 'disabledforeground', 'font', 'foreground', 'postcommand', 'relief', 'selectcolor', 'takefocus', 'tearoff', 'tearoffcommand', 'title', 'type', ) _conv_pixels = noconv_meth def create(self, **kwargs): return tkinter.Menu(self.root, **kwargs) def test_postcommand(self): widget = self.create() self.checkCommandParam(widget, 'postcommand') def test_tearoff(self): widget = self.create() self.checkBooleanParam(widget, 'tearoff') def test_tearoffcommand(self): widget = self.create() self.checkCommandParam(widget, 'tearoffcommand') def test_title(self): widget = self.create() self.checkParam(widget, 'title', 'any string') def test_type(self): widget = self.create() self.checkEnumParam(widget, 'type', 'normal', 'tearoff', 'menubar') def test_entryconfigure(self): m1 = self.create() m1.add_command(label='test') self.assertRaises(TypeError, m1.entryconfigure) with self.assertRaisesRegexp(TclError, 'bad menu entry index "foo"'): m1.entryconfigure('foo') d = m1.entryconfigure(1) self.assertIsInstance(d, dict) for k, v in d.items(): self.assertIsInstance(k, str) self.assertIsInstance(v, tuple) self.assertEqual(len(v), 5) self.assertEqual(v[0], k) self.assertEqual(m1.entrycget(1, k), v[4]) m1.destroy() def test_entryconfigure_label(self): m1 = self.create() m1.add_command(label='test') self.assertEqual(m1.entrycget(1, 'label'), 'test') m1.entryconfigure(1, label='changed') self.assertEqual(m1.entrycget(1, 'label'), 'changed') def test_entryconfigure_variable(self): m1 = self.create() v1 = tkinter.BooleanVar(self.root) v2 = tkinter.BooleanVar(self.root) m1.add_checkbutton(variable=v1, onvalue=True, offvalue=False, label='Nonsense') self.assertEqual(str(m1.entrycget(1, 'variable')), str(v1)) m1.entryconfigure(1, variable=v2) self.assertEqual(str(m1.entrycget(1, 'variable')), str(v2)) @add_standard_options(PixelSizeTests, StandardOptionsTests) class MessageTest(AbstractWidgetTest, unittest.TestCase): OPTIONS = ( 'anchor', 'aspect', 'background', 'borderwidth', 'cursor', 'font', 'foreground', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'justify', 'padx', 'pady', 'relief', 'takefocus', 'text', 'textvariable', 'width', ) _conv_pad_pixels = noconv_meth def create(self, **kwargs): return tkinter.Message(self.root, **kwargs) def test_aspect(self): widget = self.create() self.checkIntegerParam(widget, 'aspect', 250, 0, -300) tests_gui = [ ButtonTest, CanvasTest, CheckbuttonTest, EntryTest, FrameTest, LabelFrameTest,LabelTest, ListboxTest, MenubuttonTest, MenuTest, MessageTest, OptionMenuTest, PanedWindowTest, RadiobuttonTest, ScaleTest, ScrollbarTest, SpinboxTest, TextTest, ToplevelTest, ] if __name__ == '__main__': run_unittest(*tests_gui) PK]test_tkinter/__init__.pynu[PK]3(4(4test_tkinter/test_images.pynu[import unittest import Tkinter as tkinter import ttk import test.test_support as support from test_ttk.support import AbstractTkTest, requires_tcl support.requires('gui') class MiscTest(AbstractTkTest, unittest.TestCase): def test_image_types(self): image_types = self.root.image_types() self.assertIsInstance(image_types, tuple) self.assertIn('photo', image_types) self.assertIn('bitmap', image_types) def test_image_names(self): image_names = self.root.image_names() self.assertIsInstance(image_names, tuple) class BitmapImageTest(AbstractTkTest, unittest.TestCase): @classmethod def setUpClass(cls): AbstractTkTest.setUpClass.__func__(cls) cls.testfile = support.findfile('python.xbm', subdir='imghdrdata') def test_create_from_file(self): image = tkinter.BitmapImage('::img::test', master=self.root, foreground='yellow', background='blue', file=self.testfile) self.assertEqual(str(image), '::img::test') self.assertEqual(image.type(), 'bitmap') self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) self.assertIn('::img::test', self.root.image_names()) del image self.assertNotIn('::img::test', self.root.image_names()) def test_create_from_data(self): with open(self.testfile, 'rb') as f: data = f.read() image = tkinter.BitmapImage('::img::test', master=self.root, foreground='yellow', background='blue', data=data) self.assertEqual(str(image), '::img::test') self.assertEqual(image.type(), 'bitmap') self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) self.assertIn('::img::test', self.root.image_names()) del image self.assertNotIn('::img::test', self.root.image_names()) def assertEqualStrList(self, actual, expected): self.assertIsInstance(actual, str) self.assertEqual(self.root.splitlist(actual), expected) def test_configure_data(self): image = tkinter.BitmapImage('::img::test', master=self.root) self.assertEqual(image['data'], '-data {} {} {} {}') with open(self.testfile, 'rb') as f: data = f.read() image.configure(data=data) self.assertEqualStrList(image['data'], ('-data', '', '', '', data)) self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) self.assertEqual(image['maskdata'], '-maskdata {} {} {} {}') image.configure(maskdata=data) self.assertEqualStrList(image['maskdata'], ('-maskdata', '', '', '', data)) def test_configure_file(self): image = tkinter.BitmapImage('::img::test', master=self.root) self.assertEqual(image['file'], '-file {} {} {} {}') image.configure(file=self.testfile) self.assertEqualStrList(image['file'], ('-file', '', '', '',self.testfile)) self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) self.assertEqual(image['maskfile'], '-maskfile {} {} {} {}') image.configure(maskfile=self.testfile) self.assertEqualStrList(image['maskfile'], ('-maskfile', '', '', '', self.testfile)) def test_configure_background(self): image = tkinter.BitmapImage('::img::test', master=self.root) self.assertEqual(image['background'], '-background {} {} {} {}') image.configure(background='blue') self.assertEqual(image['background'], '-background {} {} {} blue') def test_configure_foreground(self): image = tkinter.BitmapImage('::img::test', master=self.root) self.assertEqual(image['foreground'], '-foreground {} {} #000000 #000000') image.configure(foreground='yellow') self.assertEqual(image['foreground'], '-foreground {} {} #000000 yellow') class PhotoImageTest(AbstractTkTest, unittest.TestCase): @classmethod def setUpClass(cls): AbstractTkTest.setUpClass.__func__(cls) cls.testfile = support.findfile('python.gif', subdir='imghdrdata') def create(self): return tkinter.PhotoImage('::img::test', master=self.root, file=self.testfile) def colorlist(self, *args): if tkinter.TkVersion >= 8.6 and self.wantobjects: return args else: return tkinter._join(args) def check_create_from_file(self, ext): testfile = support.findfile('python.' + ext, subdir='imghdrdata') image = tkinter.PhotoImage('::img::test', master=self.root, file=testfile) self.assertEqual(str(image), '::img::test') self.assertEqual(image.type(), 'photo') self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) self.assertEqual(image['data'], '') self.assertEqual(image['file'], testfile) self.assertIn('::img::test', self.root.image_names()) del image self.assertNotIn('::img::test', self.root.image_names()) def check_create_from_data(self, ext): testfile = support.findfile('python.' + ext, subdir='imghdrdata') with open(testfile, 'rb') as f: data = f.read() image = tkinter.PhotoImage('::img::test', master=self.root, data=data) self.assertEqual(str(image), '::img::test') self.assertEqual(image.type(), 'photo') self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) self.assertEqual(image['data'], data if self.wantobjects else data.decode('latin1')) self.assertEqual(image['file'], '') self.assertIn('::img::test', self.root.image_names()) del image self.assertNotIn('::img::test', self.root.image_names()) def test_create_from_ppm_file(self): self.check_create_from_file('ppm') def test_create_from_ppm_data(self): self.check_create_from_data('ppm') def test_create_from_pgm_file(self): self.check_create_from_file('pgm') def test_create_from_pgm_data(self): self.check_create_from_data('pgm') def test_create_from_gif_file(self): self.check_create_from_file('gif') def test_create_from_gif_data(self): self.check_create_from_data('gif') @requires_tcl(8, 6) def test_create_from_png_file(self): self.check_create_from_file('png') @requires_tcl(8, 6) def test_create_from_png_data(self): self.check_create_from_data('png') def test_configure_data(self): image = tkinter.PhotoImage('::img::test', master=self.root) self.assertEqual(image['data'], '') with open(self.testfile, 'rb') as f: data = f.read() image.configure(data=data) self.assertEqual(image['data'], data if self.wantobjects else data.decode('latin1')) self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) def test_configure_format(self): image = tkinter.PhotoImage('::img::test', master=self.root) self.assertEqual(image['format'], '') image.configure(file=self.testfile, format='gif') self.assertEqual(image['format'], ('gif',) if self.wantobjects else 'gif') self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) def test_configure_file(self): image = tkinter.PhotoImage('::img::test', master=self.root) self.assertEqual(image['file'], '') image.configure(file=self.testfile) self.assertEqual(image['file'], self.testfile) self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) def test_configure_gamma(self): image = tkinter.PhotoImage('::img::test', master=self.root) self.assertEqual(image['gamma'], '1.0') image.configure(gamma=2.0) self.assertEqual(image['gamma'], '2.0') def test_configure_width_height(self): image = tkinter.PhotoImage('::img::test', master=self.root) self.assertEqual(image['width'], '0') self.assertEqual(image['height'], '0') image.configure(width=20) image.configure(height=10) self.assertEqual(image['width'], '20') self.assertEqual(image['height'], '10') self.assertEqual(image.width(), 20) self.assertEqual(image.height(), 10) def test_configure_palette(self): image = tkinter.PhotoImage('::img::test', master=self.root) self.assertEqual(image['palette'], '') image.configure(palette=256) self.assertEqual(image['palette'], '256') image.configure(palette='3/4/2') self.assertEqual(image['palette'], '3/4/2') def test_blank(self): image = self.create() image.blank() self.assertEqual(image.width(), 16) self.assertEqual(image.height(), 16) self.assertEqual(image.get(4, 6), self.colorlist(0, 0, 0)) def test_copy(self): image = self.create() image2 = image.copy() self.assertEqual(image2.width(), 16) self.assertEqual(image2.height(), 16) self.assertEqual(image.get(4, 6), image.get(4, 6)) def test_subsample(self): image = self.create() image2 = image.subsample(2, 3) self.assertEqual(image2.width(), 8) self.assertEqual(image2.height(), 6) self.assertEqual(image2.get(2, 2), image.get(4, 6)) image2 = image.subsample(2) self.assertEqual(image2.width(), 8) self.assertEqual(image2.height(), 8) self.assertEqual(image2.get(2, 3), image.get(4, 6)) def test_zoom(self): image = self.create() image2 = image.zoom(2, 3) self.assertEqual(image2.width(), 32) self.assertEqual(image2.height(), 48) self.assertEqual(image2.get(8, 18), image.get(4, 6)) self.assertEqual(image2.get(9, 20), image.get(4, 6)) image2 = image.zoom(2) self.assertEqual(image2.width(), 32) self.assertEqual(image2.height(), 32) self.assertEqual(image2.get(8, 12), image.get(4, 6)) self.assertEqual(image2.get(9, 13), image.get(4, 6)) def test_put(self): image = self.create() image.put('{red green} {blue yellow}', to=(4, 6)) self.assertEqual(image.get(4, 6), self.colorlist(255, 0, 0)) self.assertEqual(image.get(5, 6), self.colorlist(0, 128 if tkinter.TkVersion >= 8.6 else 255, 0)) self.assertEqual(image.get(4, 7), self.colorlist(0, 0, 255)) self.assertEqual(image.get(5, 7), self.colorlist(255, 255, 0)) image.put((('#f00', '#00ff00'), ('#000000fff', '#ffffffff0000'))) self.assertEqual(image.get(0, 0), self.colorlist(255, 0, 0)) self.assertEqual(image.get(1, 0), self.colorlist(0, 255, 0)) self.assertEqual(image.get(0, 1), self.colorlist(0, 0, 255)) self.assertEqual(image.get(1, 1), self.colorlist(255, 255, 0)) def test_get(self): image = self.create() self.assertEqual(image.get(4, 6), self.colorlist(62, 116, 162)) self.assertEqual(image.get(0, 0), self.colorlist(0, 0, 0)) self.assertEqual(image.get(15, 15), self.colorlist(0, 0, 0)) self.assertRaises(tkinter.TclError, image.get, -1, 0) self.assertRaises(tkinter.TclError, image.get, 0, -1) self.assertRaises(tkinter.TclError, image.get, 16, 15) self.assertRaises(tkinter.TclError, image.get, 15, 16) def test_write(self): image = self.create() self.addCleanup(support.unlink, support.TESTFN) image.write(support.TESTFN) image2 = tkinter.PhotoImage('::img::test2', master=self.root, format='ppm', file=support.TESTFN) self.assertEqual(str(image2), '::img::test2') self.assertEqual(image2.type(), 'photo') self.assertEqual(image2.width(), 16) self.assertEqual(image2.height(), 16) self.assertEqual(image2.get(0, 0), image.get(0, 0)) self.assertEqual(image2.get(15, 8), image.get(15, 8)) image.write(support.TESTFN, format='gif', from_coords=(4, 6, 6, 9)) image3 = tkinter.PhotoImage('::img::test3', master=self.root, format='gif', file=support.TESTFN) self.assertEqual(str(image3), '::img::test3') self.assertEqual(image3.type(), 'photo') self.assertEqual(image3.width(), 2) self.assertEqual(image3.height(), 3) self.assertEqual(image3.get(0, 0), image.get(4, 6)) self.assertEqual(image3.get(1, 2), image.get(5, 8)) tests_gui = (MiscTest, BitmapImageTest, PhotoImageTest,) if __name__ == "__main__": support.run_unittest(*tests_gui) PK]*test_tkinter/test_misc.pyonu[ zfc@sddlZddlZddlmZmZddlmZeddeejfdYZ e fZ e dkree ndS(iN(trequirest run_unittest(tAbstractTkTesttguitMiscTestcBs#eZdZdZdZRS(cs|j}idd6ddfd}|j|jddd<|jd|}|j||jjdd|jj|jjdd|\}}|j|jdd|j t j |jj|WdQXdd<|jd|dd}|j|jdd |jd |}|j||jjdd|jj|jjdd|\}}|j ||jdd |j t j |jj|WdQXdS( Nitcountics||ds   o  PK]Mf}g}gwidget_tests.pyonu[ zfc@sVddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z ddl ZeZZe dddfkreZneoeeZdZeZe d dddfkreZneZd efd YZd efd YZd efdYZdefdYZdZdZdS(iN(tScale(tAbstractTkTestt tcl_versiont requires_tcltget_tk_patchlevelt pixels_convt tcl_obj_eqiii cCstt|S(N(tinttround(tx((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt int_roundsitAbstractWidgetTestcBseZeeZdZeZe dZ dZ de j dZeeddZdedZdZdZdZdZdd Zd Zd Zd Zd ZdZdZdZdZdZ RS(cCsEy |jSWn3tk r@t|jjdd|_|jSXdS(Nttktscaling(t_scalingtAttributeErrortfloattroottcall(tself((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR "s   cCsU|j r#|jr#tdkr#|St|trKdjt|j|St|S(Niit (ii( t _stringifyt wantobjectsRt isinstancettupletjointmapt_strtstr(Rtvalue((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR*s cCs*|||rdS|j|||dS(N(t assertEqual(Rtactualtexpectedtmsgteq((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt assertEqual21scCs|||<|tkr|}n|r4||}n|jsG|j rwt|trhtj|}qwt|}n|dkrt }n|j |||d||j |j ||d|t|t s|j |}|jt|d|j |d|d|ndS(NR"ii(t _sentinelRRRRttkintert_joinRtNoneRR#tcgetRt configureRtlen(RtwidgettnameRR tconvR"tt((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt checkParam6s"     c Cs||}|dk r(|j|}n|jtj}|||RARJRRRWR[R`RdRkRpRrRxR(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR s0            tStandardOptionsTestsc*BseZdbZd*Zd+Zd,Zd-Zd.Zd/Zd0Z d1Z d2Z d3Z d4Z d5Zd6Zd7Zd8Zd9Zejejd:kd;d<Zd=Zd>Zd?Zd@ZdAZdBZdCZdDZdEZ dFZ!dGZ"dHZ#dIZ$dJZ%dKZ&dLZ'dMZ(dNZ)dOZ*dPZ+dQZ,dRZ-dSZ.dTZ/dUZ0dVZ1dWZ2dXZ3dYZ4dZZ5d[Z6d\Z7e8d]d^d_Z9e8d]d^d`Z:daZ;RS(ctactivebackgroundtactiveborderwidthtactiveforegroundtanchorR{tbitmapRytcompoundtcursortdisabledforegroundtexportselectiontfontR}thighlightbackgroundthighlightcolorthighlightthicknessRotinsertbackgroundtinsertborderwidtht insertofftimet insertontimet insertwidthtjumptjustifytorienttpadxtpadytrelieft repeatdelaytrepeatintervaltselectbackgroundtselectborderwidthtselectforegroundtsetgridt takefocusttextt textvariablet troughcolort underlinet wraplengthtxscrollcommandtyscrollcommandcCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_activebackground s c Cs2|j}|j|ddddddddS(NRig?g333333@iiR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_activeborderwidths  cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_activeforegrounds c Cs;|j}|j|ddddddddd d dS( NRtntnetetsetstswtwtnwtcenter(RR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_anchors  cCsB|j}|j|dd|jkr>|j|dndS(NR{R|(RRRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_backgrounds cCs|j}|j|dd|j|ddtjjddd}|j|dd|d|jjjd d kod |jjks|j |dd d dndS(NRt questheadtgray50s python.xbmtsubdirt imghdrdatat@taquaR twindowingsystemtAppKitR?R4sbitmap "spam" not defined( RR/RRtfindfileRR Rt winfo_serverR8(RR+tfilename((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_bitmap%s c Csf|j}|j|dddddddd|jkrb|j|dddddddndS( NRyig?g@iiR=Rz(RRdR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_borderwidth2s   c Cs2|j}|j|ddddddddS(NRtbottomRtleftRVtrightttop(RR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_compound9s  cCs |j}|j|ddS(NR(RRW(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_cursor>s cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_disabledforegroundBs cCs |j}|j|ddS(NR(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_exportselectionFs cCs<|j}|j|dd|j|dddddS(NRs3-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*R<R4sfont "" doesn't exist(RR/R8(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_fontJs   cCsB|j}|j|dd|jkr>|j|dndS(NR}R~(RRRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_foregroundQs cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_highlightbackgroundWs cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_highlightcolor[s cCsQ|j}|j|dddddd|j|ddddd |jdS( NRig?g@iR=iR R-(RRdR/Rb(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_highlightthickness_s   tdarwins"crashes with Cocoa Tk (issue19733)cCs |j}|j|ddS(NRo(RRp(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_imagefs cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertbackgroundls c Cs2|j}|j|ddddddddS(NRig?g@iiR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertborderwidthps  cCs#|j}|j|dddS(NRid(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertofftimeus cCs#|j}|j|dddS(NRid(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertontimeys cCs,|j}|j|ddddddS(NRg?g@iR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_insertwidth}s cCs |j}|j|ddS(NR(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_jumps cCsH|j}|j|dddddd|j|dddddS( NRRRRR4s6bad justification "{}": must be left, right, or centerR<s:ambiguous justification "": must be left, right, or center(RR`R8(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_justifys  cCsC|j}|jt|d|j|j|ddddS(NRt horizontaltvertical(RRRtdefault_orientR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_orients c Cs8|j}|j|ddddddd|jdS(NRig@gffffff@it12mR-(RRdR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_padxs c Cs8|j}|j|ddddddd|jdS(NRig@gffffff@iRR-(RRdR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_padys cCs |j}|j|ddS(NR(RRk(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_reliefs cCs&|j}|j|ddddS(NRi i(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_repeatdelays cCs&|j}|j|ddddS(NRi i(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_repeatintervals cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectbackgrounds cCs,|j}|j|ddddddS(NRg?g@iR=(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectborderwidths cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectforegrounds cCs |j}|j|ddS(NR(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_setgrids cCs)|j}|j|dddddS(Ntstatetactivetdisabledtnormal(RR`(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_states cCs)|j}|j|dddddS(NRt0t1R<(RR;(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_takefocuss cCs&|j}|j|ddddS(NRR<s any string(RR;(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_texts cCs5|j}tj|j}|j|d|dS(NR(RR%t StringVarRRr(RR+Rq((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_textvariables cCs |j}|j|ddS(NR(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_troughcolors cCs)|j}|j|dddddS(NRiii (RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_underlines cCs#|j}|j|dddS(NRid(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_wraplengths cCs |j}|j|ddS(NR(RR[(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_xscrollcommands cCs |j}|j|ddS(NR(RR[(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_yscrollcommands cCs |j}|j|ddS(NRY(RR[(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_commands cCs |j}|j|ddS(Nt indicatoron(RRJ(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_indicatorons cCs |j}|j|ddS(Nt offrelief(RRk(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_offreliefs cCs |j}|j|ddS(Nt overrelief(RRk(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_overreliefs cCs |j}|j|ddS(Nt selectcolor(RRR(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectcolors cCs |j}|j|ddS(Nt selectimage(RRp(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_selectimages iicCs |j}|j|ddS(Nt tristateimage(RRp(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_tristateimages cCs#|j}|j|dddS(Nt tristatevaluet unknowable(RR/(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyttest_tristatevalues cCs5|j}tj|j}|j|d|dS(Ntvariable(RR%t DoubleVarRRr(RR+Rq((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_variables (*RRRRR{RRyRRRRRR}RRRRoRRRRRRRRRRRRRRRRRRRRRRRRR(<RRtSTANDARD_OPTIONSRRRRRRRRRRRRRRRRtunittesttskipIftsystplatformRRRRRRRRRRRRRRRRRRRRRRRR R R R R RRRRRRRRR(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyRs                                              tIntegerSizeTestscBseZdZdZRS(cCs)|j}|j|dddddS(Ntheightidii(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_height s cCs)|j}|j|dddddS(Ntwidthiini(RR>(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt test_width s (RRR'R)(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR%s tPixelSizeTestscBseZdZdZRS(c Cs2|j}|j|ddddddddS(NR&idgLY@gfffffY@iit3c(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR's c Cs2|j}|j|ddddddddS(NR(igfffff6y@gIy@init5i(RRd(RR+((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR)s (RRR'R)(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR*s csfd}|S(NcsxjD]}d|}t|s xkD]5}t||r0t|t||jPq0q0W|fd}||_t||q q WS(Nttest_cs1|j}||td|jfdS(NsOption "%s" is not tested in %s(RtAssertionErrorR(RtoptionR+(tcls(s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyR)s (Rthasattrtsetattrtgetattrtim_funcR(R0R/t methodnamet source_classR(tsource_classes(R0s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt decorators    ((R7R8((R7s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pytadd_standard_optionsscCs4tjjr0tj}dG|jddGHndS(Ns patchlevel =tinfot patchlevel(RRRR%tTclR(ttcl((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyt setUpModule3s  (R!R#tTkinterR%tttkRttest_ttk.supportRRRRRRttest.test_supportRRHtnoconvt noconv_methRRR RRRR$R RR%R*R9R>(((s0/usr/lib64/python2.7/lib-tk/test/widget_tests.pyts*   .         PK]שmPmPwidget_tests.pynu[# Common tests for test_tkinter/test_widgets.py and test_ttk/test_widgets.py import unittest import sys import Tkinter as tkinter from ttk import Scale from test_ttk.support import (AbstractTkTest, tcl_version, requires_tcl, get_tk_patchlevel, pixels_conv, tcl_obj_eq) import test.test_support noconv = noconv_meth = False if get_tk_patchlevel() < (8, 5, 11): noconv = str noconv_meth = noconv and staticmethod(noconv) def int_round(x): return int(round(x)) pixels_round = int_round if get_tk_patchlevel()[:3] == (8, 5, 11): # Issue #19085: Workaround a bug in Tk # http://core.tcl.tk/tk/info/3497848 pixels_round = int _sentinel = object() class AbstractWidgetTest(AbstractTkTest): _conv_pixels = staticmethod(pixels_round) _conv_pad_pixels = None _stringify = False @property def scaling(self): try: return self._scaling except AttributeError: self._scaling = float(self.root.call('tk', 'scaling')) return self._scaling def _str(self, value): if not self._stringify and self.wantobjects and tcl_version >= (8, 6): return value if isinstance(value, tuple): return ' '.join(map(self._str, value)) return str(value) def assertEqual2(self, actual, expected, msg=None, eq=object.__eq__): if eq(actual, expected): return self.assertEqual(actual, expected, msg) def checkParam(self, widget, name, value, expected=_sentinel, conv=False, eq=None): widget[name] = value if expected is _sentinel: expected = value if conv: expected = conv(expected) if self._stringify or not self.wantobjects: if isinstance(expected, tuple): expected = tkinter._join(expected) else: expected = str(expected) if eq is None: eq = tcl_obj_eq self.assertEqual2(widget[name], expected, eq=eq) self.assertEqual2(widget.cget(name), expected, eq=eq) # XXX if not isinstance(widget, Scale): t = widget.configure(name) self.assertEqual(len(t), 5) self.assertEqual2(t[4], expected, eq=eq) def checkInvalidParam(self, widget, name, value, errmsg=None, keep_orig=True): orig = widget[name] if errmsg is not None: errmsg = errmsg.format(value) with self.assertRaises(tkinter.TclError) as cm: widget[name] = value if errmsg is not None: self.assertEqual(str(cm.exception), errmsg) if keep_orig: self.assertEqual(widget[name], orig) else: widget[name] = orig with self.assertRaises(tkinter.TclError) as cm: widget.configure({name: value}) if errmsg is not None: self.assertEqual(str(cm.exception), errmsg) if keep_orig: self.assertEqual(widget[name], orig) else: widget[name] = orig def checkParams(self, widget, name, *values, **kwargs): for value in values: self.checkParam(widget, name, value, **kwargs) def checkIntegerParam(self, widget, name, *values, **kwargs): self.checkParams(widget, name, *values, **kwargs) self.checkInvalidParam(widget, name, '', errmsg='expected integer but got ""') self.checkInvalidParam(widget, name, '10p', errmsg='expected integer but got "10p"') self.checkInvalidParam(widget, name, 3.2, errmsg='expected integer but got "3.2"') def checkFloatParam(self, widget, name, *values, **kwargs): if 'conv' in kwargs: conv = kwargs.pop('conv') else: conv = float for value in values: self.checkParam(widget, name, value, conv=conv, **kwargs) self.checkInvalidParam(widget, name, '', errmsg='expected floating-point number but got ""') self.checkInvalidParam(widget, name, 'spam', errmsg='expected floating-point number but got "spam"') def checkBooleanParam(self, widget, name): for value in (False, 0, 'false', 'no', 'off'): self.checkParam(widget, name, value, expected=0) for value in (True, 1, 'true', 'yes', 'on'): self.checkParam(widget, name, value, expected=1) self.checkInvalidParam(widget, name, '', errmsg='expected boolean value but got ""') self.checkInvalidParam(widget, name, 'spam', errmsg='expected boolean value but got "spam"') def checkColorParam(self, widget, name, allow_empty=None, **kwargs): self.checkParams(widget, name, '#ff0000', '#00ff00', '#0000ff', '#123456', 'red', 'green', 'blue', 'white', 'black', 'grey', **kwargs) self.checkInvalidParam(widget, name, 'spam', errmsg='unknown color name "spam"') def checkCursorParam(self, widget, name, **kwargs): self.checkParams(widget, name, 'arrow', 'watch', 'cross', '',**kwargs) if tcl_version >= (8, 5): self.checkParam(widget, name, 'none') self.checkInvalidParam(widget, name, 'spam', errmsg='bad cursor spec "spam"') def checkCommandParam(self, widget, name): def command(*args): pass widget[name] = command self.assertTrue(widget[name]) self.checkParams(widget, name, '') def checkEnumParam(self, widget, name, *values, **kwargs): if 'errmsg' in kwargs: errmsg = kwargs.pop('errmsg') else: errmsg = None self.checkParams(widget, name, *values, **kwargs) if errmsg is None: errmsg2 = ' %s "{}": must be %s%s or %s' % ( name, ', '.join(values[:-1]), ',' if len(values) > 2 else '', values[-1]) self.checkInvalidParam(widget, name, '', errmsg='ambiguous' + errmsg2) errmsg = 'bad' + errmsg2 self.checkInvalidParam(widget, name, 'spam', errmsg=errmsg) def checkPixelsParam(self, widget, name, *values, **kwargs): if 'conv' in kwargs: conv = kwargs.pop('conv') else: conv = None if conv is None: conv = self._conv_pixels if 'keep_orig' in kwargs: keep_orig = kwargs.pop('keep_orig') else: keep_orig = True for value in values: expected = _sentinel conv1 = conv if isinstance(value, str): if conv1 and conv1 is not str: expected = pixels_conv(value) * self.scaling conv1 = int_round self.checkParam(widget, name, value, expected=expected, conv=conv1, **kwargs) self.checkInvalidParam(widget, name, '6x', errmsg='bad screen distance "6x"', keep_orig=keep_orig) self.checkInvalidParam(widget, name, 'spam', errmsg='bad screen distance "spam"', keep_orig=keep_orig) def checkReliefParam(self, widget, name): self.checkParams(widget, name, 'flat', 'groove', 'raised', 'ridge', 'solid', 'sunken') errmsg='bad relief "spam": must be '\ 'flat, groove, raised, ridge, solid, or sunken' if tcl_version < (8, 6): errmsg = None self.checkInvalidParam(widget, name, 'spam', errmsg=errmsg) def checkImageParam(self, widget, name): image = tkinter.PhotoImage(master=self.root, name='image1') self.checkParam(widget, name, image, conv=str) self.checkInvalidParam(widget, name, 'spam', errmsg='image "spam" doesn\'t exist') widget[name] = '' def checkVariableParam(self, widget, name, var): self.checkParam(widget, name, var, conv=str) def assertIsBoundingBox(self, bbox): self.assertIsNotNone(bbox) self.assertIsInstance(bbox, tuple) if len(bbox) != 4: self.fail('Invalid bounding box: %r' % (bbox,)) for item in bbox: if not isinstance(item, int): self.fail('Invalid bounding box: %r' % (bbox,)) break def test_keys(self): widget = self.create() keys = widget.keys() # XXX if not isinstance(widget, Scale): self.assertEqual(sorted(keys), sorted(widget.configure())) for k in keys: widget[k] # Test if OPTIONS contains all keys if test.test_support.verbose: aliases = { 'bd': 'borderwidth', 'bg': 'background', 'fg': 'foreground', 'invcmd': 'invalidcommand', 'vcmd': 'validatecommand', } keys = set(keys) expected = set(self.OPTIONS) for k in sorted(keys - expected): if not (k in aliases and aliases[k] in keys and aliases[k] in expected): print('%s.OPTIONS doesn\'t contain "%s"' % (self.__class__.__name__, k)) class StandardOptionsTests(object): STANDARD_OPTIONS = ( 'activebackground', 'activeborderwidth', 'activeforeground', 'anchor', 'background', 'bitmap', 'borderwidth', 'compound', 'cursor', 'disabledforeground', 'exportselection', 'font', 'foreground', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'image', 'insertbackground', 'insertborderwidth', 'insertofftime', 'insertontime', 'insertwidth', 'jump', 'justify', 'orient', 'padx', 'pady', 'relief', 'repeatdelay', 'repeatinterval', 'selectbackground', 'selectborderwidth', 'selectforeground', 'setgrid', 'takefocus', 'text', 'textvariable', 'troughcolor', 'underline', 'wraplength', 'xscrollcommand', 'yscrollcommand', ) def test_activebackground(self): widget = self.create() self.checkColorParam(widget, 'activebackground') def test_activeborderwidth(self): widget = self.create() self.checkPixelsParam(widget, 'activeborderwidth', 0, 1.3, 2.9, 6, -2, '10p') def test_activeforeground(self): widget = self.create() self.checkColorParam(widget, 'activeforeground') def test_anchor(self): widget = self.create() self.checkEnumParam(widget, 'anchor', 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center') def test_background(self): widget = self.create() self.checkColorParam(widget, 'background') if 'bg' in self.OPTIONS: self.checkColorParam(widget, 'bg') def test_bitmap(self): widget = self.create() self.checkParam(widget, 'bitmap', 'questhead') self.checkParam(widget, 'bitmap', 'gray50') filename = test.test_support.findfile('python.xbm', subdir='imghdrdata') self.checkParam(widget, 'bitmap', '@' + filename) # Cocoa Tk widgets don't detect invalid -bitmap values # See https://core.tcl.tk/tk/info/31cd33dbf0 if not ('aqua' in self.root.tk.call('tk', 'windowingsystem') and 'AppKit' in self.root.winfo_server()): self.checkInvalidParam(widget, 'bitmap', 'spam', errmsg='bitmap "spam" not defined') def test_borderwidth(self): widget = self.create() self.checkPixelsParam(widget, 'borderwidth', 0, 1.3, 2.6, 6, -2, '10p') if 'bd' in self.OPTIONS: self.checkPixelsParam(widget, 'bd', 0, 1.3, 2.6, 6, -2, '10p') def test_compound(self): widget = self.create() self.checkEnumParam(widget, 'compound', 'bottom', 'center', 'left', 'none', 'right', 'top') def test_cursor(self): widget = self.create() self.checkCursorParam(widget, 'cursor') def test_disabledforeground(self): widget = self.create() self.checkColorParam(widget, 'disabledforeground') def test_exportselection(self): widget = self.create() self.checkBooleanParam(widget, 'exportselection') def test_font(self): widget = self.create() self.checkParam(widget, 'font', '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') self.checkInvalidParam(widget, 'font', '', errmsg='font "" doesn\'t exist') def test_foreground(self): widget = self.create() self.checkColorParam(widget, 'foreground') if 'fg' in self.OPTIONS: self.checkColorParam(widget, 'fg') def test_highlightbackground(self): widget = self.create() self.checkColorParam(widget, 'highlightbackground') def test_highlightcolor(self): widget = self.create() self.checkColorParam(widget, 'highlightcolor') def test_highlightthickness(self): widget = self.create() self.checkPixelsParam(widget, 'highlightthickness', 0, 1.3, 2.6, 6, '10p') self.checkParam(widget, 'highlightthickness', -2, expected=0, conv=self._conv_pixels) @unittest.skipIf(sys.platform == 'darwin', 'crashes with Cocoa Tk (issue19733)') def test_image(self): widget = self.create() self.checkImageParam(widget, 'image') def test_insertbackground(self): widget = self.create() self.checkColorParam(widget, 'insertbackground') def test_insertborderwidth(self): widget = self.create() self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, 2.6, 6, -2, '10p') def test_insertofftime(self): widget = self.create() self.checkIntegerParam(widget, 'insertofftime', 100) def test_insertontime(self): widget = self.create() self.checkIntegerParam(widget, 'insertontime', 100) def test_insertwidth(self): widget = self.create() self.checkPixelsParam(widget, 'insertwidth', 1.3, 2.6, -2, '10p') def test_jump(self): widget = self.create() self.checkBooleanParam(widget, 'jump') def test_justify(self): widget = self.create() self.checkEnumParam(widget, 'justify', 'left', 'right', 'center', errmsg='bad justification "{}": must be ' 'left, right, or center') self.checkInvalidParam(widget, 'justify', '', errmsg='ambiguous justification "": must be ' 'left, right, or center') def test_orient(self): widget = self.create() self.assertEqual(str(widget['orient']), self.default_orient) self.checkEnumParam(widget, 'orient', 'horizontal', 'vertical') def test_padx(self): widget = self.create() self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, -2, '12m', conv=self._conv_pad_pixels) def test_pady(self): widget = self.create() self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, -2, '12m', conv=self._conv_pad_pixels) def test_relief(self): widget = self.create() self.checkReliefParam(widget, 'relief') def test_repeatdelay(self): widget = self.create() self.checkIntegerParam(widget, 'repeatdelay', -500, 500) def test_repeatinterval(self): widget = self.create() self.checkIntegerParam(widget, 'repeatinterval', -500, 500) def test_selectbackground(self): widget = self.create() self.checkColorParam(widget, 'selectbackground') def test_selectborderwidth(self): widget = self.create() self.checkPixelsParam(widget, 'selectborderwidth', 1.3, 2.6, -2, '10p') def test_selectforeground(self): widget = self.create() self.checkColorParam(widget, 'selectforeground') def test_setgrid(self): widget = self.create() self.checkBooleanParam(widget, 'setgrid') def test_state(self): widget = self.create() self.checkEnumParam(widget, 'state', 'active', 'disabled', 'normal') def test_takefocus(self): widget = self.create() self.checkParams(widget, 'takefocus', '0', '1', '') def test_text(self): widget = self.create() self.checkParams(widget, 'text', '', 'any string') def test_textvariable(self): widget = self.create() var = tkinter.StringVar(self.root) self.checkVariableParam(widget, 'textvariable', var) def test_troughcolor(self): widget = self.create() self.checkColorParam(widget, 'troughcolor') def test_underline(self): widget = self.create() self.checkIntegerParam(widget, 'underline', 0, 1, 10) def test_wraplength(self): widget = self.create() self.checkPixelsParam(widget, 'wraplength', 100) def test_xscrollcommand(self): widget = self.create() self.checkCommandParam(widget, 'xscrollcommand') def test_yscrollcommand(self): widget = self.create() self.checkCommandParam(widget, 'yscrollcommand') # non-standard but common options def test_command(self): widget = self.create() self.checkCommandParam(widget, 'command') def test_indicatoron(self): widget = self.create() self.checkBooleanParam(widget, 'indicatoron') def test_offrelief(self): widget = self.create() self.checkReliefParam(widget, 'offrelief') def test_overrelief(self): widget = self.create() self.checkReliefParam(widget, 'overrelief') def test_selectcolor(self): widget = self.create() self.checkColorParam(widget, 'selectcolor') def test_selectimage(self): widget = self.create() self.checkImageParam(widget, 'selectimage') @requires_tcl(8, 5) def test_tristateimage(self): widget = self.create() self.checkImageParam(widget, 'tristateimage') @requires_tcl(8, 5) def test_tristatevalue(self): widget = self.create() self.checkParam(widget, 'tristatevalue', 'unknowable') def test_variable(self): widget = self.create() var = tkinter.DoubleVar(self.root) self.checkVariableParam(widget, 'variable', var) class IntegerSizeTests(object): def test_height(self): widget = self.create() self.checkIntegerParam(widget, 'height', 100, -100, 0) def test_width(self): widget = self.create() self.checkIntegerParam(widget, 'width', 402, -402, 0) class PixelSizeTests(object): def test_height(self): widget = self.create() self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '3c') def test_width(self): widget = self.create() self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i') def add_standard_options(*source_classes): # This decorator adds test_xxx methods from source classes for every xxx # option in the OPTIONS class attribute if they are not defined explicitly. def decorator(cls): for option in cls.OPTIONS: methodname = 'test_' + option if not hasattr(cls, methodname): for source_class in source_classes: if hasattr(source_class, methodname): setattr(cls, methodname, getattr(source_class, methodname).im_func) break else: def test(self, option=option): widget = self.create() widget[option] raise AssertionError('Option "%s" is not tested in %s' % (option, cls.__name__)) test.__name__ = methodname setattr(cls, methodname, test) return cls return decorator def setUpModule(): if test.test_support.verbose: tcl = tkinter.Tcl() print 'patchlevel =', tcl.call('info', 'patchlevel') PK]]W>m _hawkey_test.sonuȯELF>9@z@8 @h`h` gg g ( 0 jj j pp888$$H`H`H` StdH`H`H` PtdVVVTTQtdRtdgg g @@GNU$|Ŏ{,&X;u%; E AE(P`# HoH)B;=@CEGIJLMNOQRUWXYZ[`beghlosuxy{溔6`FI:ls֏tAi+8Чn)thȋ_)rSm;3{ &WņpSNj=6H UKmK((3},A I:8fA EİfhsI:-6y< GGqX2AR|UqmaguUKK煂rBp,}LabBeԒKBEIX>ON6hÔ>R<" =" DU " `I" B"" >1 " N !PV|" EU" @=" @U!hi P @S- !Hh l !g  `Q" =9? !i P" `Et" `Cn" =6" @R < !0h " `D!" = !0V" BW !pU " I'" Ek" DUL" = " >RE!j P !UL!h Pbp " @A" ?Cnp " pF!i Pq" ?C !g #" `C" `=T !h  !Xj X " JI !U !h [p i !pVY " J'" =9 " I." @Rw" P= @" B" >@ !`h  !V " 0M__gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalize_ZNK6libdnf6Option11getPriorityEv_ZNK6libdnf6Option5emptyEv_ZN6libdnf10OptionBool5resetEv_ZN6libdnf13OptionSecondsD2Ev_ZTVN6libdnf12OptionNumberIiEE__gxx_personality_v0_ZN6libdnf13OptionSecondsD1Ev_ZN6libdnf10OptionBoolD2Ev_ZN6libdnf10OptionBoolD1Ev_Z14sack_converterP7_objectPP8_DnfSackPyArg_ParseTuplednf_sack_get_poolglob_for_repofiles_Z14repoToPyObjectPN6libdnf4RepoE__stack_chk_fail_Z16sackFromPyObjectP7_objectload_repo_Py_NoneStructPyExc_IOErrorPyErr_SetStringPyExc_TypeError_ZN6libdnf10OptionBoolD0Ev_ZdlPv_ZN6libdnf13OptionSecondsD0Ev_ZN6libdnf12OptionStringD2Ev_ZTVN6libdnf12OptionStringE_ZN6libdnf12OptionStringD1Ev_ZNK6libdnf10OptionBool5cloneEv_Znwm_ZTVN6libdnf10OptionBoolE_ZNK6libdnf13OptionSeconds5cloneEv_ZTVN6libdnf13OptionSecondsE_Unwind_Resume_ZNK6libdnf16OptionStringList14getValueStringB5cxx11Ev_ZNK6libdnf16OptionStringList8toStringERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE_ZNK6libdnf10OptionBool14getValueStringB5cxx11Ev_ZNK6libdnf10OptionBool8toStringB5cxx11Eb_ZSt20__throw_length_errorPKc_ZN6libdnf10OptionPathD2Ev_ZN6libdnf10OptionPathD1Ev_ZN6libdnf12OptionStringD0Ev_ZN6libdnf10OptionPathD0Ev_ZN6libdnf16OptionStringListD0Ev_ZTVN6libdnf16OptionStringListE_ZN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED0Ev_ZTVN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE_ZN6libdnf16OptionStringListD2Ev_ZN6libdnf16OptionStringListD1Ev_ZN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED2Ev_ZN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED1EvPyInit__hawkey_testPyModule_Create2PyModule_AddIntConstantPyModule_AddStringConstant_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED2Ev_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED1Ev_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_assignERKS4_memcpy_ZN6libdnf12OptionString5resetEv_ZN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE5resetEv_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag_ZSt19__throw_logic_errorPKc_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEaSERKS7__ZSt17__throw_bad_allocv__cxa_begin_catch__cxa_rethrow__cxa_end_catch_ZN6libdnf16OptionStringList5resetEv_ZNK6libdnf12OptionString14getValueStringB5cxx11Ev_ZNK6libdnf12OptionString8getValueB5cxx11Ev_ZNK6libdnf10OptionPath5cloneEv_ZTVN6libdnf10OptionPathE_ZNK6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE14getValueStringEv_ZNK6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE5cloneEv_ZNK6libdnf12OptionString5cloneEv_ZNK6libdnf16OptionStringList5cloneEv_ZTSN6libdnf6OptionE_ZTIN6libdnf6OptionE_ZTVN10__cxxabiv117__class_type_infoE_ZTSN6libdnf10OptionBoolE_ZTIN6libdnf10OptionBoolE_ZTVN10__cxxabiv120__si_class_type_infoE_ZTSN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE_ZTIN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE_ZTSN6libdnf12OptionStringE_ZTIN6libdnf12OptionStringE_ZTSN6libdnf10OptionPathE_ZTIN6libdnf10OptionPathE_ZTSN6libdnf13OptionSecondsE_ZTIN6libdnf13OptionSecondsE_ZTIN6libdnf12OptionNumberIiEE_ZTSN6libdnf16OptionStringListE_ZTIN6libdnf16OptionStringListE_ZTVN6libdnf6OptionE__cxa_pure_virtual_ZN6libdnf10OptionBool3setENS_6Option8PriorityERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_ZN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE3setENS_6Option8PriorityERKS6__ZN6libdnf12OptionString3setENS_6Option8PriorityERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_ZN6libdnf10OptionPath3setENS_6Option8PriorityERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_ZN6libdnf13OptionSeconds3setENS_6Option8PriorityERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_ZNK6libdnf12OptionNumberIiE14getValueStringB5cxx11Ev_ZN6libdnf12OptionNumberIiE5resetEv_ZN6libdnf16OptionStringList3setENS_6Option8PriorityERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_ZN6libdnf16OptionStringList3setENS_6Option8PriorityERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EE_hawkey.sohy_repo_createpool_tmpjoinwordexphy_repo_set_stringwordfreehy_repo_free_ZN6libdnf11repoGetImplEPNS_4RepoE_ZN6libdnf4Repo4Impl17attachLibsolvRepoEP6s_Repofopen64testcase_add_testtagsfclosepool_set_installedlibpython3.6m.so.1.0libdnf.so.2libdl.so.2librepo.so.0libglib-2.0.so.0libgio-2.0.so.0libgobject-2.0.so.0libsolv.so.1libsolvext.so.1libcrypto.so.1.1librpm.so.8librpmio.so.8libsqlite3.so.0libjson-c.so.4libmodulemd.so.2libsmartcols.so.1libgpgme.so.11libgpg-error.so.0libselinux.so.1libstdc++.so.6libm.so.6libgcc_s.so.1libc.so.6_edata__bss_start_end_hawkey_test.soGCC_3.0SOLV_1.0CXXABI_1.3GLIBCXX_3.4GLIBC_2.4GLIBC_2.14GLIBC_2.2.5 C P&y | 'o '*0ӯkt)Qii ui g `:g  :g g (p  U@p p p Up ;p  Up p:g g Yg ,h ,h ,0h ,Hh ,`h ,g og Kh K(h Kph Kh Kh ` h {8h W@h ppi pPh DXh hh rh 1h 1h 1h 1h Fh F0i Fi Fi F j Fpj Fh wh wHi wi wi w8j wj wh ih yh $h di ki >i ] i l(i n8i @i sPi [Xi P`i xxi |i 0i ui ui Oi Oi ^i Gi Ti Zi +i Rj ;j Jj B(j 40j 7@j :Hj tPj Q`j zhj Cxj j hj @j Aj cj o o  o  o o mo o o Ho  o 'o go No ao 2o _p !8n @n Hn EPn Xn `n hn pn  xn  n  n \n Ln  n In n n n n n n n n n n o "o #o %o & o ((o )0o *8o -@o .Ho /Po UXo 3`o 5ho fpo 6xo 8o 9HHa; HtH59 %9 hhhhhhhhqhah Qh Ah 1h !h hhhhhhhhhhqhahQhAh1h!hhhh h!h"h#h$h%h&h'qh(ah)Q%7 D%7 D% 7 D%7 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%6 D%}6 D%u6 D%m6 D%e6 D%]6 D%U6 D%M6 D%E6 D%=6 D%56 D%-6 D%%6 D%6 D%6 D% 6 D%6 D%5 D%5 D%5 D%5 D%5 D%5 DH=17 H*7 H9tH5 Ht H=7 H56 H)HHH?HHtH5 HtfD=6 u+UH=b5 Ht H=- d6 ]wUHH5SH(H5 dH%(HD$1HL$LL$I1t)H|$Hl$H$HHHH2H\$dH3%(uH([]fDAUHH5ATUS1H8dH%(HD$(1HL$HT$HD$LL$ LD$ HD$HD$ tIH|$HHt|Dl$ Ld$ HHl$DLHHDu0H!4 HHt$(dH34%(HuJH8[]A\A]H3 H5H1H8fDH3 H5 H8fHHxTH9v#HH9sHx&H7H~Zf.HxGHHH$PH='SH=o3 HHH5HH5HH5HrH5H^HH5H(HH5HHH5HH[GGG G G!f.H2 HHHG HtHHHHfDf.H1 SHHHHG HtHHH[Zf.H1 SHHHHXHChH9t(H{8HCHH9tH{H H9t [[f.@SH(SHKPHE1 HHHHHSHPS fP [ATUH@SHËEHC CH0 HHHE Ht"LcHuLHE(HC(HE HC HE0HC0HE8HC8H0 HHH[]A\HHC Ht LLHH^f.@SHVPHHdH%(HD$1{HL$dH3 %(u HH[Mf.SHHV!dH%(HD$1;HL$dH3 %(u HH[f.H/ SHHHHXHChH9t(H{8HCHH9tH{H H9t [[f.@H5/ SHHHHXHChH9tH{8HCHH9tH{HC H9tH[f.H. SHHHHXHChH9thH{8HCHH9tVH{HC H9tDH[;f.H]. ATUSLgXHHHoPHI9t)f.H}HEH9tH I9uHkPHtHLc@Hk8I9t&H}HEH9tH I9uHk8HtHH{HC H9tH[]A\vfDH- ATUHSHHHhHCxH9tEH{HHCXH9t3Lc8Hk0I9t%fDH}HEH9tH I9uHk0HtHHC HtH{HH[]A\H, ATUSLgXHHHoPHI9t)f.H}HEH9tH I9uHkPHtHtLc@Hk8I9t&H}HEH9tNH I9uHk8HtH4H{H H9t[]A\fD[]A\Hm, ATUHSHHHhHCxH9tH{HHCXH9tLc8Hk0I9t%fDH}HEH9tH I9uHk0HtHHC HtH{H[]A\ATUSHoHH9t*IfH;HCH9t?H H9uI$Ht H[]A\![]A\f.AVAUATUSHdH%(HD$1H9t1L'LwHIHnM9HwH9rXHu3HkA,HD$dH3%(H[]A\A]A^fIuHtVLHkL#fDHH,$H;II9tTH$L#HCHtfifDA$L#^f.fSHw8HHXC C[SHwHHHhC [fATIUHSHdH%(HD$1Ht HL)HH$HwPHEHu6A$H$HEH]HD$dH3%(uYH[]A\fDHtfH1H$HEHUHLH H$HEH=AWAVAUATIUSH(Ht$H9LnHL7HWLH)L)HHHD$HHH9HGHHD$L)HHIH9H|$~5HLH I =HuL9t$tI>IFH9tOI L9t$uLt$M4$Mt$H(L[]A\A]A^A_@H7HH9,H|$IML9t-IGLIH3HSHH I I9uMl$I$I9t"@H;HCH9tH I9uI$HtHM4$Lt$Mt$7fH~<HLH I %IuID$HL$M4$LiHHD$L)HHHl$Lt$L9fHEHHEH3HSHH H I9u@E1HH;l$uCHLxL9u,.HD$H8HH9tHD$ HH;HCH9tfH HHHMtL2HHyfSHw8HHPC [fSHHHSHHH0HPHH[fAUATUHSHHuHUHH% Lc H{HHLcHHEHC0Hu8HU@LkHH{8E0Lk8HC0 HuXHU`HChH{XHCXHH% HHExfCxHH[]A\A]H.H HH{8I9tH{I9tHH&fDHGSHHHFhHVpHH^H[fAWAVAUATUHSHHËEHC CH$ HHHCHH$HE HtHuHE(HC(HE HC L}8Le0HC0HC0HD$MHC8M)HC@LHHH9LL}8Le0IMLs0Lk@MLs8M9t3f.IELIEI4$IT$HDI I M9uHuHHUPLcXH{HLk8HLcHHuhHUpHCxH{hHChHHH[]A\A]A^A_fE1WH4HDHpHYmTH{0HtHC Ht'H<$HHC HtH<$HHHH{HI9tH|$HDM9uI>IFH9tYI H^AUATUHxSHEHuHUHHc" Lc H{HHLcHHEHCHu8HU@LkHH{8E0Lk8HC0HuXHU`HChH{XHCXHqHH[]A\A]H.H HH{8I9tzH{I9tlHdHf.fAWAVAUATUHhSHQHuHUHËEH{HCHJ! HHHC H$HCL}@E0HC8Le8HC@MC0HC8M)HD$LHCHH'HH91LL}@Le8IMLs8LkHMLs@M9t3f.IELIEI4$IT$HI I M9uLk@LmXHEPHCPMHCXI)HC`LHHH9LILmXHEPMLcPLcXLs`L9t^HMIFLIHuHUHvH I I9uLsXHH[]A\A]A^A_E1E1Mni!HAH|QH8H M9H{8HtH{H9<$t HHZHM9u$xSH{PHtH|$ I<$ID$H9tI I>IFH9tI \HHUHHxTH9v#HH9sHx&H7H~zf.HxgHHHDPH=GAUIATIHUSH(dH%(HD$1H1LLHH1HH]MH<$BHD$HHe1LLHHHH<$HD$HH1LLHsEHHH<$HD$HH1LLH:HHyumH<$tfHD$HH1LLH HH5u)H<$t"HD$H߾HEHHH1HL$dH3 %(Hu H([]A\A]AVIAUAATIHUHS@HLH2HHHHHdH5RLHøHt1HH EuH1[]A\A]A^HLHHO&ssOssiExpected a DnfSack *object.Can not load a testing repo.basic_string::_M_createEXPECT_SYSTEM_NSOLVABLESEXPECT_MAIN_NSOLVABLESEXPECT_UPDATES_NSOLVABLESEXPECT_YUM_NSOLVABLESx86_64FIXED_ARCH/tmp/hawkeyXXXXXXUNITTEST_DIRyum/repodata/YUM_DIR_SUFFIX_hawkey_testload_repoglob_for_repofilesbasic_string::_M_construct null not validN6libdnf6OptionEN6libdnf10OptionBoolEN6libdnf10OptionEnumINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEN6libdnf12OptionStringEN6libdnf10OptionPathEN6libdnf13OptionSecondsEN6libdnf16OptionStringListE/repomd.xml/*primary.xml.gz/*filelists.xml.gz/*prestodelta.xml.gz/*updateinfo.xml.gzr;T)xp(<h(Xhx (8Hl8X,\xxx\xx4PH8<xXzRx $FJ w?:*3$"D\p zPLRx  $9 _R(DEKD@n AAA 8 FLA A(F` (A ABBH P< 86cLeXRL| H A@Ez0, FAI q ABA HCEK i DA tCEG m DA <i]TRL| H AtULD ULD(PMAA AB,DMAE AB4TMAA  ABK AAB,MAE ABpE40UFAA  ABF AAB@XFBB A(A0D@^ 0A(A BBBJ EW$EX0@FDD D0c  AABG LsFBB B(D0A8D` 8D0A(B BBBE XEX\.Eh<hp/FBA I(D0 (D ABBA <0'I]LDIFBB B(A0I8DP? 8D0A(B BBBJ <DFBA I(D0} (D ABBA PTFBB B(A0I8DP 8D0A(B BBBD <pi]8TFEG A(DP (A ABBA <lFEE G(D0j (A BBBD MA7x}Kn=2[KnI>QGNU`: :g "-:K[o|*9CQs @4 Sg g o`P v  n P0H& oox%oo~$o j p44444444455 505@5P5`5p55555555566 606@6P6`6p6666666667 Up U; Up:GA$3a1@4S GA$3p1113p:PGA*GA$annobin gcc 8.5.0 20210514GA$plugin name: gcc-annobinGA$running gcc 8.5.0 20210514GA*GA*GA! GA*FORTIFYGA+GLIBCXX_ASSERTIONS GA*GOW*GA*cf_protectionGA+omit_frame_pointerGA+stack_clashGA!stack_realign GA$3p1113PSGA*GA$annobin gcc 8.5.0 20210514GA$plugin name: gcc-annobinGA$running gcc 8.5.0 20210514GA*GA*GA! GA*FORTIFYGA+GLIBCXX_ASSERTIONS GA*GOW*GA*cf_protectionGA+omit_frame_pointerGA+stack_clashGA!stack_realign GA*FORTIFYp:YQGA+GLIBCXX_ASSERTIONS_hawkey_test.so-0.63.0-21.el8_10.alma.1.x86_64.debug: K7zXZִF!t/]?Eh=ڊ2N*> XP{~XoYBϮعSE;Hdl13Nv+ܲRg1 7H :K]XM],!PGlyn\0Xjl] 0uj?"(oȁKqj:nP3 xRVĶ%I~:NUt63t.`@elM=GE$~#xnw4sy$A INX'7>_2 ?؀F=CADz)$/){''}.hex end def hash return @hash end def ==(other) case(other) when ProcWrapper return @a_proc == other.to_proc else return super end end alias :eql? :== def to_proc return @a_proc end end end end end PK0G]unit/util/backtracefilter.rbnu[module Test module Unit module Util module BacktraceFilter TESTUNIT_FILE_SEPARATORS = %r{[\\/:]} TESTUNIT_PREFIX = __FILE__.split(TESTUNIT_FILE_SEPARATORS)[0..-3] TESTUNIT_RB_FILE = /\.rb\Z/ def filter_backtrace(backtrace, prefix=nil) return ["No backtrace"] unless(backtrace) split_p = if(prefix) prefix.split(TESTUNIT_FILE_SEPARATORS) else TESTUNIT_PREFIX end match = proc do |e| split_e = e.split(TESTUNIT_FILE_SEPARATORS)[0, split_p.size] next false unless(split_e[0..-2] == split_p[0..-2]) split_e[-1].sub(TESTUNIT_RB_FILE, '') == split_p[-1] end return backtrace unless(backtrace.detect(&match)) found_prefix = false new_backtrace = backtrace.reverse.reject do |e| if(match[e]) found_prefix = true true elsif(found_prefix) false else true end end.reverse new_backtrace = (new_backtrace.empty? ? backtrace : new_backtrace) new_backtrace = new_backtrace.reject(&match) new_backtrace.empty? ? backtrace : new_backtrace end end end end end PK0G]ݮ?3G3Gunit/assertions.rbnu[# Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/assertionfailederror' require 'test/unit/util/backtracefilter' module Test module Unit ## # Test::Unit::Assertions contains the standard Test::Unit assertions. # Assertions is included in Test::Unit::TestCase. # # To include it in your own code and use its functionality, you simply # need to rescue Test::Unit::AssertionFailedError. Additionally you may # override add_assertion to get notified whenever an assertion is made. # # Notes: # * The message to each assertion, if given, will be propagated with the # failure. # * It is easy to add your own assertions based on assert_block(). # # = Example Custom Assertion # # def deny(boolean, message = nil) # message = build_message message, ' is not false or nil.', boolean # assert_block message do # not boolean # end # end module Assertions ## # The assertion upon which all other assertions are based. Passes if the # block yields true. # # Example: # assert_block "Couldn't do the thing" do # do_the_thing # end public def assert_block(message="assert_block failed.") # :yields: _wrap_assertion do if (! yield) raise AssertionFailedError.new(message.to_s) end end end ## # Asserts that +boolean+ is not false or nil. # # Example: # assert [1, 2].include?(5) public def assert(boolean, message=nil) _wrap_assertion do assert_block("assert should not be called with a block.") { !block_given? } assert_block(build_message(message, " is not true.", boolean)) { boolean } end end ## # Passes if +expected+ == +actual. # # Note that the ordering of arguments is important, since a helpful # error message is generated when this one fails that tells you the # values of expected and actual. # # Example: # assert_equal 'MY STRING', 'my string'.upcase public def assert_equal(expected, actual, message=nil) full_message = build_message(message, < expected but was . EOT assert_block(full_message) { expected == actual } end private def _check_exception_class(args) # :nodoc: args.partition do |klass| next if klass.instance_of?(Module) assert(Exception >= klass, "Should expect a class of exception, #{klass}") true end end private def _expected_exception?(actual_exception, exceptions, modules) # :nodoc: exceptions.include?(actual_exception.class) or modules.any? {|mod| actual_exception.is_a?(mod)} end ## # Passes if the block raises one of the given exceptions. # # Example: # assert_raise RuntimeError, LoadError do # raise 'Boom!!!' # end public def assert_raise(*args) _wrap_assertion do if Module === args.last message = "" else message = args.pop end exceptions, modules = _check_exception_class(args) expected = args.size == 1 ? args.first : args actual_exception = nil full_message = build_message(message, " exception expected but none was thrown.", expected) assert_block(full_message) do begin yield rescue Exception => actual_exception break end false end full_message = build_message(message, " exception expected but was\n?", expected, actual_exception) assert_block(full_message) {_expected_exception?(actual_exception, exceptions, modules)} actual_exception end end ## # Alias of assert_raise. # # Will be deprecated in 1.9, and removed in 2.0. public def assert_raises(*args, &block) assert_raise(*args, &block) end ## # Passes if +object+ .instance_of? +klass+ # # Example: # assert_instance_of String, 'foo' public def assert_instance_of(klass, object, message="") _wrap_assertion do assert_equal(Class, klass.class, "assert_instance_of takes a Class as its first argument") full_message = build_message(message, < expected to be an instance of but was . EOT assert_block(full_message){object.instance_of?(klass)} end end ## # Passes if +object+ is nil. # # Example: # assert_nil [1, 2].uniq! public def assert_nil(object, message="") assert_equal(nil, object, message) end ## # Passes if +object+ .kind_of? +klass+ # # Example: # assert_kind_of Object, 'foo' public def assert_kind_of(klass, object, message="") _wrap_assertion do assert(klass.kind_of?(Module), "The first parameter to assert_kind_of should be a kind_of Module.") full_message = build_message(message, "\nexpected to be kind_of\\?\n but was\n.", object, klass, object.class) assert_block(full_message){object.kind_of?(klass)} end end ## # Passes if +object+ .respond_to? +method+ # # Example: # assert_respond_to 'bugbear', :slice public def assert_respond_to(object, method, message="") _wrap_assertion do full_message = build_message(nil, "\ngiven as the method name argument to #assert_respond_to must be a Symbol or #respond_to\\?(:to_str).", method) assert_block(full_message) do method.kind_of?(Symbol) || method.respond_to?(:to_str) end full_message = build_message(message, < of type expected to respond_to\\?. EOT assert_block(full_message) { object.respond_to?(method) } end end ## # Passes if +string+ =~ +pattern+. # # Example: # assert_match(/\d+/, 'five, 6, seven') public def assert_match(pattern, string, message="") _wrap_assertion do pattern = case(pattern) when String Regexp.new(Regexp.escape(pattern)) else pattern end full_message = build_message(message, " expected to be =~\n.", string, pattern) assert_block(full_message) { string =~ pattern } end end ## # Passes if +actual+ .equal? +expected+ (i.e. they are the same # instance). # # Example: # o = Object.new # assert_same o, o public def assert_same(expected, actual, message="") full_message = build_message(message, < with id expected to be equal\\? to with id . EOT assert_block(full_message) { actual.equal?(expected) } end ## # Compares the +object1+ with +object2+ using +operator+. # # Passes if object1.__send__(operator, object2) is true. # # Example: # assert_operator 5, :>=, 4 public def assert_operator(object1, operator, object2, message="") _wrap_assertion do full_message = build_message(nil, "\ngiven as the operator for #assert_operator must be a Symbol or #respond_to\\?(:to_str).", operator) assert_block(full_message){operator.kind_of?(Symbol) || operator.respond_to?(:to_str)} full_message = build_message(message, < expected to be ? . EOT assert_block(full_message) { object1.__send__(operator, object2) } end end ## # Passes if block does not raise an exception. # # Example: # assert_nothing_raised do # [1, 2].uniq # end public def assert_nothing_raised(*args) _wrap_assertion do if Module === args.last message = "" else message = args.pop end exceptions, modules = _check_exception_class(args) begin yield rescue Exception => e if ((args.empty? && !e.instance_of?(AssertionFailedError)) || _expected_exception?(e, exceptions, modules)) assert_block(build_message(message, "Exception raised:\n?", e)){false} else raise end end nil end end ## # Flunk always fails. # # Example: # flunk 'Not done testing yet.' public def flunk(message="Flunked") assert_block(build_message(message)){false} end ## # Passes if ! +actual+ .equal? +expected+ # # Example: # assert_not_same Object.new, Object.new public def assert_not_same(expected, actual, message="") full_message = build_message(message, < with id expected to not be equal\\? to with id . EOT assert_block(full_message) { !actual.equal?(expected) } end ## # Passes if +expected+ != +actual+ # # Example: # assert_not_equal 'some string', 5 public def assert_not_equal(expected, actual, message="") full_message = build_message(message, " expected to be != to\n.", expected, actual) assert_block(full_message) { expected != actual } end ## # Passes if ! +object+ .nil? # # Example: # assert_not_nil '1 two 3'.sub!(/two/, '2') public def assert_not_nil(object, message="") full_message = build_message(message, " expected to not be nil.", object) assert_block(full_message){!object.nil?} end ## # Passes if +regexp+ !~ +string+ # # Example: # assert_no_match(/two/, 'one 2 three') public def assert_no_match(regexp, string, message="") _wrap_assertion do assert_instance_of(Regexp, regexp, "The first argument to assert_no_match should be a Regexp.") full_message = build_message(message, " expected to not match\n.", regexp, string) assert_block(full_message) { regexp !~ string } end end UncaughtThrow = {NameError => /^uncaught throw \`(.+)\'$/, ThreadError => /^uncaught throw \`(.+)\' in thread /} #` ## # Passes if the block throws +expected_symbol+ # # Example: # assert_throws :done do # throw :done # end public def assert_throws(expected_symbol, message="", &proc) _wrap_assertion do assert_instance_of(Symbol, expected_symbol, "assert_throws expects the symbol that should be thrown for its first argument") assert_block("Should have passed a block to assert_throws."){block_given?} caught = true begin catch(expected_symbol) do proc.call caught = false end full_message = build_message(message, " should have been thrown.", expected_symbol) assert_block(full_message){caught} rescue NameError, ThreadError => error if UncaughtThrow[error.class] !~ error.message raise error end full_message = build_message(message, " expected to be thrown but\n was thrown.", expected_symbol, $1.intern) flunk(full_message) end end end ## # Passes if block does not throw anything. # # Example: # assert_nothing_thrown do # [1, 2].uniq # end public def assert_nothing_thrown(message="", &proc) _wrap_assertion do assert(block_given?, "Should have passed a block to assert_nothing_thrown") begin proc.call rescue NameError, ThreadError => error if UncaughtThrow[error.class] !~ error.message raise error end full_message = build_message(message, " was thrown when nothing was expected", $1.intern) flunk(full_message) end assert(true, "Expected nothing to be thrown") end end ## # Passes if +expected_float+ and +actual_float+ are equal # within +delta+ tolerance. # # Example: # assert_in_delta 0.05, (50000.0 / 10**6), 0.00001 public def assert_in_delta(expected_float, actual_float, delta, message="") _wrap_assertion do {expected_float => "first float", actual_float => "second float", delta => "delta"}.each do |float, name| assert_respond_to(float, :to_f, "The arguments must respond to to_f; the #{name} did not") end assert_operator(delta, :>=, 0.0, "The delta should not be negative") full_message = build_message(message, < and expected to be within of each other. EOT assert_block(full_message) { (expected_float.to_f - actual_float.to_f).abs <= delta.to_f } end end ## # Passes if the method send returns a true value. # # +send_array+ is composed of: # * A receiver # * A method # * Arguments to the method # # Example: # assert_send [[1, 2], :include?, 4] public def assert_send(send_array, message="") _wrap_assertion do assert_instance_of(Array, send_array, "assert_send requires an array of send information") assert(send_array.size >= 2, "assert_send requires at least a receiver and a message name") full_message = build_message(message, < expected to respond to with a true value. EOT assert_block(full_message) { send_array[0].__send__(send_array[1], *send_array[2..-1]) } end end ## # Builds a failure message. +head+ is added before the +template+ and # +arguments+ replaces the '?'s positionally in the template. public def build_message(head, template=nil, *arguments) template &&= template.chomp return AssertionMessage.new(head, template, arguments) end private def _wrap_assertion @_assertion_wrapped ||= false unless (@_assertion_wrapped) @_assertion_wrapped = true begin add_assertion return yield ensure @_assertion_wrapped = false end else return yield end end ## # Called whenever an assertion is made. Define this in classes that # include Test::Unit::Assertions to record assertion counts. private def add_assertion end ## # Select whether or not to use the pretty-printer. If this option is set # to false before any assertions are made, pp.rb will not be required. public def self.use_pp=(value) AssertionMessage.use_pp = value end # :stopdoc: class AssertionMessage @use_pp = true class << self attr_accessor :use_pp end class Literal def initialize(value) @value = value end def inspect @value.to_s end end class Template def self.create(string) parts = (string ? string.scan(/(?=[^\\])\?|(?:\\\?|[^\?])+/m) : []) self.new(parts) end attr_reader :count def initialize(parts) @parts = parts @count = parts.find_all{|e| e == '?'}.size end def result(parameters) raise "The number of parameters does not match the number of substitutions." if(parameters.size != count) params = parameters.dup @parts.collect{|e| e == '?' ? params.shift : e.gsub(/\\\?/m, '?')}.join('') end end def self.literal(value) Literal.new(value) end include Util::BacktraceFilter def initialize(head, template_string, parameters) @head = head @template_string = template_string @parameters = parameters end def convert(object) case object when Exception < Message: <#{convert(object.message)}> ---Backtrace--- #{filter_backtrace(object.backtrace).join("\n")} --------------- EOM else if(self.class.use_pp) begin require 'pp' rescue LoadError self.class.use_pp = false return object.inspect end unless(defined?(PP)) PP.pp(object, '').chomp else object.inspect end end end def template @template ||= Template.create(@template_string) end def add_period(string) (string =~ /\.\Z/ ? string : string + '.') end def to_s message_parts = [] if (@head) head = @head.to_s unless(head.empty?) message_parts << add_period(head) end end tail = template.result(@parameters.collect{|e| convert(e)}) message_parts << tail unless(tail.empty?) message_parts.join("\n") end end # :startdoc: end end end PK0G]K4unit/testresult.rbnu[#-- # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/util/observable' module Test module Unit # Collects Test::Unit::Failure and Test::Unit::Error so that # they can be displayed to the user. To this end, observers # can be added to it, allowing the dynamic updating of, say, a # UI. class TestResult include Util::Observable CHANGED = "CHANGED" FAULT = "FAULT" attr_reader(:run_count, :assertion_count) # Constructs a new, empty TestResult. def initialize @run_count, @assertion_count = 0, 0 @failures, @errors = Array.new, Array.new end # Records a test run. def add_run @run_count += 1 notify_listeners(CHANGED, self) end # Records a Test::Unit::Failure. def add_failure(failure) @failures << failure notify_listeners(FAULT, failure) notify_listeners(CHANGED, self) end # Records a Test::Unit::Error. def add_error(error) @errors << error notify_listeners(FAULT, error) notify_listeners(CHANGED, self) end # Records an individual assertion. def add_assertion @assertion_count += 1 notify_listeners(CHANGED, self) end # Returns a string contain the recorded runs, assertions, # failures and errors in this TestResult. def to_s "#{run_count} tests, #{assertion_count} assertions, #{failure_count} failures, #{error_count} errors" end # Returns whether or not this TestResult represents # successful completion. def passed? return @failures.empty? && @errors.empty? end # Returns the number of failures this TestResult has # recorded. def failure_count return @failures.size end # Returns the number of errors this TestResult has # recorded. def error_count return @errors.size end end end end PK0G] unit/error.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/util/backtracefilter' module Test module Unit # Encapsulates an error in a test. Created by # Test::Unit::TestCase when it rescues an exception thrown # during the processing of a test. class Error include Util::BacktraceFilter attr_reader(:test_name, :exception) SINGLE_CHARACTER = 'E' # Creates a new Error with the given test_name and # exception. def initialize(test_name, exception) @test_name = test_name @exception = exception end # Returns a single character representation of an error. def single_character_display SINGLE_CHARACTER end # Returns the message associated with the error. def message "#{@exception.class.name}: #{@exception.message}" end # Returns a brief version of the error description. def short_display "#@test_name: #{message.split("\n")[0]}" end # Returns a verbose version of the error description. def long_display backtrace = filter_backtrace(@exception.backtrace).join("\n ") "Error:\n#@test_name:\n#{message}\n #{backtrace}" end # Overridden to return long_display. def to_s long_display end end end end PK0G]Fӥunit/testsuite.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. module Test module Unit # A collection of tests which can be #run. # # Note: It is easy to confuse a TestSuite instance with # something that has a static suite method; I know because _I_ # have trouble keeping them straight. Think of something that # has a suite method as simply providing a way to get a # meaningful TestSuite instance. class TestSuite attr_reader :name, :tests STARTED = name + "::STARTED" FINISHED = name + "::FINISHED" # Creates a new TestSuite with the given name. def initialize(name="Unnamed TestSuite") @name = name @tests = [] end # Runs the tests and/or suites contained in this # TestSuite. def run(result, &progress_block) yield(STARTED, name) @tests.each do |test| test.run(result, &progress_block) end yield(FINISHED, name) end # Adds the test to the suite. def <<(test) @tests << test self end def delete(test) @tests.delete(test) end # Retuns the rolled up number of tests in this suite; # i.e. if the suite contains other suites, it counts the # tests within those suites, not the suites themselves. def size total_size = 0 @tests.each { |test| total_size += test.size } total_size end def empty? tests.empty? end # Overridden to return the name given the suite at # creation. def to_s @name end # It's handy to be able to compare TestSuite instances. def ==(other) return false unless(other.kind_of?(self.class)) return false unless(@name == other.name) @tests == other.tests end end end end PK0G]xunit/testcase.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/assertions' require 'test/unit/failure' require 'test/unit/error' require 'test/unit/testsuite' require 'test/unit/assertionfailederror' require 'test/unit/util/backtracefilter' module Test module Unit # Ties everything together. If you subclass and add your own # test methods, it takes care of making them into tests and # wrapping those tests into a suite. It also does the # nitty-gritty of actually running an individual test and # collecting its results into a Test::Unit::TestResult object. class TestCase include Assertions include Util::BacktraceFilter attr_reader :method_name STARTED = name + "::STARTED" FINISHED = name + "::FINISHED" ## # These exceptions are not caught by #run. PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt, SystemExit] # Creates a new instance of the fixture for running the # test represented by test_method_name. def initialize(test_method_name) unless(respond_to?(test_method_name) and (method(test_method_name).arity == 0 || method(test_method_name).arity == -1)) throw :invalid_test end @method_name = test_method_name @test_passed = true end # Rolls up all of the test* methods in the fixture into # one suite, creating a new instance of the fixture for # each method. def self.suite method_names = public_instance_methods(true) tests = method_names.delete_if {|method_name| method_name !~ /^test./} suite = TestSuite.new(name) tests.sort.each do |test| catch(:invalid_test) do suite << new(test) end end if (suite.empty?) catch(:invalid_test) do suite << new("default_test") end end return suite end # Runs the individual test method represented by this # instance of the fixture, collecting statistics, failures # and errors in result. def run(result) yield(STARTED, name) @_result = result begin setup __send__(@method_name) rescue AssertionFailedError => e add_failure(e.message, e.backtrace) rescue Exception raise if PASSTHROUGH_EXCEPTIONS.include? $!.class add_error($!) ensure begin teardown rescue AssertionFailedError => e add_failure(e.message, e.backtrace) rescue Exception raise if PASSTHROUGH_EXCEPTIONS.include? $!.class add_error($!) end end result.add_run yield(FINISHED, name) end # Called before every test method runs. Can be used # to set up fixture information. def setup end # Called after every test method runs. Can be used to tear # down fixture information. def teardown end def default_test flunk("No tests were specified") end # Returns whether this individual test passed or # not. Primarily for use in teardown so that artifacts # can be left behind if the test fails. def passed? return @test_passed end private :passed? def size 1 end def add_assertion @_result.add_assertion end private :add_assertion def add_failure(message, all_locations=caller()) @test_passed = false @_result.add_failure(Failure.new(name, filter_backtrace(all_locations), message)) end private :add_failure def add_error(exception) @test_passed = false @_result.add_error(Error.new(name, exception)) end private :add_error # Returns a human-readable name for the specific test that # this instance of TestCase represents. def name "#{@method_name}(#{self.class.name})" end # Overridden to return #name. def to_s name end # It's handy to be able to compare TestCase instances. def ==(other) return false unless(other.kind_of?(self.class)) return false unless(@method_name == other.method_name) self.class == other.class end end end end PK0G]aAmVVunit/autorunner.rbnu[require 'test/unit' require 'test/unit/ui/testrunnerutilities' require 'optparse' module Test module Unit class AutoRunner def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block) r = new(force_standalone || standalone?, &block) r.base = default_dir r.process_args(argv) r.run end def self.standalone? return false unless("-e" == $0) ObjectSpace.each_object(Class) do |klass| return false if(klass < TestCase) end true end RUNNERS = { :console => proc do |r| require 'test/unit/ui/console/testrunner' Test::Unit::UI::Console::TestRunner end, :gtk => proc do |r| require 'test/unit/ui/gtk/testrunner' Test::Unit::UI::GTK::TestRunner end, :gtk2 => proc do |r| require 'test/unit/ui/gtk2/testrunner' Test::Unit::UI::GTK2::TestRunner end, :fox => proc do |r| require 'test/unit/ui/fox/testrunner' Test::Unit::UI::Fox::TestRunner end, :tk => proc do |r| require 'test/unit/ui/tk/testrunner' Test::Unit::UI::Tk::TestRunner end, } OUTPUT_LEVELS = [ [:silent, UI::SILENT], [:progress, UI::PROGRESS_ONLY], [:normal, UI::NORMAL], [:verbose, UI::VERBOSE], ] COLLECTORS = { :objectspace => proc do |r| require 'test/unit/collector/objectspace' c = Collector::ObjectSpace.new c.filter = r.filters c.collect($0.sub(/\.rb\Z/, '')) end, :dir => proc do |r| require 'test/unit/collector/dir' c = Collector::Dir.new c.filter = r.filters c.pattern.concat(r.pattern) if(r.pattern) c.exclude.concat(r.exclude) if(r.exclude) c.base = r.base $:.push(r.base) if r.base c.collect(*(r.to_run.empty? ? ['.'] : r.to_run)) end, } attr_reader :suite attr_accessor :output_level, :filters, :to_run, :pattern, :exclude, :base, :workdir attr_writer :runner, :collector def initialize(standalone) Unit.run = true @standalone = standalone @runner = RUNNERS[:console] @collector = COLLECTORS[(standalone ? :dir : :objectspace)] @filters = [] @to_run = [] @output_level = UI::NORMAL @workdir = nil yield(self) if(block_given?) end def process_args(args = ARGV) begin options.order!(args) {|arg| @to_run << arg} rescue OptionParser::ParseError => e puts e puts options $! = nil abort else @filters << proc{false} unless(@filters.empty?) end not @to_run.empty? end def options @options ||= OptionParser.new do |o| o.banner = "Test::Unit automatic runner." o.banner << "\nUsage: #{$0} [options] [-- untouched arguments]" o.on o.on('-r', '--runner=RUNNER', RUNNERS, "Use the given RUNNER.", "(" + keyword_display(RUNNERS) + ")") do |r| @runner = r end if(@standalone) o.on('-b', '--basedir=DIR', "Base directory of test suites.") do |b| @base = b end o.on('-w', '--workdir=DIR', "Working directory to run tests.") do |w| @workdir = w end o.on('-a', '--add=TORUN', Array, "Add TORUN to the list of things to run;", "can be a file or a directory.") do |a| @to_run.concat(a) end @pattern = [] o.on('-p', '--pattern=PATTERN', Regexp, "Match files to collect against PATTERN.") do |e| @pattern << e end @exclude = [] o.on('-x', '--exclude=PATTERN', Regexp, "Ignore files to collect against PATTERN.") do |e| @exclude << e end end o.on('-n', '--name=NAME', String, "Runs tests matching NAME.", "(patterns may be used).") do |n| n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n) case n when Regexp @filters << proc{|t| n =~ t.method_name ? true : nil} else @filters << proc{|t| n == t.method_name ? true : nil} end end o.on('-t', '--testcase=TESTCASE', String, "Runs tests in TestCases matching TESTCASE.", "(patterns may be used).") do |n| n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n) case n when Regexp @filters << proc{|t| n =~ t.class.name ? true : nil} else @filters << proc{|t| n == t.class.name ? true : nil} end end o.on('-I', "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]", "Appends directory list to $LOAD_PATH.") do |dirs| $LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR)) end o.on('-v', '--verbose=[LEVEL]', OUTPUT_LEVELS, "Set the output level (default is verbose).", "(" + keyword_display(OUTPUT_LEVELS) + ")") do |l| @output_level = l || UI::VERBOSE end o.on('--', "Stop processing options so that the", "remaining options will be passed to the", "test."){o.terminate} o.on('-h', '--help', 'Display this help.'){puts o; exit} o.on_tail o.on_tail('Deprecated options:') o.on_tail('--console', 'Console runner (use --runner).') do warn("Deprecated option (--console).") @runner = RUNNERS[:console] end o.on_tail('--gtk', 'GTK runner (use --runner).') do warn("Deprecated option (--gtk).") @runner = RUNNERS[:gtk] end o.on_tail('--fox', 'Fox runner (use --runner).') do warn("Deprecated option (--fox).") @runner = RUNNERS[:fox] end o.on_tail end end def keyword_display(array) list = array.collect {|e, *| e.to_s} Array === array or list.sort! list.collect {|e| e.sub(/^(.)([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')}.join(", ") end def run @suite = @collector[self] result = @runner[self] or return false Dir.chdir(@workdir) if @workdir result.run(@suite, @output_level).passed? end end end end PK0G]=!n n unit/collector/dir.rbnu[require 'test/unit/testsuite' require 'test/unit/collector' module Test module Unit module Collector class Dir include Collector attr_reader :pattern, :exclude attr_accessor :base def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil) super() @dir = dir @file = file @object_space = object_space @req = req @pattern = [/\btest_.*\.rb\Z/m] @exclude = [] end def collect(*from) basedir = @base $:.push(basedir) if basedir if(from.empty?) recursive_collect('.', find_test_cases) elsif(from.size == 1) recursive_collect(from.first, find_test_cases) else suites = [] from.each do |f| suite = recursive_collect(f, find_test_cases) suites << suite unless(suite.tests.empty?) end suite = TestSuite.new("[#{from.join(', ')}]") sort(suites).each{|s| suite << s} suite end ensure $:.delete_at($:.rindex(basedir)) if basedir end def find_test_cases(ignore=[]) cases = [] @object_space.each_object(Class) do |c| cases << c if(c < TestCase && !ignore.include?(c)) end ignore.concat(cases) cases end def recursive_collect(name, already_gathered) sub_suites = [] path = realdir(name) if @file.directory?(path) dir_name = name unless name == '.' @dir.entries(path).each do |e| next if(e == '.' || e == '..') e_name = dir_name ? @file.join(dir_name, e) : e if @file.directory?(realdir(e_name)) next if /\ACVS\z/ =~ e sub_suite = recursive_collect(e_name, already_gathered) sub_suites << sub_suite unless(sub_suite.empty?) else next if /~\z/ =~ e_name or /\A\.\#/ =~ e if @pattern and !@pattern.empty? next unless @pattern.any? {|pat| pat =~ e_name} end if @exclude and !@exclude.empty? next if @exclude.any? {|pat| pat =~ e_name} end collect_file(e_name, sub_suites, already_gathered) end end else collect_file(name, sub_suites, already_gathered) end suite = TestSuite.new(@file.basename(name)) sort(sub_suites).each{|s| suite << s} suite end def collect_file(name, suites, already_gathered) dir = @file.dirname(@file.expand_path(name, @base)) $:.unshift(dir) if(@req) @req.require(name) else require(name) end find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)} ensure $:.delete_at($:.rindex(dir)) if(dir) end def realdir(path) if @base @file.join(@base, path) else path end end end end end end PK0G]++unit/collector/objectspace.rbnu[# Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/collector' module Test module Unit module Collector class ObjectSpace include Collector NAME = 'collected from the ObjectSpace' def initialize(source=::ObjectSpace) super() @source = source end def collect(name=NAME) suite = TestSuite.new(name) sub_suites = [] @source.each_object(Class) do |klass| if(Test::Unit::TestCase > klass) add_suite(sub_suites, klass.suite) end end sort(sub_suites).each{|s| suite << s} suite end end end end end PK0G] J))unit/assertionfailederror.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. module Test module Unit # Thrown by Test::Unit::Assertions when an assertion fails. class AssertionFailedError < StandardError end end end PK0G]&&unit/failure.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. module Test module Unit # Encapsulates a test failure. Created by Test::Unit::TestCase # when an assertion fails. class Failure attr_reader :test_name, :location, :message SINGLE_CHARACTER = 'F' # Creates a new Failure with the given location and # message. def initialize(test_name, location, message) @test_name = test_name @location = location @message = message end # Returns a single character representation of a failure. def single_character_display SINGLE_CHARACTER end # Returns a brief version of the error description. def short_display "#@test_name: #{@message.split("\n")[0]}" end # Returns a verbose version of the error description. def long_display location_display = if(location.size == 1) location[0].sub(/\A(.+:\d+).*/, ' [\\1]') else "\n [#{location.join("\n ")}]" end "Failure:\n#@test_name#{location_display}:\n#@message" end # Overridden to return long_display. def to_s long_display end end end end PK0G]\~!~!unit/ui/fox/testrunner.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'fox' require 'test/unit/ui/testrunnermediator' require 'test/unit/ui/testrunnerutilities' include Fox module Test module Unit module UI module Fox # Runs a Test::Unit::TestSuite in a Fox UI. Obviously, # this one requires you to have Fox # (http://www.fox-toolkit.org/fox.html) and the Ruby # Fox extension (http://fxruby.sourceforge.net/) # installed. class TestRunner extend TestRunnerUtilities RED_STYLE = FXRGBA(0xFF,0,0,0xFF) #0xFF000000 GREEN_STYLE = FXRGBA(0,0xFF,0,0xFF) #0x00FF0000 # Creates a new TestRunner for running the passed # suite. def initialize(suite, output_level = NORMAL) if (suite.respond_to?(:suite)) @suite = suite.suite else @suite = suite end @result = nil @red = false end # Begins the test run. def start setup_ui setup_mediator attach_to_mediator start_ui @result end def setup_mediator @mediator = TestRunnerMediator.new(@suite) suite_name = @suite.to_s if ( @suite.kind_of?(Module) ) suite_name = @suite.name end @suite_name_entry.text = suite_name end def attach_to_mediator @mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui)) @mediator.add_listener(TestResult::FAULT, &method(:add_fault)) @mediator.add_listener(TestResult::CHANGED, &method(:result_changed)) @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started)) @mediator.add_listener(TestCase::STARTED, &method(:test_started)) @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished)) end def start_ui @application.create @window.show(PLACEMENT_SCREEN) @application.addTimeout(1) do @mediator.run_suite end @application.run end def stop @application.exit(0) end def reset_ui(count) @test_progress_bar.barColor = GREEN_STYLE @test_progress_bar.total = count @test_progress_bar.progress = 0 @red = false @test_count_label.text = "0" @assertion_count_label.text = "0" @failure_count_label.text = "0" @error_count_label.text = "0" @fault_list.clearItems end def add_fault(fault) if ( ! @red ) @test_progress_bar.barColor = RED_STYLE @red = true end item = FaultListItem.new(fault) @fault_list.appendItem(item) end def show_fault(fault) raw_show_fault(fault.long_display) end def raw_show_fault(string) @detail_text.setText(string) end def clear_fault raw_show_fault("") end def result_changed(result) @test_progress_bar.progress = result.run_count @test_count_label.text = result.run_count.to_s @assertion_count_label.text = result.assertion_count.to_s @failure_count_label.text = result.failure_count.to_s @error_count_label.text = result.error_count.to_s # repaint now! @info_panel.repaint @application.flush end def started(result) @result = result output_status("Started...") end def test_started(test_name) output_status("Running #{test_name}...") end def finished(elapsed_time) output_status("Finished in #{elapsed_time} seconds") end def output_status(string) @status_entry.text = string @status_entry.repaint end def setup_ui @application = create_application create_tooltip(@application) @window = create_window(@application) @status_entry = create_entry(@window) main_panel = create_main_panel(@window) suite_panel = create_suite_panel(main_panel) create_label(suite_panel, "Suite:") @suite_name_entry = create_entry(suite_panel) create_button(suite_panel, "&Run\tRun the current suite", proc { @mediator.run_suite }) @test_progress_bar = create_progress_bar(main_panel) @info_panel = create_info_panel(main_panel) create_label(@info_panel, "Tests:") @test_count_label = create_label(@info_panel, "0") create_label(@info_panel, "Assertions:") @assertion_count_label = create_label(@info_panel, "0") create_label(@info_panel, "Failures:") @failure_count_label = create_label(@info_panel, "0") create_label(@info_panel, "Errors:") @error_count_label = create_label(@info_panel, "0") list_panel = create_list_panel(main_panel) @fault_list = create_fault_list(list_panel) detail_panel = create_detail_panel(main_panel) @detail_text = create_text(detail_panel) end def create_application app = FXApp.new("TestRunner", "Test::Unit") app.init([]) app end def create_window(app) FXMainWindow.new(app, "Test::Unit TestRunner", nil, nil, DECOR_ALL, 0, 0, 450) end def create_tooltip(app) FXTooltip.new(app) end def create_main_panel(parent) panel = FXVerticalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y) panel.vSpacing = 10 panel end def create_suite_panel(parent) FXHorizontalFrame.new(parent, LAYOUT_SIDE_LEFT | LAYOUT_FILL_X) end def create_button(parent, text, action) FXButton.new(parent, text).connect(SEL_COMMAND, &action) end def create_progress_bar(parent) FXProgressBar.new(parent, nil, 0, PROGRESSBAR_NORMAL | LAYOUT_FILL_X) end def create_info_panel(parent) FXMatrix.new(parent, 1, MATRIX_BY_ROWS | LAYOUT_FILL_X) end def create_label(parent, text) FXLabel.new(parent, text, nil, JUSTIFY_CENTER_X | LAYOUT_FILL_COLUMN) end def create_list_panel(parent) FXHorizontalFrame.new(parent, LAYOUT_FILL_X | FRAME_SUNKEN | FRAME_THICK) end def create_fault_list(parent) list = FXList.new(parent, 10, nil, 0, LIST_SINGLESELECT | LAYOUT_FILL_X) #, 0, 0, 0, 150) list.connect(SEL_COMMAND) do |sender, sel, ptr| if sender.retrieveItem(sender.currentItem).selected? show_fault(sender.retrieveItem(sender.currentItem).fault) else clear_fault end end list end def create_detail_panel(parent) FXHorizontalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK) end def create_text(parent) FXText.new(parent, nil, 0, TEXT_READONLY | LAYOUT_FILL_X | LAYOUT_FILL_Y) end def create_entry(parent) entry = FXTextField.new(parent, 30, nil, 0, TEXTFIELD_NORMAL | LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X) entry.disable entry end end class FaultListItem < FXListItem attr_reader(:fault) def initialize(fault) super(fault.short_display) @fault = fault end end end end end end if __FILE__ == $0 Test::Unit::UI::Fox::TestRunner.start_command_line_test end PK0G]2>>unit/ui/gtk2/testrunner.rbnu[#-- # # Author:: Kenta MURATA. # Copyright:: Copyright (c) 2000-2002 Kenta MURATA. All rights reserved. # License:: Ruby license. require "gtk2" require "test/unit/ui/testrunnermediator" require "test/unit/ui/testrunnerutilities" module Test module Unit module UI module GTK2 Gtk.init class EnhancedLabel < Gtk::Label def set_text(text) super(text.gsub(/\n\t/, "\n ")) end end class FaultList < Gtk::TreeView def initialize @faults = [] @model = Gtk::ListStore.new(String, String) super(@model) column = Gtk::TreeViewColumn.new column.visible = false append_column(column) renderer = Gtk::CellRendererText.new column = Gtk::TreeViewColumn.new("Failures", renderer, {:text => 1}) append_column(column) selection.mode = Gtk::SELECTION_SINGLE set_rules_hint(true) set_headers_visible(false) end # def initialize def add_fault(fault) @faults.push(fault) iter = @model.append iter.set_value(0, (@faults.length - 1).to_s) iter.set_value(1, fault.short_display) end # def add_fault(fault) def get_fault(iter) @faults[iter.get_value(0).to_i] end # def get_fault def clear model.clear end # def clear end class TestRunner extend TestRunnerUtilities def lazy_initialize(symbol) if !instance_eval("defined?(@#{symbol})") then yield end return instance_eval("@#{symbol}") end private :lazy_initialize def status_entry lazy_initialize(:status_entry) do @status_entry = Gtk::Entry.new @status_entry.editable = false end end private :status_entry def status_panel lazy_initialize(:status_panel) do @status_panel = Gtk::HBox.new @status_panel.border_width = 10 @status_panel.pack_start(status_entry, true, true, 0) end end private :status_panel def fault_detail_label lazy_initialize(:fault_detail_label) do @fault_detail_label = EnhancedLabel.new("") # style = Gtk::Style.new # font = Gdk::Font. # font_load("-*-Courier 10 Pitch-medium-r-normal--*-120-*-*-*-*-*-*") # style.set_font(font) # @fault_detail_label.style = style @fault_detail_label.justify = Gtk::JUSTIFY_LEFT @fault_detail_label.wrap = false end end private :fault_detail_label def inner_detail_sub_panel lazy_initialize(:inner_detail_sub_panel) do @inner_detail_sub_panel = Gtk::HBox.new @inner_detail_sub_panel.pack_start(fault_detail_label, false, false, 0) end end private :inner_detail_sub_panel def outer_detail_sub_panel lazy_initialize(:outer_detail_sub_panel) do @outer_detail_sub_panel = Gtk::VBox.new @outer_detail_sub_panel.pack_start(inner_detail_sub_panel, false, false, 0) end end private :outer_detail_sub_panel def detail_scrolled_window lazy_initialize(:detail_scrolled_window) do @detail_scrolled_window = Gtk::ScrolledWindow.new @detail_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @detail_scrolled_window. set_size_request(400, @detail_scrolled_window.allocation.height) @detail_scrolled_window.add_with_viewport(outer_detail_sub_panel) end end private :detail_scrolled_window def detail_panel lazy_initialize(:detail_panel) do @detail_panel = Gtk::HBox.new @detail_panel.border_width = 10 @detail_panel.pack_start(detail_scrolled_window, true, true, 0) end end private :detail_panel def fault_list lazy_initialize(:fault_list) do @fault_list = FaultList.new end end private :fault_list def list_scrolled_window lazy_initialize(:list_scrolled_window) do @list_scrolled_window = Gtk::ScrolledWindow.new @list_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @list_scrolled_window. set_size_request(@list_scrolled_window.allocation.width, 150) @list_scrolled_window.add_with_viewport(fault_list) end end private :list_scrolled_window def list_panel lazy_initialize(:list_panel) do @list_panel = Gtk::HBox.new @list_panel.border_width = 10 @list_panel.pack_start(list_scrolled_window, true, true, 0) end end private :list_panel def error_count_label lazy_initialize(:error_count_label) do @error_count_label = Gtk::Label.new("0") @error_count_label.justify = Gtk::JUSTIFY_LEFT end end private :error_count_label def failure_count_label lazy_initialize(:failure_count_label) do @failure_count_label = Gtk::Label.new("0") @failure_count_label.justify = Gtk::JUSTIFY_LEFT end end private :failure_count_label def assertion_count_label lazy_initialize(:assertion_count_label) do @assertion_count_label = Gtk::Label.new("0") @assertion_count_label.justify = Gtk::JUSTIFY_LEFT end end private :assertion_count_label def run_count_label lazy_initialize(:run_count_label) do @run_count_label = Gtk::Label.new("0") @run_count_label.justify = Gtk::JUSTIFY_LEFT end end private :run_count_label def info_panel lazy_initialize(:info_panel) do @info_panel = Gtk::HBox.new(false, 0) @info_panel.border_width = 10 @info_panel.pack_start(Gtk::Label.new("Runs:"), false, false, 0) @info_panel.pack_start(run_count_label, true, false, 0) @info_panel.pack_start(Gtk::Label.new("Assertions:"), false, false, 0) @info_panel.pack_start(assertion_count_label, true, false, 0) @info_panel.pack_start(Gtk::Label.new("Failures:"), false, false, 0) @info_panel.pack_start(failure_count_label, true, false, 0) @info_panel.pack_start(Gtk::Label.new("Errors:"), false, false, 0) @info_panel.pack_start(error_count_label, true, false, 0) end end # def info_panel private :info_panel def green_style lazy_initialize(:green_style) do @green_style = Gtk::Style.new @green_style.set_bg(Gtk::STATE_PRELIGHT, 0x0000, 0xFFFF, 0x0000) end end # def green_style private :green_style def red_style lazy_initialize(:red_style) do @red_style = Gtk::Style.new @red_style.set_bg(Gtk::STATE_PRELIGHT, 0xFFFF, 0x0000, 0x0000) end end # def red_style private :red_style def test_progress_bar lazy_initialize(:test_progress_bar) { @test_progress_bar = Gtk::ProgressBar.new @test_progress_bar.fraction = 0.0 @test_progress_bar. set_size_request(@test_progress_bar.allocation.width, info_panel.size_request[1]) @test_progress_bar.style = green_style } end # def test_progress_bar private :test_progress_bar def progress_panel lazy_initialize(:progress_panel) do @progress_panel = Gtk::HBox.new(false, 10) @progress_panel.border_width = 10 @progress_panel.pack_start(test_progress_bar, true, true, 0) end end # def progress_panel def run_button lazy_initialize(:run_button) do @run_button = Gtk::Button.new("Run") end end # def run_button def suite_name_entry lazy_initialize(:suite_name_entry) do @suite_name_entry = Gtk::Entry.new @suite_name_entry.editable = false end end # def suite_name_entry private :suite_name_entry def suite_panel lazy_initialize(:suite_panel) do @suite_panel = Gtk::HBox.new(false, 10) @suite_panel.border_width = 10 @suite_panel.pack_start(Gtk::Label.new("Suite:"), false, false, 0) @suite_panel.pack_start(suite_name_entry, true, true, 0) @suite_panel.pack_start(run_button, false, false, 0) end end # def suite_panel private :suite_panel def main_panel lazy_initialize(:main_panel) do @main_panel = Gtk::VBox.new(false, 0) @main_panel.pack_start(suite_panel, false, false, 0) @main_panel.pack_start(progress_panel, false, false, 0) @main_panel.pack_start(info_panel, false, false, 0) @main_panel.pack_start(list_panel, false, false, 0) @main_panel.pack_start(detail_panel, true, true, 0) @main_panel.pack_start(status_panel, false, false, 0) end end # def main_panel private :main_panel def main_window lazy_initialize(:main_window) do @main_window = Gtk::Window.new(Gtk::Window::TOPLEVEL) @main_window.set_title("Test::Unit TestRunner") @main_window.set_default_size(800, 600) @main_window.set_resizable(true) @main_window.add(main_panel) end end # def main_window private :main_window def setup_ui main_window.signal_connect("destroy", nil) { stop } main_window.show_all fault_list.selection.signal_connect("changed", nil) do |selection, data| if selection.selected then show_fault(fault_list.get_fault(selection.selected)) else clear_fault end end end # def setup_ui private :setup_ui def output_status(string) status_entry.set_text(string) end # def output_status(string) private :output_status def finished(elapsed_time) test_progress_bar.fraction = 1.0 output_status("Finished in #{elapsed_time} seconds") end # def finished(elapsed_time) private :finished def test_started(test_name) output_status("Running #{test_name}...") end # def test_started(test_name) private :test_started def started(result) @result = result output_status("Started...") end # def started(result) private :started def test_finished(result) test_progress_bar.fraction += 1.0 / @count end # def test_finished(result) def result_changed(result) run_count_label.label = result.run_count.to_s assertion_count_label.label = result.assertion_count.to_s failure_count_label.label = result.failure_count.to_s error_count_label.label = result.error_count.to_s end # def result_changed(result) private :result_changed def clear_fault raw_show_fault("") end # def clear_fault private :clear_fault def raw_show_fault(string) fault_detail_label.set_text(string) outer_detail_sub_panel.queue_resize end # def raw_show_fault(string) private :raw_show_fault def show_fault(fault) raw_show_fault(fault.long_display) end # def show_fault(fault) private :show_fault def add_fault(fault) if not @red then test_progress_bar.style = red_style @red = true end fault_list.add_fault(fault) end # def add_fault(fault) private :add_fault def reset_ui(count) test_progress_bar.style = green_style test_progress_bar.fraction = 0.0 @count = count + 1 @red = false run_count_label.set_text("0") assertion_count_label.set_text("0") failure_count_label.set_text("0") error_count_label.set_text("0") fault_list.clear end # def reset_ui(count) private :reset_ui def stop Gtk.main_quit end # def stop private :stop def run_test @runner.raise(@restart_signal) end private :run_test def start_ui @viewer.run running = false begin loop do if (running ^= true) run_button.child.text = "Stop" @mediator.run_suite else run_button.child.text = "Run" @viewer.join break end end rescue @restart_signal retry rescue end end # def start_ui private :start_ui def attach_to_mediator run_button.signal_connect("clicked", nil) { run_test } @mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui)) @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started)) @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished)) @mediator.add_listener(TestResult::FAULT, &method(:add_fault)) @mediator.add_listener(TestResult::CHANGED, &method(:result_changed)) @mediator.add_listener(TestCase::STARTED, &method(:test_started)) @mediator.add_listener(TestCase::FINISHED, &method(:test_finished)) end # def attach_to_mediator private :attach_to_mediator def setup_mediator @mediator = TestRunnerMediator.new(@suite) suite_name = @suite.to_s if @suite.kind_of?(Module) then suite_name = @suite.name end suite_name_entry.set_text(suite_name) end # def setup_mediator private :setup_mediator def start setup_mediator setup_ui attach_to_mediator start_ui @result end # def start def initialize(suite, output_level = NORMAL) if suite.respond_to?(:suite) then @suite = suite.suite else @suite = suite end @result = nil @runner = Thread.current @restart_signal = Class.new(Exception) @viewer = Thread.start do @runner.join rescue @runner.run Gtk.main end @viewer.join rescue nil # wait deadlock to handshake end # def initialize(suite) end # class TestRunner end # module GTK2 end # module UI end # module Unit end # module Test PK0G]`Dc"c"unit/ui/tk/testrunner.rbnu[#-- # # Original Author:: Nathaniel Talbott. # Author:: Kazuhiro NISHIYAMA. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # Copyright:: Copyright (c) 2003 Kazuhiro NISHIYAMA. All rights reserved. # License:: Ruby license. require 'tk' require 'test/unit/ui/testrunnermediator' require 'test/unit/ui/testrunnerutilities' module Test module Unit module UI module Tk # Runs a Test::Unit::TestSuite in a Tk UI. Obviously, # this one requires you to have Tk # and the Ruby Tk extension installed. class TestRunner extend TestRunnerUtilities # Creates a new TestRunner for running the passed # suite. def initialize(suite, output_level = NORMAL) if (suite.respond_to?(:suite)) @suite = suite.suite else @suite = suite end @result = nil @red = false @fault_detail_list = [] @runner = Thread.current @restart_signal = Class.new(Exception) @viewer = Thread.start do @runner.join rescue @runner.run ::Tk.mainloop end @viewer.join rescue nil # wait deadlock to handshake end # Begins the test run. def start setup_ui setup_mediator attach_to_mediator start_ui @result end private def setup_mediator @mediator = TestRunnerMediator.new(@suite) suite_name = @suite.to_s if ( @suite.kind_of?(Module) ) suite_name = @suite.name end @suite_name_entry.value = suite_name end def attach_to_mediator @run_button.command(method(:run_test)) @fault_list.bind('ButtonPress-1', proc{|y| fault = @fault_detail_list[@fault_list.nearest(y)] if fault show_fault(fault) end }, '%y') @mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui)) @mediator.add_listener(TestResult::FAULT, &method(:add_fault)) @mediator.add_listener(TestResult::CHANGED, &method(:result_changed)) @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started)) @mediator.add_listener(TestCase::STARTED, &method(:test_started)) @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished)) end def run_test @runner.raise(@restart_signal) end def start_ui @viewer.run running = false begin loop do if (running ^= true) @run_button.configure('text'=>'Stop') @mediator.run_suite else @run_button.configure('text'=>'Run') @viewer.join break end end rescue @restart_signal retry rescue end end def stop ::Tk.exit end def reset_ui(count) @test_total_count = count.to_f @test_progress_bar.configure('background'=>'green') @test_progress_bar.place('relwidth'=>(count.zero? ? 0 : 0/count)) @red = false @test_count_label.value = 0 @assertion_count_label.value = 0 @failure_count_label.value = 0 @error_count_label.value = 0 @fault_list.delete(0, 'end') @fault_detail_list = [] clear_fault end def add_fault(fault) if ( ! @red ) @test_progress_bar.configure('background'=>'red') @red = true end @fault_detail_list.push fault @fault_list.insert('end', fault.short_display) end def show_fault(fault) raw_show_fault(fault.long_display) end def raw_show_fault(string) @detail_text.value = string end def clear_fault raw_show_fault("") end def result_changed(result) @test_count_label.value = result.run_count @test_progress_bar.place('relwidth'=>result.run_count/@test_total_count) @assertion_count_label.value = result.assertion_count @failure_count_label.value = result.failure_count @error_count_label.value = result.error_count end def started(result) @result = result output_status("Started...") end def test_started(test_name) output_status("Running #{test_name}...") end def finished(elapsed_time) output_status("Finished in #{elapsed_time} seconds") end def output_status(string) @status_entry.value = string end def setup_ui @status_entry = TkVariable.new l = TkLabel.new(nil, 'textvariable'=>@status_entry, 'relief'=>'sunken') l.pack('side'=>'bottom', 'fill'=>'x') suite_frame = TkFrame.new.pack('fill'=>'x') @run_button = TkButton.new(suite_frame, 'text'=>'Run') @run_button.pack('side'=>'right') TkLabel.new(suite_frame, 'text'=>'Suite:').pack('side'=>'left') @suite_name_entry = TkVariable.new l = TkLabel.new(suite_frame, 'textvariable'=>@suite_name_entry, 'relief'=>'sunken') l.pack('side'=>'left', 'fill'=>'x', 'expand'=>true) f = TkFrame.new(nil, 'relief'=>'sunken', 'borderwidth'=>3, 'height'=>20).pack('fill'=>'x', 'padx'=>1) @test_progress_bar = TkFrame.new(f, 'background'=>'green').place('anchor'=>'nw', 'relwidth'=>0.0, 'relheight'=>1.0) info_frame = TkFrame.new.pack('fill'=>'x') @test_count_label = create_count_label(info_frame, 'Tests:') @assertion_count_label = create_count_label(info_frame, 'Assertions:') @failure_count_label = create_count_label(info_frame, 'Failures:') @error_count_label = create_count_label(info_frame, 'Errors:') if (::Tk.info('command', TkPanedWindow::TkCommandNames[0]) != "") # use panedwindow paned_frame = TkPanedWindow.new("orient"=>"vertical").pack('fill'=>'both', 'expand'=>true) fault_list_frame = TkFrame.new(paned_frame) detail_frame = TkFrame.new(paned_frame) paned_frame.add(fault_list_frame, detail_frame) else # no panedwindow paned_frame = nil fault_list_frame = TkFrame.new.pack('fill'=>'both', 'expand'=>true) detail_frame = TkFrame.new.pack('fill'=>'both', 'expand'=>true) end TkGrid.rowconfigure(fault_list_frame, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(fault_list_frame, 0, 'weight'=>1, 'minsize'=>0) fault_scrollbar_y = TkScrollbar.new(fault_list_frame) fault_scrollbar_x = TkScrollbar.new(fault_list_frame) @fault_list = TkListbox.new(fault_list_frame) @fault_list.yscrollbar(fault_scrollbar_y) @fault_list.xscrollbar(fault_scrollbar_x) TkGrid.rowconfigure(detail_frame, 0, 'weight'=>1, 'minsize'=>0) TkGrid.columnconfigure(detail_frame, 0, 'weight'=>1, 'minsize'=>0) ::Tk.grid(@fault_list, fault_scrollbar_y, 'sticky'=>'news') ::Tk.grid(fault_scrollbar_x, 'sticky'=>'news') detail_scrollbar_y = TkScrollbar.new(detail_frame) detail_scrollbar_x = TkScrollbar.new(detail_frame) @detail_text = TkText.new(detail_frame, 'height'=>10, 'wrap'=>'none') { bindtags(bindtags - [TkText]) } @detail_text.yscrollbar(detail_scrollbar_y) @detail_text.xscrollbar(detail_scrollbar_x) ::Tk.grid(@detail_text, detail_scrollbar_y, 'sticky'=>'news') ::Tk.grid(detail_scrollbar_x, 'sticky'=>'news') # rubber-style pane if paned_frame ::Tk.update @height = paned_frame.winfo_height paned_frame.bind('Configure', proc{|h| paned_frame.sash_place(0, 0, paned_frame.sash_coord(0)[1] * h / @height) @height = h }, '%h') end end def create_count_label(parent, label) TkLabel.new(parent, 'text'=>label).pack('side'=>'left', 'expand'=>true) v = TkVariable.new(0) TkLabel.new(parent, 'textvariable'=>v).pack('side'=>'left', 'expand'=>true) v end end end end end end if __FILE__ == $0 Test::Unit::UI::Tk::TestRunner.start_command_line_test end PK0G]Kunit/ui/testrunnerutilities.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. module Test module Unit module UI SILENT = 0 PROGRESS_ONLY = 1 NORMAL = 2 VERBOSE = 3 # Provides some utilities common to most, if not all, # TestRunners. # #-- # # Perhaps there ought to be a TestRunner superclass? There # seems to be a decent amount of shared code between test # runners. module TestRunnerUtilities # Creates a new TestRunner and runs the suite. def run(suite, output_level=NORMAL) return new(suite, output_level).start end # Takes care of the ARGV parsing and suite # determination necessary for running one of the # TestRunners from the command line. def start_command_line_test if ARGV.empty? puts "You should supply the name of a test suite file to the runner" exit end require ARGV[0].gsub(/.+::/, '') new(eval(ARGV[0])).start end end end end end PK0G]9977unit/ui/gtk/testrunner.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'gtk' require 'test/unit/ui/testrunnermediator' require 'test/unit/ui/testrunnerutilities' module Test module Unit module UI module GTK # Runs a Test::Unit::TestSuite in a Gtk UI. Obviously, # this one requires you to have Gtk # (http://www.gtk.org/) and the Ruby Gtk extension # (http://ruby-gnome.sourceforge.net/) installed. class TestRunner extend TestRunnerUtilities # Creates a new TestRunner for running the passed # suite. def initialize(suite, output_level = NORMAL) if (suite.respond_to?(:suite)) @suite = suite.suite else @suite = suite end @result = nil @runner = Thread.current @restart_signal = Class.new(Exception) @viewer = Thread.start do @runner.join rescue @runner.run Gtk.main end @viewer.join rescue nil # wait deadlock to handshake end # Begins the test run. def start setup_mediator setup_ui attach_to_mediator start_ui @result end private def setup_mediator @mediator = TestRunnerMediator.new(@suite) suite_name = @suite.to_s if ( @suite.kind_of?(Module) ) suite_name = @suite.name end suite_name_entry.set_text(suite_name) end def attach_to_mediator run_button.signal_connect("clicked", nil, &method(:run_test)) @mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui)) @mediator.add_listener(TestResult::FAULT, &method(:add_fault)) @mediator.add_listener(TestResult::CHANGED, &method(:result_changed)) @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started)) @mediator.add_listener(TestCase::STARTED, &method(:test_started)) @mediator.add_listener(TestCase::FINISHED, &method(:test_finished)) @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished)) end def run_test(*) @runner.raise(@restart_signal) end def start_ui @viewer.run running = false begin loop do if (running ^= true) run_button.child.text = "Stop" @mediator.run_suite else run_button.child.text = "Run" @viewer.join break end end rescue @restart_signal retry rescue end end def stop(*) Gtk.main_quit end def reset_ui(count) test_progress_bar.set_style(green_style) test_progress_bar.configure(0, 0, count) @red = false run_count_label.set_text("0") assertion_count_label.set_text("0") failure_count_label.set_text("0") error_count_label.set_text("0") fault_list.remove_items(fault_list.children) end def add_fault(fault) if ( ! @red ) test_progress_bar.set_style(red_style) @red = true end item = FaultListItem.new(fault) item.show fault_list.append_items([item]) end def show_fault(fault) raw_show_fault(fault.long_display) end def raw_show_fault(string) fault_detail_label.set_text(string) outer_detail_sub_panel.queue_resize end def clear_fault raw_show_fault("") end def result_changed(result) run_count_label.set_text(result.run_count.to_s) assertion_count_label.set_text(result.assertion_count.to_s) failure_count_label.set_text(result.failure_count.to_s) error_count_label.set_text(result.error_count.to_s) end def started(result) @result = result output_status("Started...") end def test_started(test_name) output_status("Running #{test_name}...") end def test_finished(test_name) test_progress_bar.set_value(test_progress_bar.get_value + 1) end def finished(elapsed_time) output_status("Finished in #{elapsed_time} seconds") end def output_status(string) status_entry.set_text(string) end def setup_ui main_window.signal_connect("destroy", nil, &method(:stop)) main_window.show_all fault_list.signal_connect("select-child", nil) { | list, item, data | show_fault(item.fault) } fault_list.signal_connect("unselect-child", nil) { clear_fault } @red = false end def main_window lazy_initialize(:main_window) { @main_window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL) @main_window.set_title("Test::Unit TestRunner") @main_window.set_usize(800, 600) @main_window.set_uposition(20, 20) @main_window.set_policy(true, true, false) @main_window.add(main_panel) } end def main_panel lazy_initialize(:main_panel) { @main_panel = Gtk::VBox.new(false, 0) @main_panel.pack_start(suite_panel, false, false, 0) @main_panel.pack_start(progress_panel, false, false, 0) @main_panel.pack_start(info_panel, false, false, 0) @main_panel.pack_start(list_panel, false, false, 0) @main_panel.pack_start(detail_panel, true, true, 0) @main_panel.pack_start(status_panel, false, false, 0) } end def suite_panel lazy_initialize(:suite_panel) { @suite_panel = Gtk::HBox.new(false, 10) @suite_panel.border_width(10) @suite_panel.pack_start(Gtk::Label.new("Suite:"), false, false, 0) @suite_panel.pack_start(suite_name_entry, true, true, 0) @suite_panel.pack_start(run_button, false, false, 0) } end def suite_name_entry lazy_initialize(:suite_name_entry) { @suite_name_entry = Gtk::Entry.new @suite_name_entry.set_editable(false) } end def run_button lazy_initialize(:run_button) { @run_button = Gtk::Button.new("Run") } end def progress_panel lazy_initialize(:progress_panel) { @progress_panel = Gtk::HBox.new(false, 10) @progress_panel.border_width(10) @progress_panel.pack_start(test_progress_bar, true, true, 0) } end def test_progress_bar lazy_initialize(:test_progress_bar) { @test_progress_bar = EnhancedProgressBar.new @test_progress_bar.set_usize(@test_progress_bar.allocation.width, info_panel.size_request.height) @test_progress_bar.set_style(green_style) } end def green_style lazy_initialize(:green_style) { @green_style = Gtk::Style.new @green_style.set_bg(Gtk::STATE_PRELIGHT, 0x0000, 0xFFFF, 0x0000) } end def red_style lazy_initialize(:red_style) { @red_style = Gtk::Style.new @red_style.set_bg(Gtk::STATE_PRELIGHT, 0xFFFF, 0x0000, 0x0000) } end def info_panel lazy_initialize(:info_panel) { @info_panel = Gtk::HBox.new(false, 0) @info_panel.border_width(10) @info_panel.pack_start(Gtk::Label.new("Runs:"), false, false, 0) @info_panel.pack_start(run_count_label, true, false, 0) @info_panel.pack_start(Gtk::Label.new("Assertions:"), false, false, 0) @info_panel.pack_start(assertion_count_label, true, false, 0) @info_panel.pack_start(Gtk::Label.new("Failures:"), false, false, 0) @info_panel.pack_start(failure_count_label, true, false, 0) @info_panel.pack_start(Gtk::Label.new("Errors:"), false, false, 0) @info_panel.pack_start(error_count_label, true, false, 0) } end def run_count_label lazy_initialize(:run_count_label) { @run_count_label = Gtk::Label.new("0") @run_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end def assertion_count_label lazy_initialize(:assertion_count_label) { @assertion_count_label = Gtk::Label.new("0") @assertion_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end def failure_count_label lazy_initialize(:failure_count_label) { @failure_count_label = Gtk::Label.new("0") @failure_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end def error_count_label lazy_initialize(:error_count_label) { @error_count_label = Gtk::Label.new("0") @error_count_label.set_justify(Gtk::JUSTIFY_LEFT) } end def list_panel lazy_initialize(:list_panel) { @list_panel = Gtk::HBox.new @list_panel.border_width(10) @list_panel.pack_start(list_scrolled_window, true, true, 0) } end def list_scrolled_window lazy_initialize(:list_scrolled_window) { @list_scrolled_window = Gtk::ScrolledWindow.new @list_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @list_scrolled_window.set_usize(@list_scrolled_window.allocation.width, 150) @list_scrolled_window.add_with_viewport(fault_list) } end def fault_list lazy_initialize(:fault_list) { @fault_list = Gtk::List.new } end def detail_panel lazy_initialize(:detail_panel) { @detail_panel = Gtk::HBox.new @detail_panel.border_width(10) @detail_panel.pack_start(detail_scrolled_window, true, true, 0) } end def detail_scrolled_window lazy_initialize(:detail_scrolled_window) { @detail_scrolled_window = Gtk::ScrolledWindow.new @detail_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @detail_scrolled_window.set_usize(400, @detail_scrolled_window.allocation.height) @detail_scrolled_window.add_with_viewport(outer_detail_sub_panel) } end def outer_detail_sub_panel lazy_initialize(:outer_detail_sub_panel) { @outer_detail_sub_panel = Gtk::VBox.new @outer_detail_sub_panel.pack_start(inner_detail_sub_panel, false, false, 0) } end def inner_detail_sub_panel lazy_initialize(:inner_detail_sub_panel) { @inner_detail_sub_panel = Gtk::HBox.new @inner_detail_sub_panel.pack_start(fault_detail_label, false, false, 0) } end def fault_detail_label lazy_initialize(:fault_detail_label) { @fault_detail_label = EnhancedLabel.new("") style = Gtk::Style.new font = Gdk::Font.font_load("-*-Courier New-medium-r-normal--*-120-*-*-*-*-*-*") begin style.set_font(font) rescue ArgumentError; end @fault_detail_label.set_style(style) @fault_detail_label.set_justify(Gtk::JUSTIFY_LEFT) @fault_detail_label.set_line_wrap(false) } end def status_panel lazy_initialize(:status_panel) { @status_panel = Gtk::HBox.new @status_panel.border_width(10) @status_panel.pack_start(status_entry, true, true, 0) } end def status_entry lazy_initialize(:status_entry) { @status_entry = Gtk::Entry.new @status_entry.set_editable(false) } end def lazy_initialize(symbol) if (!instance_eval("defined?(@#{symbol.to_s})")) yield end return instance_eval("@" + symbol.to_s) end end class EnhancedProgressBar < Gtk::ProgressBar def set_style(style) super hide show end end class EnhancedLabel < Gtk::Label def set_text(text) super(text.gsub(/\n\t/, "\n" + (" " * 4))) end end class FaultListItem < Gtk::ListItem attr_reader(:fault) def initialize(fault) super(fault.short_display) @fault = fault end end end end end end if __FILE__ == $0 Test::Unit::UI::GTK::TestRunner.start_command_line_test end PK0G]o/unit/ui/console/testrunner.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/ui/testrunnermediator' require 'test/unit/ui/testrunnerutilities' module Test module Unit module UI module Console # Runs a Test::Unit::TestSuite on the console. class TestRunner extend TestRunnerUtilities # Creates a new TestRunner for running the passed # suite. If quiet_mode is true, the output while # running is limited to progress dots, errors and # failures, and the final result. io specifies # where runner output should go to; defaults to # STDOUT. def initialize(suite, output_level=NORMAL, io=STDOUT) if (suite.respond_to?(:suite)) @suite = suite.suite else @suite = suite end @output_level = output_level @io = io @already_outputted = false @faults = [] end # Begins the test run. def start setup_mediator attach_to_mediator return start_mediator end private def setup_mediator @mediator = create_mediator(@suite) suite_name = @suite.to_s if ( @suite.kind_of?(Module) ) suite_name = @suite.name end output("Loaded suite #{suite_name}") end def create_mediator(suite) return TestRunnerMediator.new(suite) end def attach_to_mediator @mediator.add_listener(TestResult::FAULT, &method(:add_fault)) @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started)) @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished)) @mediator.add_listener(TestCase::STARTED, &method(:test_started)) @mediator.add_listener(TestCase::FINISHED, &method(:test_finished)) end def start_mediator return @mediator.run_suite end def add_fault(fault) @faults << fault output_single(fault.single_character_display, PROGRESS_ONLY) @already_outputted = true end def started(result) @result = result output("Started") end def finished(elapsed_time) nl output("Finished in #{elapsed_time} seconds.") @faults.each_with_index do |fault, index| nl output("%3d) %s" % [index + 1, fault.long_display]) end nl output(@result) end def test_started(name) output_single(name + ": ", VERBOSE) end def test_finished(name) output_single(".", PROGRESS_ONLY) unless (@already_outputted) nl(VERBOSE) @already_outputted = false end def nl(level=NORMAL) output("", level) end def output(something, level=NORMAL) @io.puts(something) if (output?(level)) @io.flush end def output_single(something, level=NORMAL) @io.write(something) if (output?(level)) @io.flush end def output?(level) level <= @output_level end end end end end end if __FILE__ == $0 Test::Unit::UI::Console::TestRunner.start_command_line_test end PK0G] 000unit/ui/testrunnermediator.rbnu[#-- # # Author:: Nathaniel Talbott. # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit' require 'test/unit/util/observable' require 'test/unit/testresult' module Test module Unit module UI # Provides an interface to write any given UI against, # hopefully making it easy to write new UIs. class TestRunnerMediator RESET = name + "::RESET" STARTED = name + "::STARTED" FINISHED = name + "::FINISHED" include Util::Observable # Creates a new TestRunnerMediator initialized to run # the passed suite. def initialize(suite) @suite = suite end # Runs the suite the TestRunnerMediator was created # with. def run_suite Unit.run = true begin_time = Time.now notify_listeners(RESET, @suite.size) result = create_result notify_listeners(STARTED, result) result_listener = result.add_listener(TestResult::CHANGED) do |updated_result| notify_listeners(TestResult::CHANGED, updated_result) end fault_listener = result.add_listener(TestResult::FAULT) do |fault| notify_listeners(TestResult::FAULT, fault) end @suite.run(result) do |channel, value| notify_listeners(channel, value) end result.remove_listener(TestResult::FAULT, fault_listener) result.remove_listener(TestResult::CHANGED, result_listener) end_time = Time.now elapsed_time = end_time - begin_time notify_listeners(FINISHED, elapsed_time) #"Finished in #{elapsed_time} seconds.") return result end private # A factory method to create the result the mediator # should run with. Can be overridden by subclasses if # one wants to use a different result. def create_result return TestResult.new end end end end end PK0G]2Viiunit/collector.rbnu[module Test module Unit module Collector def initialize @filters = [] end def filter=(filters) @filters = case(filters) when Proc [filters] when Array filters end end def add_suite(destination, suite) to_delete = suite.tests.find_all{|t| !include?(t)} to_delete.each{|t| suite.delete(t)} destination << suite unless(suite.size == 0) end def include?(test) return true if(@filters.empty?) @filters.each do |filter| result = filter[test] if(result.nil?) next elsif(!result) return false else return true end end true end def sort(suites) suites.sort_by{|s| s.name} end end end end PK0G]$q+q+unit.rbnu[require 'test/unit/testcase' require 'test/unit/autorunner' module Test # :nodoc: # # = Test::Unit - Ruby Unit Testing Framework # # == Introduction # # Unit testing is making waves all over the place, largely due to the # fact that it is a core practice of XP. While XP is great, unit testing # has been around for a long time and has always been a good idea. One # of the keys to good unit testing, though, is not just writing tests, # but having tests. What's the difference? Well, if you just _write_ a # test and throw it away, you have no guarantee that something won't # change later which breaks your code. If, on the other hand, you _have_ # tests (obviously you have to write them first), and run them as often # as possible, you slowly build up a wall of things that cannot break # without you immediately knowing about it. This is when unit testing # hits its peak usefulness. # # Enter Test::Unit, a framework for unit testing in Ruby, helping you to # design, debug and evaluate your code by making it easy to write and # have tests for it. # # # == Notes # # Test::Unit has grown out of and superceded Lapidary. # # # == Feedback # # I like (and do my best to practice) XP, so I value early releases, # user feedback, and clean, simple, expressive code. There is always # room for improvement in everything I do, and Test::Unit is no # exception. Please, let me know what you think of Test::Unit as it # stands, and what you'd like to see expanded/changed/improved/etc. If # you find a bug, let me know ASAP; one good way to let me know what the # bug is is to submit a new test that catches it :-) Also, I'd love to # hear about any successes you have with Test::Unit, and any # documentation you might add will be greatly appreciated. My contact # info is below. # # # == Contact Information # # A lot of discussion happens about Ruby in general on the ruby-talk # mailing list (http://www.ruby-lang.org/en/ml.html), and you can ask # any questions you might have there. I monitor the list, as do many # other helpful Rubyists, and you're sure to get a quick answer. Of # course, you're also welcome to email me (Nathaniel Talbott) directly # at mailto:testunit@talbott.ws, and I'll do my best to help you out. # # # == Credits # # I'd like to thank... # # Matz, for a great language! # # Masaki Suketa, for his work on RubyUnit, which filled a vital need in # the Ruby world for a very long time. I'm also grateful for his help in # polishing Test::Unit and getting the RubyUnit compatibility layer # right. His graciousness in allowing Test::Unit to supercede RubyUnit # continues to be a challenge to me to be more willing to defer my own # rights. # # Ken McKinlay, for his interest and work on unit testing, and for his # willingness to dialog about it. He was also a great help in pointing # out some of the holes in the RubyUnit compatibility layer. # # Dave Thomas, for the original idea that led to the extremely simple # "require 'test/unit'", plus his code to improve it even more by # allowing the selection of tests from the command-line. Also, without # RDoc, the documentation for Test::Unit would stink a lot more than it # does now. # # Everyone who's helped out with bug reports, feature ideas, # encouragement to continue, etc. It's a real privilege to be a part of # the Ruby community. # # The guys at RoleModel Software, for putting up with me repeating, "But # this would be so much easier in Ruby!" whenever we're coding in Java. # # My Creator, for giving me life, and giving it more abundantly. # # # == License # # Test::Unit is copyright (c) 2000-2003 Nathaniel Talbott. It is free # software, and is distributed under the Ruby license. See the COPYING # file in the standard Ruby distribution for details. # # # == Warranty # # This software is provided "as is" and without any express or # implied warranties, including, without limitation, the implied # warranties of merchantibility and fitness for a particular # purpose. # # # == Author # # Nathaniel Talbott. # Copyright (c) 2000-2003, Nathaniel Talbott # # ---- # # = Usage # # The general idea behind unit testing is that you write a _test_ # _method_ that makes certain _assertions_ about your code, working # against a _test_ _fixture_. A bunch of these _test_ _methods_ are # bundled up into a _test_ _suite_ and can be run any time the # developer wants. The results of a run are gathered in a _test_ # _result_ and displayed to the user through some UI. So, lets break # this down and see how Test::Unit provides each of these necessary # pieces. # # # == Assertions # # These are the heart of the framework. Think of an assertion as a # statement of expected outcome, i.e. "I assert that x should be equal # to y". If, when the assertion is executed, it turns out to be # correct, nothing happens, and life is good. If, on the other hand, # your assertion turns out to be false, an error is propagated with # pertinent information so that you can go back and make your # assertion succeed, and, once again, life is good. For an explanation # of the current assertions, see Test::Unit::Assertions. # # # == Test Method & Test Fixture # # Obviously, these assertions have to be called within a context that # knows about them and can do something meaningful with their # pass/fail value. Also, it's handy to collect a bunch of related # tests, each test represented by a method, into a common test class # that knows how to run them. The tests will be in a separate class # from the code they're testing for a couple of reasons. First of all, # it allows your code to stay uncluttered with test code, making it # easier to maintain. Second, it allows the tests to be stripped out # for deployment, since they're really there for you, the developer, # and your users don't need them. Third, and most importantly, it # allows you to set up a common test fixture for your tests to run # against. # # What's a test fixture? Well, tests do not live in a vacuum; rather, # they're run against the code they are testing. Often, a collection # of tests will run against a common set of data, also called a # fixture. If they're all bundled into the same test class, they can # all share the setting up and tearing down of that data, eliminating # unnecessary duplication and making it much easier to add related # tests. # # Test::Unit::TestCase wraps up a collection of test methods together # and allows you to easily set up and tear down the same test fixture # for each test. This is done by overriding #setup and/or #teardown, # which will be called before and after each test method that is # run. The TestCase also knows how to collect the results of your # assertions into a Test::Unit::TestResult, which can then be reported # back to you... but I'm getting ahead of myself. To write a test, # follow these steps: # # * Make sure Test::Unit is in your library path. # * require 'test/unit' in your test script. # * Create a class that subclasses Test::Unit::TestCase. # * Add a method that begins with "test" to your class. # * Make assertions in your test method. # * Optionally define #setup and/or #teardown to set up and/or tear # down your common test fixture. # * You can now run your test as you would any other Ruby # script... try it and see! # # A really simple test might look like this (#setup and #teardown are # commented out to indicate that they are completely optional): # # require 'test/unit' # # class TC_MyTest < Test::Unit::TestCase # # def setup # # end # # # def teardown # # end # # def test_fail # assert(false, 'Assertion was false.') # end # end # # # == Test Runners # # So, now you have this great test class, but you still need a way to # run it and view any failures that occur during the run. This is # where Test::Unit::UI::Console::TestRunner (and others, such as # Test::Unit::UI::GTK::TestRunner) comes into play. The console test # runner is automatically invoked for you if you require 'test/unit' # and simply run the file. To use another runner, or to manually # invoke a runner, simply call its run class method and pass in an # object that responds to the suite message with a # Test::Unit::TestSuite. This can be as simple as passing in your # TestCase class (which has a class suite method). It might look # something like this: # # require 'test/unit/ui/console/testrunner' # Test::Unit::UI::Console::TestRunner.run(TC_MyTest) # # # == Test Suite # # As more and more unit tests accumulate for a given project, it # becomes a real drag running them one at a time, and it also # introduces the potential to overlook a failing test because you # forget to run it. Suddenly it becomes very handy that the # TestRunners can take any object that returns a Test::Unit::TestSuite # in response to a suite method. The TestSuite can, in turn, contain # other TestSuites or individual tests (typically created by a # TestCase). In other words, you can easily wrap up a group of # TestCases and TestSuites like this: # # require 'test/unit/testsuite' # require 'tc_myfirsttests' # require 'tc_moretestsbyme' # require 'ts_anothersetoftests' # # class TS_MyTests # def self.suite # suite = Test::Unit::TestSuite.new # suite << TC_MyFirstTests.suite # suite << TC_MoreTestsByMe.suite # suite << TS_AnotherSetOfTests.suite # return suite # end # end # Test::Unit::UI::Console::TestRunner.run(TS_MyTests) # # Now, this is a bit cumbersome, so Test::Unit does a little bit more # for you, by wrapping these up automatically when you require # 'test/unit'. What does this mean? It means you could write the above # test case like this instead: # # require 'test/unit' # require 'tc_myfirsttests' # require 'tc_moretestsbyme' # require 'ts_anothersetoftests' # # Test::Unit is smart enough to find all the test cases existing in # the ObjectSpace and wrap them up into a suite for you. It then runs # the dynamic suite using the console TestRunner. # # # == Questions? # # I'd really like to get feedback from all levels of Ruby # practitioners about typos, grammatical errors, unclear statements, # missing points, etc., in this document (or any other). # module Unit # Set true when Test::Unit has run. If set to true Test::Unit # will not automatically run at exit. def self.run=(flag) @run = flag end # Already tests have run? def self.run? @run ||= false end end end at_exit do unless $! || Test::Unit.run? Kernel.exit Test::Unit::AutoRunner.run end end PK`]Buxx)__pycache__/__init__.cpython-36.opt-2.pycnu[PK`]2#__pycache__/__init__.cpython-36.pycnu[PK`]2) __pycache__/__init__.cpython-36.opt-1.pycnu[PK`]  I support/testresult.pynu[PK`]r&XX3%support/__pycache__/testresult.cpython-36.opt-1.pycnu[PK`]]1VDsupport/__pycache__/__init__.cpython-36.opt-2.pycnu[PK`] P  38&support/__pycache__/testresult.cpython-36.opt-2.pycnu[PK`]m6Dsupport/__pycache__/script_helper.cpython-36.opt-2.pycnu[PK`]/J0Zsupport/__pycache__/script_helper.cpython-36.pycnu[PK`]8\p?p?+#vsupport/__pycache__/__init__.cpython-36.pycnu[PK`]/J6support/__pycache__/script_helper.cpython-36.opt-1.pycnu[PK`]>>1support/__pycache__/__init__.cpython-36.opt-1.pycnu[PK`]r&XX-Qsupport/__pycache__/testresult.cpython-36.pycnu[PK`] ~0support/script_helper.pynu[PK`]C敏..Gsupport/__init__.pynu[PK`]LB2 u__init__.pynu[PKbd]z# x__init__.pycnu[PKbd]z# {__init__.pyonu[PKbd]J[test_support.pycnu[PKbd]g 2))݀script_helper.pynu[PKbd]GKFFscript_helper.pyonu[PKbd]&=Asupport/__init__.pycnu[PKbd]Oaasupport/__init__.pyonu[PKbd];rq##support/script_helper.pyonu[PKbd] (support/script_helper.pycnu[PKbd]GKFscript_helper.pycnu[PKbd]J[test_support.pyonu[PKbd]ӨqOOtest_support.pynu[PK]((Ttest_program.pyonu[PK]\pqqCtest_setups.pyonu[PK]CVEEwvtest_discovery.pyonu[PK]o5z4z4test_assertions.pycnu[PK]ú((ytest_program.pycnu[PK]D  dummy.pyonu[PK]S.#Ď<<] test_suite.pycnu[PK]S.#Ď<<)W test_suite.pyonu[PK]+%% test_skipping.pycnu[PK]Fcw!! test_runner.pynu[PK]o5z4z4 test_assertions.pyonu[PK]grx%% S test_break.pynu[PK]}'96 test_functiontestcase.pycnu[PK]YoIN test_functiontestcase.pynu[PK]Ij̟''test_ttk/__init__.pycnu[PK]ž''0?test_ttk/test_extensions.pyonu[PK]p9gtest_ttk/__init__.pyonu[PK]8 htest_ttk/test_widgets.pycnu[PK]d67>>Ytest_ttk/test_functions.pyonu[PK]GCCϘtest_ttk/test_functions.pynu[PK]d67>>test_ttk/test_functions.pycnu[PK]M3 test_ttk/test_style.pycnu[PK]ž''(test_ttk/test_extensions.pycnu[PK]M3 Ptest_ttk/test_style.pyonu[PK]8^test_ttk/test_widgets.pyonu[PK]B,,Otest_ttk/test_extensions.pynu[PK]@ S}test_ttk/support.pycnu[PK]M,76test_ttk/support.pynu[PK]V test_ttk/test_widgets.pynu[PK]test_ttk/__init__.pynu[PK]@ S&test_ttk/support.pyonu[PK]ܐb b Ftest_ttk/test_style.pynu[PK]T+ + runtktests.pycnu[PK]0<477Wtest_tkinter/test_text.pycnu[PK]0<477test_tkinter/test_text.pyonu[PK]-ԠԠ'Ytest_tkinter/test_geometry_managers.pyonu[PK]TDktest_tkinter/__init__.pycnu[PK]=,,]ltest_tkinter/test_variables.pycnu[PK]TDJtest_tkinter/__init__.pyonu[PK]pr#test_tkinter/test_font.pynu[PK]=,,Rtest_tkinter/test_variables.pyonu[PK]*?test_tkinter/test_misc.pycnu[PK]VItest_tkinter/test_font.pycnu[PK]6Зtest_tkinter/test_loadtk.pynu[PK]ltest_tkinter/test_widgets.pycnu[PK]test_tkinter/test_loadtk.pyonu[PK]Kww&test_tkinter/test_geometry_managers.pynu[PK]Κtest_tkinter/test_loadtk.pycnu[PK]% test_tkinter/test_variables.pynu[PK]!=޼test_tkinter/test_text.pynu[PK]-ԠԠ'test_tkinter/test_geometry_managers.pycnu[PK]3,O'>'>)jtest_tkinter/test_images.pycnu[PK]VItest_tkinter/test_font.pyonu[PK]ltest_tkinter/test_widgets.pyonu[PK]rtest_tkinter/test_misc.pynu[PK]3,O'>'>test_tkinter/test_images.pyonu[PK] Vtest_tkinter/test_widgets.pynu[PK])test_tkinter/__init__.pynu[PK]3(4(4qtest_tkinter/test_images.pynu[PK]*test_tkinter/test_misc.pyonu[PK]Mf}g}g.widget_tests.pyonu[PK]שmPmPdwidget_tests.pynu[PK]]W>m _hawkey_test.sonuȯPK0G]y3 3 7unit/util/observable.rbnu[PK0G]}hUUpCunit/util/procwrapper.rbnu[PK0G] Hunit/util/backtracefilter.rbnu[PK0G]ݮ?3G3GvMunit/assertions.rbnu[PK0G]K4unit/testresult.rbnu[PK0G] Kunit/error.rbnu[PK0G]Fӥ"unit/testsuite.rbnu[PK0G]xunit/testcase.rbnu[PK0G]aAmVV unit/autorunner.rbnu[PK0G]=!n n unit/collector/dir.rbnu[PK0G]++Xunit/collector/objectspace.rbnu[PK0G] J))unit/assertionfailederror.rbnu[PK0G]&&Eunit/failure.rbnu[PK0G]\~!~!unit/ui/fox/testrunner.rbnu[PK0G]2>>q unit/ui/gtk2/testrunner.rbnu[PK0G]`Dc"c"uO unit/ui/tk/testrunner.rbnu[PK0G]K r unit/ui/testrunnerutilities.rbnu[PK0G]9977v unit/ui/gtk/testrunner.rbnu[PK0G]o/ˮ unit/ui/console/testrunner.rbnu[PK0G] 000 unit/ui/testrunnermediator.rbnu[PK0G]2Vii! unit/collector.rbnu[PK0G]$q+q+ unit.rbnu[PK0s