
    9[g	                       d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d dlZd dlmZ d d	lmZ d d
lmZ d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlZd dl Z d dl!Z!d dl!m"Z" d dl#m$Z$ d dl#m%Z% d dl#m&Z& d dl#m'Z' d dl#m(Z( d dl)Z)d dl*Z*d dl+m,Z, d dl-m.Z. d dl/m0Z0 e jb                  dk  rd dl2m3Z4 nd dlm4Z4 dZ5 e(de      Z6e	e
eefZ7d Z8dVd!Z9dWd"Z:	 	 	 	 	 	 	 	 	 	 dXd#Z;dYd$Z<dZd%Z=d[d&Z>d\d'Z?d]d(Z@d^d)ZAd_d*ZBd`d+ZCdadbd,ZDdcd-ZEej                  f	 	 	 	 	 ddd.ZGd[d/ZHded0ZIdfd1ZJdgd2ZKdhd3ZL	 	 	 	 	 	 	 	 	 	 did4ZM	 	 	 	 	 	 	 	 	 	 	 	 djd5ZNdkd6ZOdld7ZPdmd8ZQ	 	 	 	 	 	 	 	 dnd9ZR G d: d;e      ZS G d< d=eT      ZUeSj                  d>	 	 	 	 	 	 	 	 	 dod?ZW	 	 	 	 	 	 	 	 	 	 dpd@ZXdqdAZYe j                  j                  dB      rdrdCZ\ndrdDZ\dsdEZ]dtdFZ^dudGZ_dHdI	 	 	 	 	 dvdJZ`dwdKZadxdLZb G dM dNec      ZddO f	 	 	 	 	 dydPZe	 	 	 	 	 	 dzdQZfd{dRZgd|dSZhd}dTZid~dUZjy)    )annotationsN)Enum)EBADF)ELOOP)ENOENT)ENOTDIR)partial)
ModuleSpec)
PathFinder)
expanduser)
expandvars)isabs)sep)Path)PurePath)
ModuleType)Any)Callable)Iterable)Iterator)TypeVar)assert_never)skip)PytestWarning)      )_NamespaceLoader)NamespaceLoaderi _AnyPurePath)bound)   i  c                R    t        | dd       t        v xs t        | dd       t        v S )Nerrnowinerror)getattr_IGNORED_ERRORS_IGNORED_WINERRORS)	exceptions    J/var/www/html/bid-api/venv/lib/python3.12/site-packages/_pytest/pathlib.py_ignore_errorr*   >   s0    	7D)_< 	F9j$/3EE    c                $    | j                  d      S )Nz.lock)joinpathpaths    r)   get_lock_pathr0   E   s    ==!!r+   c                  t        |t              r|}n|d   }t        |t              ryt        |t              s1t	        j
                  t        d| dt        |       d|              y| t        j                  t        j                  t        j                  fvrG| t        j                  fvr3t	        j
                  t        d|  d| dt        |       d|              yd	d
ldfd}t        |      }|j                         r)|j                   D ]  } |t#        |             ||k(  s n  |t#        |              | |       y)zhHandle known read-only errors during rmtree.

    The returned value is used only by our own tests.
       Fz(rm_rf) error removing 
z: z(rm_rf) unknown function z when removing z:
r   Nc                    t        j                  |       j                  }t        j                  | |j                  z  j
                  z         y N)osstatst_modechmodS_IRUSRS_IWUSR)pmoder7   s     r)   chmod_rwz on_rm_rf_error.<locals>.chmod_rwq   s6    wwqz!!
D4<<'$,,67r+   T)r<   strreturnNone)
isinstanceBaseExceptionFileNotFoundErrorPermissionErrorwarningswarnr   typer6   rmdirremoveunlinkopenr7   r   is_fileparentsr?   )	funcr/   excinfo
start_pathexcr>   r<   parentr7   s	           @r)   on_rm_rf_errorrT   I   s)    '=)aj #()c?+3D6DI;bNO	
 BHHbii33z!MM/v_TF#dSVi[XZ[^Z_`
  8 	T
