a  ze@sddlmZedZddlZddlZddlZddlZddl Z ddl Z ddl Z e dej ZGdddZGdd d eZejeed \ZZGd d d eZejeed \ZZGd ddZGdddeZejeed \ZZGdddeZejeed \ZZedkre dS))utilzimportlib.machineryNz&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)c@sleZdZdZdZdeeZdZddZddZ d d Z d d Z d dZ ddZ ddZddZddZdS) EncodingTestüÉz {0} = '{1}' _tempc Cst|jj}t||jd}||Wdn1s>0Y|j|j||j}||WdS1s|0YdS)Nwb)rcreate_modules module_nameopenwrite machinerySourceFileLoaderload)selfsourcemappingfileloaderrc/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_importlib/source/test_source_encoding.pyrun_test%s( zEncodingTest.run_testcCs2d|}|dg}||j|d|S)Nz # coding={0}utf-8 )formatencodeappend source_linejoin)rencoding encoding_line source_linesrrr create_source-s  zEncodingTest.create_sourcecCs"d}d|d}||dS)Nz# coding=koi8-rz {0} a=42 zkoi8-r)rrr)rr rrrrtest_non_obvious_encoding4sz&EncodingTest.test_non_obvious_encodingcCs||jddSNr)rrrrrrrtest_default_encoding=sz"EncodingTest.test_default_encodingcCsd}||}||dS)NLatin-1r"r)rrrrrrtest_encoding_on_first_lineAs z(EncodingTest.test_encoding_on_first_linecCsd|d}||dS)Ns#/usr/bin/python r'r(rrrrrtest_encoding_on_second_lineGsz)EncodingTest.test_encoding_on_second_linecCs|tj|jddSr$)rcodecsBOM_UTF8rrr%rrrtest_bomLszEncodingTest.test_bomcCstj|d}||dSr$)r,r-r"rr*rrrtest_bom_and_utf_8PszEncodingTest.test_bom_and_utf_8cCsHtj|d}|t||Wdn1s:0YdS)Nzlatin-1)r,r-r"Z assertRaises SyntaxErrorrr*rrrtest_bom_conflictUs zEncodingTest.test_bom_conflictN)__name__ __module__ __qualname__variable characterrrr rr"r#r&r)r+r.r/r1rrrrrs   rc@seZdZddZdS)EncodingTestPEP451cCs,t|j}tj|j||_|||SN)types ModuleTyper importlibrspec_from_loader__spec__ exec_module)rrmodulerrrr]s  zEncodingTestPEP451.loadNr2r3r4rrrrrr7[sr7)r c@seZdZddZdS)EncodingTestPEP302cCsDt(tdt||jWdS1s60YdSNignore)warningscatch_warnings simplefilterDeprecationWarning load_moduler )rrrrrrks  zEncodingTestPEP302.loadNr@rrrrrAisrAc@s,eZdZddZddZddZddZd S) LineEndingTestc Csd}gd}||}t|f}t||d}||Wdn1sP0Y|j|||}|||WdS1s0YdS)Nr)sa = 42sb = -13r)rrr r r r rr)rZ line_endingr r!rrrrrrrr{s  (zLineEndingTest.run_testcCs|ddS)N rr%rrrtest_crszLineEndingTest.test_crcCs|ddS)Ns rLr%rrr test_crlfszLineEndingTest.test_crlfcCs|ddS)NrrLr%rrrtest_lfszLineEndingTest.test_lfN)r2r3r4rrMrNrOrrrrrIvs rIc@seZdZddZdS)LineEndingTestPEP451cCs(t|}tj|||_|||Sr8)r9r:r;rr<r=r>)rrr r?rrrrs  zLineEndingTestPEP451.loadNr@rrrrrPsrPc@seZdZddZdS)LineEndingTestPEP302cCsBt&tdt||WdS1s40YdSrB)rDrErFrGrH)rrr rrrrs  zLineEndingTestPEP302.loadNr@rrrrrQsrQ__main__) rZimport_importlibr r,importlib.utilr;rer9 unicodedataZunittestrDcompileASCIIZ CODING_RErr7Z test_bothZFrozen_EncodingTestPEP451ZSource_EncodingTestPEP451rAZFrozen_EncodingTestPEP302ZSource_EncodingTestPEP302rIrPZFrozen_LineEndingTestPEP451ZSource_LineEndingTestPEP451rQZFrozen_LineEndingTestPEP302ZSource_LineEndingTestPEP302r2mainrrrrs:  H