B ^v<@s dZddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z ddl mZddZGd d d ejZd d ZGd ddejZGdddZGdddZGdddZGdddeZGdddZGdddejZedkredS)z3 Test cases for the repr module Nick Mathewson N)create_empty_fileverbose)repr)Repr)recursive_reprcCs d}xt|D] }|f}qW|S)N)range)Znestingtirr)/usr/lib64/python3.7/test/test_reprlib.py nestedTuples r c@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS) ReprTestscCs|j}|tdd|tddd}t|dddt|dd}|t|||td td d }t|dddt|dd}|t||dS) Nabcz'abc'Zabcdefghijklmnopz'abcdefghijklmnop'Zz ) r ClassWithReprrrClassWithFailingReprid assertTrue startswithendswithZassertInfind)rrZi1Zi2rZi3rrrr test_instances$zReprTests.test_instancecCs"tdd}||d|dS)NcSs|S)Nr)xrrr z'ReprTests.test_lambda..z0.z*.get_cell..innerr)rFr)r;r get_cells z%ReprTests.test_cell..get_cellrz6z) __closure__Z assertRegexrr)rrGr;rrr test_cells zReprTests.test_cellcCsd|j}|ttjdGddd}t|j}|t|dt|j}|t|ddS)Nz"c@seZdZddZdS)z%ReprTests.test_descriptors..CcSsdS)Nr)clsrrr foor=z)ReprTests.test_descriptors..C.fooN)__name__ __module__ __qualname__rKrrrr CsrOzrBrCrDrIrTrWrrrr r s 5  r c Cs(t|ddd}||WdQRXdS)NwASCII)encoding)openwrite)pathtextfprrr write_filesr`c@steZdZdZddZddZddZdd Zd d Ze d d dZ ddZ ddZ ddZe dddZdS) LongReprTest3areallylongpackageandmodulenametotestreprtruncationcCstj|j|_tj|j|j|_tj|jddt|jt tj|jdtj|jddt|jt tj|jdt |_ t j d|j tdS)NT) ignore_errorsz __init__.pyr)osr]joinlongnamepkgname subpkgnameshutilZrmtreemkdirrgetcwdheresysinsert importlibinvalidate_caches)rrrr setUps   zLongReprTest.setUpcCsg}x@t|jD]0\}}}x$||D]}|tj||q&WqW||j||x.|D]&}tj|rt |qht |qhWt jd=dS)Nr) rdwalkrgappendr]resortreverseisdirrmdirremoverm)rZactionsdirpathZdirnames filenamesnameprrr tearDowns    zLongReprTest.tearDowncCst|j}|dt|jd7}|t|dtd7}|ttjdtd}tjdkrv|dkrv|d|ntjdkrt rt d|dS) Nrrz.pyzx.pyntizDtest paths too long (%d characters) for Windows' 260 character limitzcached_path_len =) lenrlrfroutilcache_from_sourcerdr{ZskipTestrprint)rZ module_nameZsource_path_lenZcached_path_lenrrr _check_path_limitationss  z$LongReprTest._check_path_limitationscCstd|_||jttj|j|jdt ddl m }|}| t |d|j|jf| t tddS)Nz.pyr)rbzz)ZmaxDiffrrgrrdr]rerhrorpgareallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncationrbrrrL__file__rm)rrbmodulerrr test_modules  zLongReprTest.test_modulecCsT|d|j}ttj|jddtddl m }|t |j d|j dS)NrKzfoo.pyzclass foo(object): pass r)rKz) rrr`rdr]rerhrorprrKrrL)rrrKrrr test_types   zLongReprTest.test_typezneed a suitable objectcCsdS)Nr)rrrr test_object*szLongReprTest.test_objectcCsP|dttj|jddtddlm }| t |j d|j dS)Nbarzbar.pyzclass bar: pass r)rz) rr`rdr]rerhrorprrrrrL)rrrrr test_class0s   zLongReprTest.test_classcCsZ|dttj|jddtddlm }| }| t | d|j dS)Nbazzbaz.pyzclass baz: pass r)rz<%s.baz object at 0x)rr`rdr]rerhrorprrr6rr7rL)rrZibazrrr r:;s   zLongReprTest.test_instancecCs|d|j}ttj|jddtddl m }t |j j }||d|| }t |j }||d|jf|dS)Nquxzqux.pyzclass aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: def amethod(self): pass r)rzz)rrrsrrr)rmrrr test_recursive_reprs        z%TestRecursiveRepr.test_recursive_reprcCsBddlm}tj}tj}x$|D]}|t||t||qWdS)Nr)WRAPPER_ASSIGNMENTS) functoolsrrrrZassertIsgetattr)rassignedrrr{rrr test_assigned_attributess   z*TestRecursiveRepr.test_assigned_attributesN)rLrMrNrrrrrr rs r__main__)rrmrdriroimportlib.utilrZ test.supportrrreprlibrrrrr ZTestCaser r`rar3r4rrrrrLmainrrrr s0   C