Ayy{iiFS[!#	  
 SYJr+   c                    t         j                  j                  d      r-| j                         } t	        t        t        |                   } | S )a0  Get the extended-length version of a path (Windows).

    On Windows, by default, the maximum length of a path (MAX_PATH) is 260
    characters, and operations on paths longer than that fail. But it is possible
    to overcome this by converting the path to "extended-length" form before
    performing the operation:
    https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation

    On Windows, this function returns the extended-length absolute version of path.
    On other platforms it returns path unchanged.
    win32)sysplatform
startswithresolver   get_extended_length_path_strr?   r.   s    r)   ensure_extended_length_pathr\      s:     ||w'||~0T;<Kr+   c                p    d}d}| j                  ||f      r| S | j                  d      r|| dd z   S || z   S )z1Convert a path to a Windows extended length path.z\\?\z\\?\UNC\z\\   N)rY   )r/   long_path_prefixunc_long_path_prefixs      r)   r[   r[      sN     )(*>?@v#d12h..d""r+   c                    t        |       } t        t        |       }t        j                  dk\  r!t        j                  t        |       |       yt        j                  t        |       |       y)zNRemove the path contents recursively, even if some elements
    are read-only.)rQ   )r      )onexc)onerrorN)r\   r	   rT   rW   version_infoshutilrmtreer?   )r/   rd   s     r)   rm_rfrh      sL     't,Dn6G
7"c$iw/c$i1r+   c              #     K   |j                         }t        j                  |       D ]0  }|j                  j                         j	                  |      s-| 2 yw)zGFind all elements in root that begin with the prefix, case-insensitive.N)lowerr6   scandirnamerY   )rootprefixl_prefixxs       r)   find_prefixedrq      sA     ||~HZZ66<<>$$X.G s   AAAc              #  R   K   t        |      }| D ]  }|j                  |d   yw)zReturn the parts of the paths following the prefix.

    :param iter: Iterator over path names.
    :param prefix: Expected prefix of the path names.
    N)lenrl   )iterrn   p_lenentrys       r)   extract_suffixesrw      s,      KEjj   s   %'c                .    t        t        | |      |      S )z+Combine find_prefixes and extract_suffixes.)rw   rq   )rm   rn   s     r)   find_suffixesry      s    M$7@@r+   c                8    	 t        |       S # t        $ r Y yw xY w)z0Parse number path suffixes, returns -1 on error.)int
ValueError)	maybe_nums    r)   	parse_numr      s#    9~ s   
 	c                    | j                  |      }	 |j                          	 |j                  |       y# t        $ r Y w xY w# t        $ r Y yw xY w)a  Helper to create the current symlink.

    It's full of race conditions that are reasonably OK to ignore
    for the context of best effort linking to the latest test run.

    The presumption being that in case of much parallelism
    the inaccuracy is going to be acceptable.
    N)r-   rK   OSError
symlink_to	Exception)rm   targetlink_tocurrent_symlinks       r)   _force_symlinkr      s]     mmF+O ""7+    s    6 A 	AA	AAc           
     .   t        d      D ]g  }t        t        t        t	        | |            d      }|dz   }| j                  | |       }	 |j                  |       t        | |dz   |       |c S  t        d| d|  d	      # t        $ r Y w xY w)
zKCreate a directory with an increased number as suffix for the given prefix.
   r{   defaultr2   r=   currentz*could not create numbered dir with prefix z in z after 10 tries)
rangemaxmapr   ry   r-   mkdirr   r   r   )rm   rn   r=   imax_existing
new_numbernew_paths          r)   make_numbered_dirr      s    2Y3y-f*EFPRS!A%
==F8J<!89	NNN% 4)!3X>O  8hd4&1
 	
  		s   B	BBc                   t        |       }	 t        j                  t        |      t        j                  t        j
                  z  t        j                  z  d      }t        j                         }t        |      j                         }t        j                  ||       t        j                  |       |j                         st        d      |S # t        $ r}t        d|        |d}~ww xY w)z2Create a lock to prevent premature folder cleanup.i  z/lock path got renamed after successful creationzcannot create lockfile in N)r0   r6   rL   r?   O_WRONLYO_CREATO_EXCLgetpidencodewritecloserM   r   FileExistsError)r<   	lock_pathfdpidspides         r)   create_cleanup_lockr      s    a IWWS^R[[2::%=		%I5Q iik3x 
