a  ze!@sdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z e Gdddej Zedkr|edS) z4Tests for the pindent script in the Tools directory.N)support)assert_python_ok) scriptsdirskip_if_missingc@sreZdZejedZddZddZ ddZ dd Z d d Z d d Z ddZddZddZddZddZdS) PindentTestsz pindent.pyc Csht|L}t|$}|||Wdn1s<0YWdn1sZ0YdSN)open assertEqual readlines)selfZfn1Zfn2f1f2rP/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_tools/test_pindent.pyassertFileEqualszPindentTests.assertFileEqualcGs^tjtj|jf|tjtjdd}||\}}Wdn1sF0Y|||S)NT)stdinstdoutuniversal_newlines) subprocessPopensys executablescriptPIPE communicateZ assertIsNone)r sourceargsprocouterrrrrpindents, zPindentTests.pindentcCsddd|DdS)N css|]}|VqdSr)lstrip).0linerrr !z+PindentTests.lstriplines..)join splitlines)r datarrr lstriplines szPindentTests.lstriplinesc Cs&d|_t}tj|d}t|j}|}Wdn1sH0Yt|d}| |Wdn1s|0Yt |jd|\}}}| |d| |d|d}| tj |t| }| ||Wdn1s0Yt|}|} Wdn1s,0Yt| dd| || d|| ||d| t |jd|\}}}| |d| |dt| }| || Wdn1s0Yt| }| ||Wdn1s0Y||} t|d}| | Wdn1s@0Yt |jd|\}}}| |d| |dt| }| || Wdn1s0Yt|}|} Wdn1s0Yt| dd| || d| Wdn1s0YdS) Nz_test.pyw-dr&~exec-c-r)ZmaxDiffrZtemp_dirospathr'rrreadwriterr Z assertTrueexistscompiler r*) r Z directoryZ data_pathfclosedrcrrZbackupcleanbrokenZindentedrrr test_selftest#sL  & (   . (    0 0  *   0 ( zPindentTests.test_selftestc CsP|||d||||d|||}|||dddd|dS)Nr/r,r0-e-s4)r r r*r r:r8r;rrr pindent_testNs zPindentTests.pindent_testcCs$td}td}|||dS)Na: if a: pass if a: pass else: pass if a: pass elif: pass else: pass while a: break while a: break else: pass for i in a: break for i in a: break else: pass try: pass finally: pass try: pass except TypeError: pass except ValueError: pass else: pass try: pass except TypeError: pass except ValueError: pass finally: pass with a: pass class A: pass def f(): pass a` if a: pass # end if if a: pass else: pass # end if if a: pass elif: pass else: pass # end if while a: break # end while while a: break else: pass # end while for i in a: break # end for for i in a: break else: pass # end for try: pass finally: pass # end try try: pass except TypeError: pass except ValueError: pass else: pass # end try try: pass except TypeError: pass except ValueError: pass finally: pass # end try with a: pass # end with class A: pass # end class A def f(): pass # end def f textwrapdedentrAr r:r8rrrtest_statementsTs A MzPindentTests.test_statementscCs$td}td}|||dS)Nz def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 else: print 'oops!' aJ def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 # end if else: print 'oops!' # end if # end def foobar rBrErrrtest_multilevels zPindentTests.test_multilevelc Cstd}td}|||d||||d|||}|||dddd|td }td }|||d||||d|||}|||d|dS) Nz\ if a: if b: pass z if a: if b: pass # end if # end if r/r,r0r=r>9zD if a: if b: pass zo if a: if b: pass # end if # end if )rCrDr r r*r@rrrtest_preserve_indentss      z"PindentTests.test_preserve_indentscCs@td}td}|||d||||d|dS)Nz class\ \ A: def \ f: pass z class\ \ A: def \ f: pass # end def f # end class A r/r,)rCrDr r rErrrtest_escaped_newline!s z!PindentTests.test_escaped_newlinecCs$td}td}|||dS)Nz4 if a: pass zI if a: pass # end if rBrErrrtest_empty_line9s  zPindentTests.test_empty_linecCs$td}td}|||dS)Nz# if a: pass z8 if a: pass # end if rBrErrr test_onelineGs  zPindentTests.test_onelineN)__name__ __module__ __qualname__r1r2r'rrrr r*r<rArFrGrIrJrKrLrrrrrs +"r__main__)__doc__r1rZunittestrrCtestrZtest.support.script_helperrZtest.test_toolsrrZTestCaserrMmainrrrrs  D