bgdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z ddl mZddlmZddlmZe Ze eefZes"d ejeejd <d#dZdZdZd$dZd%dZd&dZefd'd"Z dS)(z,Utility functions for configuration testing.) annotationsN)Path)AnyDict)Mock) PY38_PLUS)Runc|S)N)r_s t/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/testutils/configuration_test.pyrstested_configuration_file str | PathsuffixstrdefaultreturncJ|}t|}|j|jd|z }|rSt |d5}|}dddn #1swxYwYt jd|nt jd|||S)zKReturn the expected value from the file if it exists, or the given default..utf8)encodingNz %s exists.z%s not found, using '%s'.)rparentstemexistsopenreadlogginginfo)rrrexpectedpathexpected_result_pathfs rget_expected_or_defaultr'"s H ) * *D;DI)@)@)@)@@""$$Q & 8 8 8 AvvxxH                \#78888 02FPPP Os A,,A03A0functional_appendfunctional_removeconfiguration_pathdefault_configurationPylintConfigurationctj|}t|dd}tj|}|D]\}}|t kr+|D]\}}||xx|z cc<;|tkrF|D]0\}}g} ||D]} | |vr| | | ||<1|||<|S)zIGet the expected parsed configuration of a configuration functional test.z result.jsonz{}rr) copydeepcopyr'jsonloadsitemsEXPECTED_CONF_APPEND_KEYEXPECTED_CONF_REMOVE_KEYappend) r*r+resultconfig_as_json to_overridekeyvaluefkeyfvalue new_value old_values rget_expected_configurationr@;s$]0 1 1F,=$N*^,,K!''))   U * * * %  ' ' ft &  ' , , , %  ) ) f !'44I ..!((333(t  ) F3KK Mr suffix_filter list[Path]cpt|fdjDS)zEReturn all the file related to a test conf file ending with a suffix.cg|]R}t|jj.t|P|SSr )rr startswithendswith).0p conf_pathrAs r z%get_related_files..Ysc    qv;; ! !). 1 1 7:!ffoom6T6T     r)rriterdir)rrArIs `@rget_related_filesrLTsS.//I     !))++   ruser_specific_pathrtuple[int, str]cdd}d}t|d}t|dkrtjd||dS|stjdd S|d} t t |jd d d }n/#t$r"}tjd |||Yd}~dSd}~wwxYwt||dd}tjd|||| |t| |fS)z-Get the expected output of a functional test.rzwe expect a single file of the form 'filename.32.out' where 'filename' represents the name of the configuration file, and '32' the expected error code.out)rAzToo much .out files for %s %s.)zout file is brokenz9.out file does not exists, so the expected exit code is 0)rrr)maxsplitrRz-Wrong format for .out file name for %s %s: %sNz.outrr.z4Output exists for %s so the expected exit code is %s)abspathrelpath)rLlenr!errorr"intrrrsplit Exceptionr'formatr relative_to)r*rM exit_codemsgpossible_out_filesr$eoutputs rget_expected_outputrb`sI P++=USSS "" ,     ('   PQQQu a D (DI--cA->>rBCC ((( ;      ('''''(%i#5#5#5rF L> fmm"'((445GHH$ s"r}s~ 32""""""  &&&&&&3 223C5CNDDDB001*/.2    ....d9A6666666r