T
  "KLL  ?21#67Q>?s   AC 	C/C**C/c                H    t        j                         }| |fdd} ||      S )zFRegister a cleanup function for removing a lock, by default on atexit.c                x    t        j                         }||k7  ry 	 | j                          y # t        $ r Y y w xY wr5   )r6   r   rK   r   )r   original_pidcurrent_pids      r)   cleanup_on_exitz6register_cleanup_lock_removal.<locals>.cleanup_on_exit  s;    iik,&	 		s   - 	99)r   r   r   r|   r@   rA   )r6   r   )r   registerr   r   s       r)   register_cleanup_lock_removalr     s&     ))+C*3  O$$r+   c                   t        |       } d}	 t        |       }| j                  }|j                  dt	        j
                                }| j                  |       t        |       	 |	 |j                          yy# t        $ r& Y |!	 |j                          y# t        $ r Y yw xY wyw xY w# t        $ r Y yw xY w# |!	 |j                          w # t        $ r Y w w xY ww xY w)z^Remove a numbered directory if its lock can be obtained and it does
    not seem to be in use.Nzgarbage-)
r\   r   rS   r-   uuiduuid4renamerh   r   rK   )r/   r   rS   garbages       r)   maybe_delete_a_numbered_dirr     s    't,DI'-	//HTZZ\N";<Gg    " !  
 	    "  !      "  !sl   AA> ,B0 >	B-B? B 	B('B(,B--B? 0	B<;B<?C$CC$	C C$C  C$c                ^   | j                         ryt        |       }	 |j                         sy	 	 |j	                         j
                  }||k  r4t        j                  t              5  |j                          	 ddd       yy# t        $ r Y yw xY w# 1 sw Y   yxY w# t        $ r Y yw xY w)zGCheck if `path` is deletable based on whether the lock file is expired.FTN)

is_symlinkr0   rM   r   r7   st_mtime
contextlibsuppressrK   r   )r/   $consider_lock_dead_if_created_beforelock	lock_times       r)   ensure_deletabler   6  s    D||~ IIK((	 ;;
 $$W- .- #    .   s.   B B  )B	BBB 	B,+B,c                4    t        | |      rt        |        yy)z8Try to cleanup a folder if we can ensure it's deletable.N)r   r   )r/   r   s     r)   try_cleanupr   R  s    BC#D) Dr+   c           	   #  *  K   t        t        t        t        | |            d      }||z
  }t	        | |      }t        j                  |      \  }}t        t        t        ||            }t        ||      D ]  \  }}	|	|k  st        |        yw)zIList candidates for numbered directories to be removed - follows py.path.r{   r   N)
r   r   r   ry   rq   	itertoolsteerw   zipr   )
rm   rn   keepr   
max_deleteentriesentries2numbersrv   numbers
             r)   cleanup_candidatesr   X  s     s9mD&&ABBOL$JD&)G!g.GX)-h?@GWg.vZu+ /s   B BBc                    | j                         D ]B  }|j                         s|j                         j                         r3|j	                          D y r5   )iterdirr   rZ   existsrK   )rm   left_dirs     r)   cleanup_dead_symlinksr   d  s=    LLN ##%,,.! #r+   c                    | j                         syt        | ||      D ]  }t        ||        | j                  d      D ]  }t        ||        t	        |        y)z-Cleanup for lock driven numbered directories.Nz	garbage-*)r   r   r   globr   )rm   rn   r   r   r/   s        r)   cleanup_numbered_dirr   k  sV     ;;="46D>? 7		+&D>? ' $r+   c                .   d}t        d      D ]h  }	 t        | ||      }|dk7  rt        |      }t        |       |j	                         j
                  |z
  }	t        j                  t        | |||	       |c S  |J |# t        $ r}
