bg2bddlmZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl mZ ddl mZmZddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZmZm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(e ee)e*fZ+e e,j-dz Z.GddZ/dS)) annotationsN)Counter)StringIO)Path)TextIOTuple)Config)checkers)_config_initialization)IS_PYPY)PyLinter)Message) _EXPECTED_RE _OPERATORS UPDATE_OPTION)FunctionalTestFile NoFileErrorparse_python_version) OutputLine)FunctionalTestReportertesting_pylintrcceZdZdZ d(d)dZd*d Zd*d Zd+d Zd,dZe d-dZ e d.dZ d/dZ d/dZ d0dZd0dZd*dZd1d!Zd2d$Zd3d'ZdS)4LintModuleTestN test_filerconfig Config | NonereturnNonec&t}t|_d|jj_t j|jt} |j}|j d|j d|j dn#t$rYnwxYw||_ |j g}n#t$rdg}YnwxYw|r| dr|5}d||D}|d|d |d dddn #1swxYwY|d d d |g|jjdt*d|jjdt*d|jjdt*d|jjddg|jjddg|jjddg|jjddt-|j|||t.j|jjjk|_|jrt6rt.jdk|_||_dS) Nrzsuppressed-messagezlocally-disabledzuseless-suppressionminimal_messages_configch|] }|d S).0msgs r/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/testutils/lint_module_test.py z*LintModuleTest.__init__..Fs%V%V%Vc!f%V%V%Vz astroid-errorfatalz syntax-errorz --disable=allz --enable=,z --min_pyver))typedefaultz --max_pyver)rz--min_pyver_end_position)z --requiresc@d|dDS)Nc6g|]}|Sr$stripr&is r( z=LintModuleTest.__init__....Xs )J)J)J!'')))J)J)Jr*r,splitss r(z)LintModuleTest.__init__..Xs)J)JQWWS\\)J)J)Jr*z--except_implementationsc@d|dDS)Nc6g|]}|Sr$r6r8s r(r:z=LintModuleTest.__init__....\ <<.\<...arBr*r,r;r=s r(r?z)LintModuleTest.__init__..arCr*z&--exclude_from_minimal_messages_configF)r0) args_list config_filereporter)r2 )rr _linterr persistentr initializePYLINTRC option_filedisabler _test_filesource getoption_open_source_fileget_expected_messagesaddextendjoin _arg_parser add_argumentrr sys version_infomin_pyver_end_position_check_end_positionr _config)selfrr_test_reporterrc_fileargsfmessages_to_enables r(__init__zLintModuleTest.__init__,s011zz )* &DL)))' +G L !5 6 6 6 L !3 4 4 4 L !6 7 7 7 7    D $ $%DD   4DDD   Wf&&'@AA W'')) 7Q%V%V8R8RST8U8U%V%V%V""&&777"&&w///"&&~666  7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 KK*Tchh?Q6R6R*T*TU V V V  --  4f .     --  4f .     -- &-A6 .     -- JJTV .     -- &<< .    -- !<< .    -- 4e .     LDg      3 J J    # B B'*'76'AD $ s8AB** B76B7C CC AE44E8;E8c||r=tjdtjddddg}|jjjD]7} t|#t$r| |Y4wxYw|r+tjdd |d |jjj }|r?tj|vr*d }tj|tjz|jjj}|rAtj|vr!tjd tj|jrA|jd r)|jjjrtjd dSdSdSdS)NzTest cannot run with Python  r#)maxsplitr.z Requires r,z to be present.z-Test cannot run with Python implementation %rzTest cannot run on platform r!z,Test excluded from --minimal-messages-config)!_should_be_skipped_due_to_versionpytestskiprZversionr<rJrrequires __import__ ImportErrorappendrWexcept_implementationsplatformpython_implementationexclude_platformslowerr^rR$exclude_from_minimal_messages_config)r_missing requirementrrr'excluded_platformss r(setUpzLintModuleTest.setUpus  1 1 3 3  KWs{/@/@q/@/Q/QRS/TWWW   <.7 , ,K ,;'''' , , ,{+++++ ,  H KFCHHW$5$5FFF G G G!%!4!K ! D-//3IIIE C("@"B"BBCCC!\0B  M|!!##'999 K3<KKLLL L H &&'@AA H #H H KF G G G G G  H H H H H Hs(A88BBc.|dSN)_runTestr_s r(runTestzLintModuleTest.runTests r*boolc~tj|jjjkptj|jjjkSr})rZr[rJr min_pyver max_pyverrs r(rjz0LintModuleTest._should_be_skipped_due_to_versions3  t|2< < @$,"5"?? r*strcT|jjd|jjd|jjdS)Nz (ri))rPbase __class__ __module____name__rs r(__str__zLintModuleTest.__str__s0/&``$.*C``dnF]````r*streamrMessageCounterct}t|D]4\}}tj|}||d}||dz}nO|ds|dr|dzt |z}nt |}|d}|d}|r0t|}t|tj |s|d d D]&} ||| fxxdz cc<'6|S) zParses a file and get expected messages. :param stream: File-like input stream. :type stream: enumerable :returns: A dict mapping line,msg-symbol tuples to the count on this line. :rtype: dict Nliner#+-rmopmsgsr,) r enumeratersearchgroup startswithintrrrZr[r<r7) rmessagesr9rmatchlinenormrrequiredmsg_ids r(rTz$LintModuleTest.get_expected_messagess[$+99 (( 6 6GAt '--E};;v&&D|Q%% #)=)= #QT*Tkk),,GT""B /88!"~c&6AA++f--33C88 6 6/000A50000 6r*expected_entriesactual_entries1tuple[MessageCounter, dict[tuple[int, str], int]]c|}||i}t|D],\}}|dkr!|||dkr| ||<-||fS)z{Takes two multisets and compares them. A multiset is a dict with the cardinality of the key as the value. r)copysubtractlistitemspop)rrrx unexpectedkeyvalues r(multiset_differencez"LintModuleTest.multiset_differences#''))((( w}}// - -JCzz C   199',fJsO ""r*cx t|jjdS#t$rt dcYSwxYw)Nutf-8encodingr )openrPexpected_outputFileNotFoundErrorrrs r(_open_expected_filez"LintModuleTest._open_expected_filesL 7'JJJ J    B<<    s 99c|jjdkrt|jjdSd|jjvrt|jjdSt|jjdS)Ninvalid_encoded_datarrlatin1utf8)rPrrrQrs r(rSz LintModuleTest._open_source_filesk ? #9 9 9.AAA A t+ + +.BBB BDO*V<<<.s9%%%#C)ABB%%%r*test)rSrTrrcsvreader)r_rc expected_msgsexpected_output_liness` r( _get_expectedzLintModuleTest._get_expecteds2  # # % % : 66q99M : : : : : : : : : : : : : : : &#IIM  % % ' ' 1%%%%:a00%%% !                333s8<<'"BBBcR|jjj}|dt }g}|D]i}|jdksJd|jd||j|jfxxdz cc<|tj ||j j||fS)Nc*|j|j|jfSr})rsymbolr')ms r(r?z,LintModuleTest._get_actual..sQVQXqu$=r*rr+z#Pylint analysis failed because of ''r#) rJrHrsortrrr'rrqrfrom_msgr])r_r received_msgsreceived_output_linesr's r( _get_actualzLintModuleTest._get_actuals"&,"7"@ == >>>(/ "  C g%%%?SW???&%% #(CJ. / / /1 4 / / / ! ( (#C)ABB    333r*c,d}|jjg}|j||\}}|\}}||ksJ||||||||dS)NT)rPrQrJcheckrrerror_msg_for_unequal_messages_check_output_text)r___tracebackhide__modules_to_checkexpected_messagesractual_messages actual_outputs r(r~zLintModuleTest._runTests  O23 +,,,-1-?-?-A-A*?)-)9)9););&  0 0 0  . . .    1 0 0  1?MRRRRRr*rrrlist[OutputLine]c(d|jjdg}|||\}}|rA|d|dt |D|rA|d|dt |Dd|}|jrE|jdd kr'|d z }|dd |Dz }|S) NzWrong results for file "z":z Expected in testdata:c3@K|]}d|ddd|dVdSrgr3z: r#Nr$r%s r( z@LintModuleTest.error_msg_for_unequal_messages..s>KKC/3q6///s1v//KKKKKKr*z Unexpected in testdata:c3@K|]}d|ddd|dVdSrr$r%s r(rz@LintModuleTest.error_msg_for_unequal_messages..s>NNC/3q6///s1v//NNNNNNr* verboserz& Actual pylint output for this file: c34K|]}t|VdSr})r)r&os r(rz@LintModuleTest.error_msg_for_unequal_messages..s("A"Aa3q66"A"A"A"A"A"Ar*) rPrrrqrVsortedrWr^rR)r_rrrr'rxr error_msgs r(rz-LintModuleTest.error_msg_for_unequal_messagess0 C$/*>BBBC"66     L JJ0 1 1 1 JJKK6'??KKK K K K  O JJ2 3 3 3 JJNN6*;M;MNNN N N NIIcNN < BDL229==AA D DI "A"A="A"A"AAA AIr*expected_linesreceived_linescxt|t|z }t|t|z }d|jjd}tjd}|r!|dz }t ||D] }||dz } |r|dz }t ||D] }||dz } |dt d |jjd z }t}tj |d } t ||D])}| | *|| z }|S) NzWrong output for 'z.txt':rz - Missing lines: rrz - Unexpected lines: zY You can update the expected output automatically with: 'python tests/test_functional.py z -k "test_functional[z/]"' Here's the update text in case you can't: r)dialect) setrProperator attrgetterrrrrwriterwriterowto_csvgetvalue) r_rrrxrrsort_by_line_numberr expected_csvrs r(error_msg_for_unequal_outputz+LintModuleTest.error_msg_for_unequal_outputs n%%N(;(;;((3~+>+>> E)=EEE &1(;;  ) / /Iw,?@@@ ) )[[[(  1 2 2Iz/BCCC ) )[[[( >3@>>$(O$8>>> I $::LZ f===F~3FGGG / / .... ..00 0Ir*_rcN||ksJ|||dS)zlThis is a function because we want to be able to update the text in LintModuleOutputUpdate. N)r)r_rrrs r(rz!LintModuleTest._check_output_text;s8-///1R1R ]2 2 /////r*r})rrrrrr)rr)rr)rr)rrrr)rrrrrr)rr)rr)rrrrrrrr)rrrrrr)rrrrrrrr)rr __qualname__maxDiffrer{rrjr staticmethodrTrrrSrrr~rrrr$r*r(rr)s|GFJGGGGGRHHHH:    aaaa\@###\#$    ==== 4 4 4 4 4 4 4 4 S S S S,<       r*r)0 __future__rrrrsrZ collectionsriorpathlibrtyping CounterTyperrrk_pytest.configr pylintr #pylint.config.config_initializationr pylint.constantsr pylint.lintr pylint.message.messagerpylint.testutils.constantsrrr%pylint.testutils.functional.test_filerrrpylint.testutils.output_liner#pylint.testutils.reporter_for_testsrrrr__file__parentrMrr$r*r(r s #"""""  )))))) !!!!!!FFFFFF$$$$$$ ******NNNNNNNNNN 433333FFFFFFU38_- 4>> #5 5] ] ] ] ] ] ] ] ] ] r*