L iv ddlZddlZddlZddlZddlZddlmZddlmZm Z ddl Z ddl Z e jdZ GddZe jdd d eeddffd Ze jd d Zy)N)deque) GeneratorSequencec#$Ktjd}|jj|jj|jj d ||jj|jj|jj dy#|jj|jj|jj dwxYww)z0 Fixture providing a memory filesystem. memoryN)fsspec filesystemstoreclear pseudo_dirsappend)ms U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fsspec/conftest.pyrrs (#AGGMMOMMMM!    R     R s A%D(B<,ADt|jtr |jn|jd}|s|s|||<|j|j|r|S)a Gather counts of filesystem instances in the instance caches of all currently imported filesystem classes. Parameters ---------- omit_zero: Whether to omit instance types with no cached instances. r) rr rrrlen_cache isinstanceprotocolrstrrr)rroutrrcountkeys r gather_countsz$InstanceCacheInspector.gather_counts.s!7789//#C OE#,,38&0s&CcllVW $CH NN3--/ 0 r)rN) __name__ __module__ __qualname____doc__r booldictr%intr)rrrrs,126$$sCx.rrfunctionT)scopeautouserc#Kt}|j ||jy#|jwxYww)as Fixture to ensure empty filesystem instance caches before and after a test. Used by default for all tests. Clears caches of all imported filesystem classes. Can be used to write test assertions about instance caches. Usage: def test_something(instance_caches): # Test code here fsspec.open("file://abc") fsspec.open("memory://foo/bar") # Test assertion assert instance_caches.gather_counts() == {"file": 1, "memory": 1} Returns ------- instance_caches: An instance cache inspector for clearing and inspecting caches. N)rr )ics rinstance_cachesr7Gs5. !BHHJ   sA3AAA)r3c #Ktjdt|}ttj j |dd5}|jddzdddtjtjddd|d d d d d g } tjdd|j|j t!j"|y#1swYxYw#t$$rYywxYw#|j|j t!j"|w#t$$rYwwxYwxYww)z6 Fixture providing a writable FTP filesystem. pyftpdlibr&wbshelloi'Nz-mz-dz-uuserz-Ppassz-w) localhostiIr;r<)pytest importorskipr%openospathjoinwrite subprocessPopensys executabletimesleep terminatewaitshutilrmtree Exception)tmpdirdfPs r ftp_writablerUgs   $ F A bggll1e$d +"q 5 !" {D!T64QUV A  1 //    MM& !""       MM& !   s~A E  C("5E D1 E C4'E (C1-E 4 D=E ?DE !E %D;:E ; EE EE  E )rBrNrFrHrJ collectionsrcollections.abcrrr?r fixturerrr7rUr1rrrYs  /  ! ! %%Pj$/#94#EF0>j!"r