|
}Y d}
~
d}
~
ww xY w)z>Create a numbered dir with a cleanup lock and remove old ones.Nr   r   )
r   r   r   r   r7   r   atexitr   r   r   )rm   rn   r   lock_timeoutr=   r   r   r<   r   r   rR   s              r)   make_numbered_dir_with_cleanupr   y  s     	A2Y	!$5Aqy/2	-i8 456683D3D|3S0OO$4 H' ( ==
G  	A	s   (A??	BBBc                |    t        |       } t        |       } t        |       rt        |       S |j	                  |       S r5   )r   r   r   r   r-   )inputrootpaths     r)   resolve_from_strr     s8    uEuEU|E{  ''r+   c                   t        |      }t        j                  j                  d      }|r*t        | vr"t
        | v r| j                  t
        t              } t        | vr|j                  }nOt        |      }|j                         r4t        j                  j                  |       sdt        j                   |  } t        j                  ||       S )a  A port of FNMatcher from py.path.common which works with PurePath() instances.

    The difference between this algorithm and PurePath.match() is that the
    latter matches "**" glob expressions for each part of the path, while
    this algorithm uses the whole path instead.

    For example:
        "tests/foo/bar/doc/test_foo.py" matches pattern "tests/**/doc/test*.py"
        with this algorithm, but not with PurePath.match().

    This algorithm was ported to keep backward-compatibility with existing
    settings which assume paths match according this logic.

    References:
    * https://bugs.python.org/issue29249
    * https://bugs.python.org/issue34731
    win*)r   rW   rX   rY   r   	posix_sepreplacerl   r?   is_absoluter6   r/   r   fnmatch)patternr/   iswin32rl   s       r)   
fnmatch_exr     s    $ D>Dll%%e,G3g%)w*> //)S1
'yy4ybggmmG&<"&&'+G??4))r+   c           	         | j                  t              }t        t        |            D ch c]%  }t        j                  |d |dz          xs t        ' c}S c c}w )Nr2   )splitr   r   rs   join)spartsr   s      r)   r   r     sM    GGCLE5:3u:5FG5FCHHU7QU^$++5FGGGs   *Ac                |    	 t        j                  | |fi | y# t        $ r}t        d|        Y d}~yd}~ww xY w)zDMake a symlink, or skip the test in case symlinks are not supported.zsymlinks not supported: N)r6   symlinkr   r   )srcdstkwargsr   s       r)   symlink_or_skipr     s=    -


3&v& -'s+,,-s    	;6;c                      e Zd ZdZdZdZdZy)
ImportModez6Possible values for `mode` parameter of `import_path`.prependappend	importlibN)__name__
__module____qualname____doc__r   r   r    r+   r)   r   r     s    @GFIr+   r   c                      e Zd ZdZy)ImportPathMismatchErrora  Raised on import_path() if there is a mismatch of __file__'s.

    This can happen when `import_path` is called multiple times with different filenames that has
    the same basename but reside in packages
    (for example "/tests1/test_foo.py" and "/tests2/test_foo.py").
    Nr   r   r   r   r   r+   r)   r   r     s    r+   r   r   c               f   t        |       } t        |      }| j                         st        |       |t        j                  u rG	 t        | |      \  }}t        j                  t              5  t        j                  |   cddd       S 	 t        | |      \  }}|t        j                   u rDt#        |      t        j$                  vrt        j$                  j!                  t#        |             nf|t        j&                  u rIt#        |      t        j$                  d   k7  r5t        j$                  j)                  dt#        |             nt+        |       t	        j,                  |       t        j                  |   }| j.                  d	k(  r|S t0        j2                  j5                  d
