'L imZdZddlmZddlmZddlmZddlZddlZddlZddl Z ddl m Z ddl Z ddl mZdd l mZdd l mZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl$m%Z%ddl$m&Z&ddl'm(Z(dZ)dZ*eejVGddZ,GddZ-Gdd Z.Gd!d"Z/Gd#d$Z0d-d%Z1d.d&Z2ed'(d/d)Z3e d0d*Z4d1d+Z5d2d,Z6y)3z%Implementation of the cache provider.) annotations) Generator)IterableN)Path)final)resolve_from_str)rm_rf) CollectReport)nodes)TerminalWriter)Config)ExitCode)hookimpl)Parser)check_ispytest)fixture)FixtureRequest)Session) Directory)File) TestReporta.# pytest cache directory # This directory contains data from the pytest's cache plugin, which provides the `--lf` and `--ff` options, as well as the `cache` fixture. **Do not** commit this to version control. See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information. sSignature: 8a477f597d28d172789f06886806bc55 # This file is a cache directory tag created by pytest. # For information about cache directory tags, see: # https://bford.info/cachedir/spec.html ceZdZUdZej dZded<ej dZded<dZ d Z dd  dd Z e dd dd Z e ddd Zedd ddZdd ddZddZddZddZd dZd!dZd"dZy)#Cachez Instance of the `cache` fixture.F)reprr _cachedirr_configdv _ispytestc6t|||_||_yN)rrr)selfcachedirconfigr!s [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/_pytest/cacheprovider.py__init__zCache.__init__Es y!! ct||j|d}|jdr#|jr|j |d|||dS)zHCreate the Cache instance for a Config. :meta private: Tr cacheclear)rcache_dir_from_config getoptionis_dir clear_cache)clsr&r!r%s r' for_configzCache.for_configLsW y!,,Vt,D   L )hoo.? OOHO 58Vt44r)ct||j|jfD]#}||z }|jst |%y)zfClear the sub-directories used to hold cached directories and values. :meta private: N)r_CACHE_PREFIX_DIRS_CACHE_PREFIX_VALUESr.r )r0r%r!prefixrs r'r/zCache.clear_cacheXsF y!--s/G/GH F6!Axxza r)cbt|t|jd|jS)zRGet the path to the cache directory for a Config. :meta private: cache_dir)rr getinirootpath)r&r!s r'r,zCache.cache_dir_from_configds& y! k :FOOLLr)c t|ddl}ddlm}|j ||r|j di|n||j jdy)z7Issue a cache warning. :meta private: rN)PytestCacheWarning) stacklevel)rwarnings_pytest.warning_typesr;warnformatrhook)r$fmtr!argsr?r;s r'rAz Cache.warnmsM y!< Tzszz1D1s C LL    r)cJ|j|jddy)NT)exist_okparents)&_ensure_cache_dir_and_supporting_filesmkdir)r$paths r'_mkdirz Cache._mkdir}s 335 D$ /r)ct|}t|jdkDr td|jj |j |}|j||S)aReturn a directory path object with the given name. If the directory does not yet exist, it will be created. You can use it to manage files to e.g. store/retrieve database dumps across test sessions. .. versionadded:: 7.0 :param name: Must be a string not containing a ``/`` separator. Make sure the name contains your plugin or application identifiers to prevent clashes with other cache users. rz.name is not allowed to contain path separators)rlenparts ValueErrorrjoinpathr3rL)r$namerKress r'rJz Cache.mkdirsVDz tzz?Q MN Nnn%%d&=&=tD C r)c`|jj|jt|Sr#)rrQr4r)r$keys r' _getvaluepathzCache._getvaluepaths#~~&&t'@'@$s)LLr)c|j|} |jdd5}tj|cdddS#1swYyxYw#tt f$r|cYSwxYw)aReturn the cached value for the given key. If no value was yet cached or the value cannot be read, the specified default is returned. :param key: Must be a ``/`` separated value. Usually the first name is the name of your plugin or your application. :param default: The value to return in case of a cache-miss or invalid cache value. rUTF-8encodingN)rVopenjsonloadrPOSError)r$rUdefaultrKfs r'getz Cache.getsc!!#& 31 $Qyy| $ $ $G$ N s-AA AA AAA%$A%c|j|} |j|jt j |dd} |jd d }|5|j|dddy#t$r#}|j d|d|dYd}~yd}~wwxYw#1swYyxYw#t$r#}|j d |d|dYd}~yd}~wwxYw) aNSave value for the given key. :param key: Must be a ``/`` separated value. Usually the first name is the name of your plugin or your application. :param value: Must be of any combination of basic python types, including nested types like lists of dictionaries. zcould not create cache path z: Tr NF) ensure_asciiindentwrYrZzcache could not write path ) rVrLparentr_rAr]dumpsr\write)r$rUvaluerKexcdataras r'setz Cache.sets!!#&  KK $zz%eA>  # 0A      II.tfBse<          II-dV2cU;    s;A7B2B&7 B#BB#&B/2 C;CCc|jjry|jjjddt j d|jj5}t |}tjd}tj||jd|z t|jdd d 5}|jtdddt|jd d d 5}|jd dddt|jdd5}|jtddd |j|j|jdddy#1swYxYw#1swYxYw#1swYVxYw#t $r7}|j"t"j$t"j&fvrYd}~hd}~wwxYw#1swYyxYw)z.Create the cache dir and its supporting files.NT)rHrGzpytest-cache-files-)r5diriz README.mdxrYrZz .gitignorez%# Created by pytest automatically. * z CACHEDIR.TAGxb)rr.rhrJtempfileTemporaryDirectoryrosumaskchmodr\rQrjREADME_CONTENTCACHEDIR_TAG_CONTENTrenamer_errno ENOTEMPTYEEXIST)r$newpathrKrwraes r'rIz,Cache._ensure_cache_dir_and_supporting_filess >> "  ##D4#@  ( ((%% % =DHHUOE HHUO JJuu} %dmmK0#H (A' (dmmL13I CQAB CdmmN3T: .a,- .  DNN+" K% %  ( ( C C . .   775??ELL"AAB  +% % s.A'G?F+%G?F$"#G?F0G?$F<?G?F! G?$F- )G?0F9 5G?< G<-G72G?7G<<G??HN)r%rr&rr!boolreturnNone)r&rr!rrr)F)r%rr!rrr)r&rr!rrr)rDstrr!rrEobjectrr)rKrrr)rRrrr)rUrrr)rUr)rUrrkrrrrr)__name__ __module__ __qualname____doc__ dataclassesfieldr__annotations__rr3r4r( classmethodr1r/ staticmethodr,rArLrJrVrbrnrIr>r)r'rr7s+'k''U3It3'k''U3GV3DI&,<@ =B 5 5  CHMM38 0*M&>+r)rc<eZdZddZed ddZy)LFPluginCollWrapperc ||_d|_y)NF)lfplugin_collected_at_least_one_failurer$rs r'r(zLFPluginCollWrapper.__init__s  /4,r)T)wrapperc#Kd}t|ttzr;|jjdfd }t |j |d|_|St|tr|j|jjvr|j }|jj|js`tfd|Ds|S|jjjjt|jdd|_ |j }|Dcgc]G}|j"vs5|j%|jst|t&j(r|Ic}|dd|Scc}ww)Nc |jvSr#)rK)nodelf_pathss r'sort_keyz@LFPluginCollWrapper.pytest_make_collect_report..sort_keysyyH,,r)TrUreversec3:K|]}|jvywr#nodeid).0rr lastfaileds r' zALFPluginCollWrapper.pytest_make_collect_report..sF!qxx:5Fszlfplugin-collskip)rznodes.Item | nodes.Collectorrr) isinstancerrr_last_failed_pathssortedresultrrKrranyr& pluginmanagerregisterLFPluginCollSkipfilessessionr isinitpathr Collector) r$ collectorrSrrrrrrrs @@r'pytest_make_collect_reportz.LFPluginCollWrapper.pytest_make_collect_reportsD i9!4 5}}77H -  CJ> 3 4 (~~!A!AA!]]55 ;;FvFF" MM((66??-dmm<>Q<@D8#++$xx:-))!&&1!!U__5 q  sD(F,A F8 FNrLFPluginrr)rnodes.Collectorrz-Generator[None, CollectReport, CollectReport]rrrr(rrr>r)r'rrs05d+(+ 6++r)rc.eZdZddZe ddZy)rc||_yr#)rrs r'r(zLFPluginCollSkipfiles.__init__.s   r)ct|trZ|j|jjvr8|jxj dz c_t |jddgSy)Nrpassed)longreprr)rrrKrr_skipped_filesr r)r$rs r'rz0LFPluginCollSkipfiles.pytest_make_collect_report1sZ i &~~T]]%E%EE ,,1,$$$hbr)Nr)rrrzCollectReport | Nonerr>r)r'rr-s+! (    r)rcneZdZdZd dZd dZddZddZddZe dd dd Z dd Z y )rz;Plugin which implements the --lf (run last-failing) option.cj|_d}tfd|D|_jsJjj di|_d|_d|_d|_jdr;|j|_ jjt|dyy)N)lf failedfirstc3@K|]}j|ywr#)r-)rrUr&s r'rz$LFPlugin.__init__..EsGC&**3/Gscache/lastfailedrrzlfplugin-collwrapper)r&ractivecacherbr_previously_failed_count_report_statusrr-get_last_failed_pathsrrrr)r$r& active_keyss ` r'r(zLFPlugin.__init__Bs ) G;GG |||+1<<+;+;.ms&Ut T':&UsT)outcomerrrrr)r$rrs r'pytest_collectreportzLFPlugin.pytest_collectreporthso#88 }}/##FMM2&&&Uv}}&UU0.2DOOFMM *r)Trtryfirstc#Kd}|js|S|jrPg}g}|D]=}|j|jvr|j|-|j|?t ||_|st |jd|_n|jjdr"||dd|jj|n||z|dd|j dk(rdnd}|jjdrdnd }d |j d |||_|jd kDr9|jdk(rd nd} |xj d|jd | dz c_|Sd|_|jjddk(r;|xj dz c_|jj|ddg|dd|S|xj dz c_|Sw)Nz% known failures not in selected testsr)itemsrfailurefailuresrz firstzrerun previous  rfilefilesz (skipped )zno previously failed tests, last_failed_no_failuresnonezdeselecting all items.znot deselecting items.) rrrappendrNrrr&r-rCpytest_deselectedr) r$r&rrSpreviously_failedpreviously_passedrnounsuffix files_nouns r'pytest_collection_modifyitemsz&LFPlugin.pytest_collection_modifyitemsqs{{J ?? "  "  3;;$//1%,,T2%,,T2  3 -00A,BD )$4??+,,QR#;;((.0E!HKK118I1J03DDE!H$($A$AQ$FyJ%)[[%:%:=%Ir%d&C&C%DAdVF8T#""Q&'+':':a'?VW ##D4G4G3H*UV'WW# #AD {{$$%>?6I##'??# --E!H-=a ##'??# sG'G)c|j}|jds t|dry|jJ|jj di}||j k7r'|jj d|j yy)N cacheshow workerinputr)r&r-hasattrrrbrrn)r$rr&saved_lastfaileds r'pytest_sessionfinishzLFPlugin.pytest_sessionfinishsw   K (GFM,J ||'''!<<++,>C t . LL  / A /r)Nr&rrr)rz set[Path])r str | None)rrrr)rr rr)r&rrlist[nodes.Item]rGenerator[None])rrrr) rrrrr(rrrrrrrr>r)r'rr?sXE 1 2 2dT*11%51 1+1fBr)rcJeZdZdZd dZeddd dZd dZd dZy) NFPluginz8Plugin which implements the --nf (run new-first) option.c||_|jj|_|jJt |jj dg|_y)N cache/nodeids)r&optionnewfirstrrrnrbcached_nodeidsr$r&s r'r(zNFPlugin.__init__sH mm,, ||'''!&,,"2"2?B"GHr)Trc#Kd}|jri}i}|D]9}|j|jvr|||j<+|||j<;|j|j |j|j z|dd|jj ||S|jj d|D|Sw)Nc34K|]}|jywr#rrs r'rz9NFPlugin.pytest_collection_modifyitems..s&Ett{{&Es)rrr_get_increasing_ordervaluesr)r$rrS new_items other_itemsrs r'rz&NFPlugin.pytest_collection_modifyitemss ;;/1I13K 4;;d&9&99-1Idkk*/3K ,  4 11  "**;+=+=+?@AE!H    & &y 1     & &&Eu&E E sCCc t|ddS)NcJ|jjjSr#)rKstatst_mtime)rs r'z0NFPlugin._get_increasing_order..sdiinn.>.G.Gr)Tr)r)r$rs r'rzNFPlugin._get_increasing_orderse!GQUVVr)c|j}|jds t|dry|jdry|jJ|jj dt |j y)Nrr collectonlyr)r&r-rrrnrrrs r'rzNFPlugin.pytest_sessionfinishse   K (GFM,J    M * ||''' &1D1D*EFr)Nr)rrrr)rzIterable[nodes.Item]rrr) rrrrr(rrrrr>r)r'rrs2BI dT*+*W Gr)rc |jd}|jddddd|jdd dd d |jd d ddd|jddddd|jddddd}dtjvr1tjj tjd|}|j d|d|jddd d!d"d#d$%y&)'zxAdd command-line options for cache functionality. :param parser: Parser object to add command-line options to. generalz--lfz --last-failed store_truerzHRerun only the tests that failed at the last run (or all if none failed))actiondesthelpz--ffz--failed-firstrzyRun all tests, but run the last failures first. This may re-order tests and thus lead to repeated fixture setup/teardown.z--nfz --new-firstrzORun tests from new files first, then the rest of the tests sorted by file mtimez --cache-showr?rz_Show cache contents, don't perform collection or tests. Optional argument: glob (default: '*').)rnargsrrz --cache-clearr+z.Remove all cache contents at start of test run .pytest_cache TOX_ENV_DIRr7zCache directory path)r`rz--lfnfz--last-failed-no-failuresstorer)allrraWith ``--lf``, determines whether to execute tests when there are no previously (known) failures or when no cached ``lastfailed`` data was found. ``all`` (the default) runs the full test suite again. ``none`` just emits a message about no known failures and exits successfully.)rrchoicesr`rN)getgroup addoptionrvenvironrKjoinaddini)parsergroupcache_dir_defaults r'pytest_addoptionr&s- OOI &E OO  W  OO +  OO   OO  6   OO  =  ( "GGLLM)BDUV MM+'8?UMV OO# &X r)c|jjr)|jjsddlm}||tSy)Nr) wrap_session)rrr _pytest.mainr()r&r(s r'pytest_cmdline_mainr*s. }}v}}'9'9-FI.. r)T)rctj|d|_|jj t |d|jj t |dy)zConfigure cache system and register related plugins. Creates the Cache instance and registers the last-failed (LFPlugin) and new-first (NFPlugin) plugins with the plugin manager. :param config: pytest configuration object. Tr rnfpluginN)rr1rrrrr)r&s r'pytest_configurer-'sQ##Fd#;FL !!(6"2J? !!(6"2J?r)c^|jjJ|jjS)abReturn a cache object that can persist state between testing sessions. cache.get(key, default) cache.set(key, value) Keys must be ``/`` separated strings, where the first part is usually the name of your plugin or application to avoid clashes with other cache users. Values can be any object handled by the json stdlib module. )r&r)requests r'rr5s* >>   ++ + >>  r)c |jjdkDs|jddk7rE|jJ|jj} |j |j }d|Sy#t$r|}YwxYw)z6Display cachedir with --cache-show and if non-default.rr7rN cachedir: )rverboser8rr relative_tor9rP)r&r% displaypaths r'pytest_report_headerr5Es }}q FMM+$>/$Q||'''<<)) #"..v?KK=))  #"K #sA44 BBcddlm}|jJt}|j dt |jj z|jj js|j dy|jjd}|d}t}|jj }|tjz }|jdd|td|j|DD]}t |j!|} |jj#| |} | |ur|j | d R|j | d || j%D]} |j d | z|tj&z } | jrt| j|} |jdd || D][}|j)st |j!|} |j | d |j+j,]y)a}Display cache contents when --cache-show is used. Shows cached values and directories matching the specified glob pattern (default: '*'). Displays cache location, cached test results, and any cached directories created by plugins. :param config: pytest configuration object. :param session: pytest session object. :returns: Exit code (0 for success). r)pformatr1zcache is empty*-zcache values for c3BK|]}|js|ywr#)is_file)rrrs r'rzcacheshow..rsE!Esz- contains unreadable content, will be ignoredz contains:z zcache directories for z is a file of length )pprintr7rr linerrr.rrrrr4seprrglobr3rb splitlinesr3r;r st_size)r&rr7twglobdummybasedirvdirvalpathrUvalr=ddircontentsps r'rrUs << ## #  BGGL3v||556 67 << ! ! ( ( *  ! == " "1 %D | HEll$$G U// /DFF3#D8,-ETZZ%5EE%'%%d+,llsE* %< GGseHI J GGse:& ' //1 %t $ %% U-- -D {{}$**T*+ s,TH56 IAyy{!--013%4QVVX5E5E4FGH  I r))r#rrr)r&rrzint | ExitCode | Noner)r/rrr)r&rrr)r&rrrrint)7r __future__rcollections.abcrrrr|r]rvpathlibrrttypingrr r reportsr _pytestr _pytest._ior _pytest.configrrr_pytest.config.argparsingr_pytest.deprecatedr_pytest.fixturesrrr)r _pytest.nodesrr_pytest.reportsrryrz dataclassrrrrrr&r*r-rr5rr>r)r'r[s+#%$ %"&!##,-$+ #&  }}}@11h$nBnBb+G+G\>B 4 @ @        1 r)