d      }|dk7  r|j6                  }|t9        |||       |j;                  d      r|dd }|j;                  t0        j<                  d	z         r |dt?        t0        j<                  d	z           }	 tA        t#        |       |      }	|	st9        |||       |S # 1 sw Y   nxY wt        || |d      }||S # t        $ r Y nw xY wt        | |      }t        j                  t              5  t        j                  |   cddd       S # 1 sw Y   nxY wt        || | j                  d      }|t        d| d|        |S # t        $ r | j                  | j                  }}Y w xY w# tB        $ r d}	Y w xY w)aq  
    Import and return a module from the given path, which can be a file (a module) or
    a directory (a package).

    :param path:
        Path to the file to import.

    :param mode:
        Controls the underlying import mechanism that will be used:

        * ImportMode.prepend: the directory containing the module (or package, taking
          `__init__.py` files into account) will be put at the *start* of `sys.path` before
          being imported with `importlib.import_module`.

        * ImportMode.append: same as `prepend`, but the directory will be appended
          to the end of `sys.path`, if not already in `sys.path`.

        * ImportMode.importlib: uses more fine control mechanisms provided by `importlib`
          to import the module, which avoids having to muck with `sys.path` at all. It effectively
          allows having same-named test modules in different places.

    :param root:
        Used as an anchor when mode == ImportMode.importlib to obtain
        a unique name for the module being imported so it can safely be stored
        into ``sys.modules``.

    :param consider_namespace_packages:
        If True, consider namespace packages when resolving module names.

    :raises ImportPathMismatchError:
        If after importing the given `path` and the module `__file__`
        are different. Only raised in `prepend` and `append` modes.
    consider_namespace_packagesNFinsert_modulesTzCan't find module z at location r   __init__.pyPY_IGNORE_IMPORTMISMATCH 1)z.pycz.pyor{   )"r   r   r   ImportErrorr    resolve_pkg_root_and_module_namer   r   KeyErrorrW   modules_import_module_using_specCouldNotResolvePathErrormodule_name_from_pathrS   stemr   r?   r/   r   insertr   import_modulerl   r6   environget__file__r   endswithr   rs   _is_samerD   )
r/   r=   rm   r   pkg_rootmodule_namemodignoremodule_fileis_sames
             r)   import_pathr    s   P :DdD;;=$z###	$D2M%!Hk $$X.{{;/ /.,7 @.I!
+ z   x=(HHOOCM*	##	#x=CHHQK'HHOOAs8}-TK(
++k
"CyyM!
ZZ^^6;F}ll)+{DII 01%cr*K 67%&F#bff}.D*E(FGK	s4y+6G )+{DIIJE /. ,T8EC 
 ( 		 ,D$7  *;;{+ +** (t{{4
 ; 2;-}TFSTT
 $ 7 $TYY+7D ! 	G	sN   I/ .IK: *L" I/	I;:I;#K  K	:!LL"L0/L0c                  | j                  d      \  }}}d}|rt        j                  j                  |      }|c|j                  dk(  r|j
                  j
                  }n|j
                  }|dz  j                         r|dz  }t        |||j
                  |      }t        j                  D ]6  }	|	j                  | t        |      t        |      g      }
t        |
|      s6 nS d}|j                         rt        ||t                     }t        j                   j#                  | t        |      |      }
t        |
|      r~|
J t        j                   j%                  |
      }|t        j                  | <   |
j&                  j)                  |       |t+        |||       |rt-        t        j                  |        |S y)a  
    Tries to import a module by its canonical name, path, and its parent location.

    :param module_name:
        The expected module name, will become the key of `sys.modules`.

    :param module_path:
        The file path of the module, for example `/foo/bar/test_demo.py`.
        If module is a package, pass the path to the  `__init__.py` of the package.
        If module is a namespace package, pass directory path.

    :param module_location:
        The parent location of the module.
        If module is a package, pass the directory containing the `__init__.py` file.

    :param insert_modules:
        If True, will call `insert_missing_modules` to create empty intermediate modules
        with made-up module names (when importing test files not reachable from `sys.path`).

    Example 1 of parent_module_*:

        module_name:        "a.b.c.demo"
        module_path:        Path("a/b/c/demo.py")
        module_location:    Path("a/b/c/")
        if "a.b.c" is package ("a/b/c/__init__.py" exists), then
            parent_module_name:         "a.b.c"
            parent_module_path:         Path("a/b/c/__init__.py")
            parent_module_location:     Path("a/b/c/")
        else:
            parent_module_name:         "a.b.c"
            parent_module_path:         Path("a/b/c")
            parent_module_location:     Path("a/b/")

    Example 2 of parent_module_*:

        module_name:        "a.b.c"
        module_path:        Path("a/b/c/__init__.py")
        module_location:    Path("a/b/c/")
        if  "a.b" is package ("a/b/__init__.py" exists), then
            parent_module_name:         "a.b"
            parent_module_path:         Path("a/b/__init__.py")
            parent_module_location:     Path("a/b/")
        else:
            parent_module_name:         "a.b"
            parent_module_path:         Path("a/b/")
            parent_module_location:     Path("a/")
    .Nr   r   )loader)
rpartitionrW   r  r  rl   rS   rM   r  	meta_path	find_specr?   spec_matches_module_pathis_dirr   r   r   utilspec_from_file_locationmodule_from_specr  exec_modulesetattrinsert_missing_modules)r  module_pathmodule_locationr   parent_module_name_rl   parent_moduleparent_module_pathmeta_importerspecr  r  s                r)   r  r  g  s   h #."8"8"=4'+M(:; =0 &1%7%7%>%>"%0%7%7""]2;;=%7-%G"5"""))-	M &&#o.K0@A
 $D+6 '  %T;
EF~~55[)& 6 
  k2nn--d3#&K $ $M4-"3;;<
r+   c                    | y| j                   rt        | j                         |k(  S | j                  r!| j                  D ]  }t        |      |k(  s y y)zPReturn true if the given ModuleSpec can be used to import the given module path.FT)originr   submodule_search_locations)module_specr(  r/   s      r)   r   r     sY    K&&';66
 --::DDz[( ; r+   r   c                t    t        |       t        |      k(  xs  t        j                  j                  | |      S r5   )r   r6   r/   samefilef1f2s     r)   r  r    s+    Bx48#?rww'7'7B'??r+   c                B    t         j                  j                  | |      S r5   )r6   r/   r5  r6  s     r)   r  r    s    wwB''r+   c                   | j                  d      } 	 | j                  |      }|j                  }t	        |      dk\  r|d   dk(  r|dd }t        d |D              }dj                  |      S # t        $ r | j                  dd }Y Xw xY w)	z
    Return a dotted module name based on the given path, anchored on root.

    For example: path="projects/src/tests/test_foo.py" and root="/projects", the
    resulting module name will be "src.tests.test_foo".
    r  r2   Nr^   r{   __init__c              3  @   K   | ]  }|j                  d d        yw)r  r+  N)r   ).0rp   s     r)   	<genexpr>z(module_name_from_path.<locals>.<genexpr>  s     ?Jqqyyc*Js   r  )with_suffixrelative_tor   r}   rs   tupler   )r/   rm   relative_path
path_partss       r)   r
  r
    s     BD)((. #((
 :!
2* <_

 ?J??J88J%  $ ZZ^
$s   A. .B	B	c                   |j                  d      }|r|j                  d      \  }}}|r`| j                  |      }|1	 t        j                  st
        t        j                  |      }|| |<   t        ||      st        ||| |          |j                  d       dj                  |      }|ryy# t
        $ r t        |d      }Y `w xY w)aM  
    Used by ``import_path`` to create intermediate modules when using mode=importlib.

    When we want to import a module as "src.tests.test_foo" for example, we need
    to create empty modules "src" and "src.tests" after inserting "src.tests.test_foo",
    otherwise "src.tests.test_foo" is not importable by ``__import__``.
    r  Nz6Empty module created by pytest's importmode=importlib.)docr{   )r   r  r  rW   r  ModuleNotFoundErrorr   r  r   hasattrr&  popr   )r  r  module_partsr*  r+  
child_namer,  s          r)   r'  r'    s     $$S)L
,7,B,B3,G)Az#KK(:;M$
 ==11$-$;$;<N$OM /<*+ =*5z7;3GHhh|,5  + $.#T%Ms   +B2 2C
Cc                    d}t        j                  | f| j                        D ]H  }|j                         s|dz  j	                         s |S |j
                  j                         s |S |}J |S )zReturn the Python package path by looking for the last
    directory upwards which still contains an __init__.py.

    Returns None if it cannot be determined.
    Nr   )r   chainrN   r!  rM   rl   isidentifier)r/   resultrS   s      r)   resolve_package_pathrO  =  sp     F//4'4<<8==?]*335 M ;;++-M F 9 Mr+   Fr   c                  d}t        |       }||j                  }|rD||n| j                  }|g|j                  D ]!  }t        ||       }|st	        ||       s|} n |t        ||       }|r||fS t        d|        )a  
    Return the path to the directory of the root package that contains the
    given Python file, and its module name:

        src/
            app/
                __init__.py
                core/
                    __init__.py
                    models.py

    Passing the full path to `models.py` will yield Path("src") and "app.core.models".

    If consider_namespace_packages is True, then we additionally check upwards in the hierarchy
    for namespace packages:

    https://packaging.python.org/en/latest/guides/packaging-namespace-packages

    Raises CouldNotResolvePathError if the given path does not belong to a package (missing any __init__.py files).
    NzCould not resolve for )rO  rS   rN   compute_module_nameis_importabler	  )r/   r   r  pkg_pathstart	candidater  s          r)   r  r  N  s    . !H#D)H??"$0dkk0%--0I-i>K}[$?$ 1 )(D9[((
"%;D6#B
CCr+   c                    	 t         j                  j                  |       }t        ||      S # t        t
        t        f$ r Y yw xY w)a  
    Return if the given module path could be imported normally by Python, akin to the user
    entering the REPL and importing the corresponding module name directly, and corresponds
    to the module_path specified.

    :param module_name:
        Full module name that we want to check if is importable.
        For example, "app.models".

    :param module_path:
        Full path to the python module/package we want to check if is importable.
        For example, "/projects/src/app/models.py".
    F)r   r"  r  r   r  r}   ImportWarning)r  r(  r/  s      r)   rR  rR  z  sG    	;
 ~~''4 (k:: ]3 s   - AAc                   	 |j                  d      }	 |j                  |       }t        |j                        }|sy|d   dk(  r|j                          dj                  |      S # t        $ r Y yw xY w# t        $ r Y yw xY w)z8Compute a module name based on a path and a root anchor.r  Nr{   r;  r  )r?  r}   r@  listr   rH  r   )rm   r(  path_without_suffixrelativenamess        r)   rQ  rQ    s    )55b9
&2248  ERyJ		88E?    s"   A& A5 &	A21A25	B Bc                      e Zd ZdZy)r	  z<Custom exception raised by resolve_pkg_root_and_module_name.Nr   r   r+   r)   r	  r	    s    Fr+   r	  c                    | j                   S r5   )rl   )rv   s    r)   <lambda>r_    s    5::r+   c                   g }t        j                  |       5 }|D ]$  }	 |j                          |j                  |       & 	 ddd       |j                  |       |S # t        $ r}t	        |      rY d}~] d}~ww xY w# 1 sw Y   ?xY w)zScan a directory recursively, in breadth-first order.

    The returned entries are sorted according to the given key.
    The default is to sort by name.
    N)key)r6   rk   rM   r   r*   r   sort)r/   sort_keyr   r   rv   errs         r)   rk   rk     s     G	D	Q E
 NN5!  
 LLXLN   % 
	s9   BAB	A>(A93B8A99A>>BB
c              #     K   t        |       }|E d{    |D ]:  }|j                         s ||      st        |j                  |      E d{    < y7 D7 	w)zWalk a directory recursively, in breadth-first order.

    The `recurse` predicate determines whether a directory is recursed.

    Entries at each directory level are sorted.
    N)rk   r!  visitr/   )r/   recurser   rv   s       r)   rf  rf    sR      dmG<<>genUZZ111   2s+   AAAAAAAAc                R    t        t        j                  j                  |             S )zConvert a path to an absolute path using os.path.abspath.

    Prefer this over Path.resolve() (see #6523).
    Prefer this over Path.absolute() (not public, doesn't normalize).
    )r   r6   r/   abspathr.   s    r)   absolutepathrj    s     %&&r+   c                    	 t        t        j                  j                  t	        |       t	        |      f            S # t
        $ r Y yw xY w)zReturn the common part shared with the other path, or None if there is
    no common part.

    If one path is relative and one is absolute, returns None.
    N)r   r6   r/   
commonpathr?   r}   )path1path2s     r)   rl  rl    s@    BGG&&E
CJ'?@AA s   ;> 	A
	A
c                   t        | t              sJ t        |t              sJ || k(  rt        j                  S t	        | |      }|st        |      S | j                  |      }|j                  |      }t        j                  j                  g t        j                  gt        |j                        z  |j                   S )zReturn a string which is a relative path from directory to dest such
    that directory/bestrelpath == dest.

    The paths must be either both absolute or both relative.

    If no such path can be determined, returns dest.
    )rB   r   r6   curdirrl  r?   r@  r/   r   pardirrs   r   )	directorydestbasereldirectoryreldests        r)   bestrelpathrw    s     i&&&dD!!!yyyi&D 4y((.Lt$G77<< 99+L../
/ 
	 r+   c                N    	 | j                         S # t        t        f$ r Y yw xY w)zTLike Path.exists(), but account for input arguments that might be too long (#11394).F)r   r}   r   )r<   s    r)   safe_existsry    s,    xxz   s    $$)r(   r   r@   bool)r/   r   r@   r   )
rO   zCallable[..., Any] | Noner/   r?   rP   zUBaseException | tuple[type[BaseException], BaseException, types.TracebackType | None]rQ   r   r@   rz  )r/   r   r@   r   )r/   r?   r@   r?   )r/   r   r@   rA   )rm   r   rn   r?   r@   Iterator[os.DirEntry[str]])rt   zIterable[os.DirEntry[str]]rn   r?   r@   Iterator[str])rm   r   rn   r?   r@   r|  )r~   r?   r@   r|   )rm   r   r   zstr | PurePathr   z
str | Pathr@   rA   )i  )rm   r   rn   r?   r=   r|   r@   r   )r<   r   r@   r   )r   r   r   r   r@   r   )r/   r   r   floatr@   rz  )r/   r   r   r}  r@   rA   )rm   r   rn   r?   r   r|   r@   zIterator[Path])rm   r   r@   rA   )
rm   r   rn   r?   r   r|   r   r}  r@   rA   )rm   r   rn   r?   r   r|   r   r}  r=   r|   r@   r   )r   r?   r   r   r@   r   )r   r?   r/   str | os.PathLike[str]r@   rz  )r   r?   r@   zset[str])r   os.PathLike[str] | strr   r  r   r   r@   rA   )
r/   r~  r=   zstr | ImportModerm   r   r   rz  r@   r   )
r  r?   r(  r   r)  r   r   rz  r@   zModuleType | None)r3  zModuleSpec | Noner(  r   r@   rz  )r7  r?   r8  r?   r@   rz  )r/   r   rm   r   r@   r?   )r  zdict[str, ModuleType]r  r?   r@   rA   )r/   r   r@   Path | None)r/   r   r   rz  r@   ztuple[Path, str])r  r?   r(  r   r@   rz  )rm   r   r(  r   r@   z
str | None)r/   r~  rc  z$Callable[[os.DirEntry[str]], object]r@   zlist[os.DirEntry[str]])r/   r~  rg  z"Callable[[os.DirEntry[str]], bool]r@   r{  )r/   r~  r@   r   )rm  r   rn  r   r@   r  )rr  r   rs  r   r@   r?   )r<   r   r@   rz  )k
__future__r   r   r   enumr   r#   r   r   r   r   r   	functoolsr	   importlib.machineryr
   r   importlib.utilr   r   r6   os.pathr   r   r   r   pathlibr   r   	posixpathr   rf   rW   typesr   typingr   r   r   r   r   r   rF   _pytest.compatr   _pytest.outcomesr   _pytest.warning_typesr   re   importlib._bootstrap_externalr   r   LOCK_TIMEOUTr   r&   r'   r*   r0   rT   r\   r[   rh   rq   rw   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r  r  r   rX   rY   r  r
  r'  rO  r  rR  rQ  r   r	  rk   rf  rj  rl  rw  ry  r   r+   r)   <module>r     sb   "          * *   	       &  
          ' ! / gQ3~X6 7E51 "8
#8
8L8 8 
8v$	#2!A
(
*$ &,__%%"%%&88*	" 
  #& NS 	 
  	
  
B(!*HH
	-		-		- 	- 
		- k  (//{
 { { 	{
 "&{ {|nn#'n:>nSWnnb* <<5!@
( >#-L$ 8=)D
)D04)D)DX;4(Gy G 6N
 2 22
 2+M22 '	:r+   