
    עiN2                    z   U 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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mZ d dlmZ  ed       G d d             Zeeef   Zded<   ddZ	 	 	 	 d dZ	 	 	 	 	 	 d!dZ	 	 	 	 	 	 d"dZ d#dZ!d$dZ"dZ#	 	 	 	 	 	 	 	 	 	 	 	 d%dZ$d&dZ%y)'    )annotations)Iterable)Sequence)	dataclass)KW_ONLYN)Path)Literal)	TypeAlias   )
UsageError)failabsolutepath)
commonpathsafe_existsT)frozenc                  :    e Zd ZU dZded<   ded<   ded<   ded	<   y
)ConfigValuea8  Represents a configuration value with its origin and parsing mode.

    This allows tracking whether a value came from a configuration file
    or from a CLI override (--override-ini), which is important for
    determining precedence when dealing with ini option aliases.

    The mode tracks the parsing mode/data model used for the value:
    - "ini": from INI files or [tool.pytest.ini_options], where the only
      supported value types are `str` or `list[str]`.
    - "toml": from TOML files (not in INI mode), where native TOML types
       are preserved.
    objectvaluer   _zLiteral['file', 'override']originzLiteral['ini', 'toml']modeN)__name__
__module____qualname____doc____annotations__     Y/sites/domain-asset-master/.venv/lib/python3.12/site-packages/_pytest/config/findpaths.pyr   r      s     MJ''
  r!   r   r
   
ConfigDictc                    	 t        j                  t        |             S # t         j                  $ r}t	        t        |            |d}~ww xY w)zParse the given generic '.ini' file using legacy IniConfig parser, returning
    the parsed object.

    Raise UsageError if the file cannot be parsed.
    N)	iniconfig	IniConfigstr
ParseErrorr   )pathexcs     r"   _parse_ini_configr+   .   sC    ,""3t9-- ,S"+,s     AAAc           
     x   | j                   dk(  rSt        |       }d|v r3|d   j                         D ci c]  \  }}|t        |dd       c}}S | j                  dv ri S y| j                   dk(  r|t        |       }d|j
                  v r3|d   j                         D ci c]  \  }}|t        |dd       c}}S d|j
                  v r!t        t        j                  d	
      d       y| j                   dk(  rqt        j                  dk\  rddl}nddl}| j                  d      }	 |j                  |      }| j                  dv rF|j#                  di       }|r0|j                         D ci c]  \  }}|t        |dd       c}}S i S |j#                  di       j#                  di       }	|	j                         D ci c]  \  }}|dk7  s|| }
}}|	j#                  dd      }|
r|rt!        |  d      |
r0|
j                         D ci c]  \  }}|t        |dd       c}}S |:dd}|j                         D ci c]  \  }}|t         ||      dd       c}}S yc c}}w c c}}w # |j                  $ r}t!        |  d|       |d}~ww xY wc c}}w c c}}w c c}}w c c}}w )zLoad pytest configuration from the given file path, if supported.

    Return None if the file does not contain valid pytest configuration.
    z.inipytestfileinir   r   >   
pytest.ini.pytest.iniz.cfgztool:pytest	setup.cfg)filenameF)pytracez.toml)      r   Nzutf-8)encodingz: )pytest.toml.pytest.tomltomltoolini_optionsz: Cannot use both [tool.pytest] (native TOML types) and [tool.pytest.ini_options] (string-based INI format) simultaneously. Please use [tool.pytest] with native TOML types (recommended) or [tool.pytest.ini_options] for backwards compatibility.c                <    t        | t              r| S t        |       S N)
isinstancelistr'   )vs    r"   make_scalarz/load_config_dict_from_file.<locals>.make_scalar   s     *1d 31?Q?r!   )rB   r   returnzstr | list[str])suffixr+   itemsr   namesectionsr   CFG_PYTEST_SECTIONformatsysversion_infotomllibtomli	read_textloadsTOMLDecodeErrorr   get)filepathr%   krB   rM   	toml_textconfigr*   pytest_configtool_pytesttoml_config
ini_configrC   s                r"   load_config_dict_from_filer[   :   s    & %h/	y  &h/557Aq ;qe<<  }} ==	\ W 
F	"%h/	I... &m4::<Aq ;qe<<  +++ #**K*@%P@ w 
G	#w&#&&&8		<]]9-F
 ==;;"JJx4M !. 3 3 51 {1V&AA 
 I !**VR044XrBK -8,=,=,?VDAq1CU1a4VKV$=Jz j !P P   !, 1 1 31 {1V&AA 
 '@
 !+ 0 0 21 {;q>&uMM 
 k* && 	<zC512;	< WsA   I0!I6-I< 3J$J*J*J0J6<J!JJ!c                ,   g d}|D cg c]  }t        |      j                  d      r|! }}|s| g}d}g }|D ]  }t        |      }|g|j                  D ]  }|D ]  }	||	z  }
|
j	                         s|
j
                  dk(  r||
}t        |
      }|:|j                  |	      }||dz   d D ]5  }||z  }|j	                         st        |      %|j                  |       7 ||
||fc c c S    ||j                  |i g fS ddi g fS c c}w )a	  Search in the list of arguments for a valid ini-file for pytest,
    and return a tuple of (rootdir, inifile, cfg-dict, ignored-config-files), where
    ignored-config-files is a list of config basenames found that contain
    pytest configuration but were ignored.)r9   r:   r1   r2   pyproject.tomlztox.inir3   -Nr]   r   )
r'   
startswithr   parentsis_filerG   r[   indexappendparent)invocation_dirargsconfig_namesxfound_pyproject_tomlignored_config_filesargargpathbaseconfig_nameprZ   rb   	remainderp2s                  r"   locate_configrr      sg   L :!3q6#4#4S#9A:D:(,&( Is#/w/ 	ID+ I;&99;vv!116J6R/0,!;A!>J!- , 2 2; ?)5eaik)B GI!%	!1B "

$>r$B$N 4 ; ;I FG  $Q
4HHHI	II& '#**,@"bHHr27 ;s
   DDc                    d }|D ]N  }|j                         s||}||j                  v s||k(  r-||j                  v r|}>t        ||      }|M|}P || }|S |j                         r|j                  }|S r?   )existsr`   r   ra   rd   )re   pathscommon_ancestorr)   shareds        r"   get_common_ancestorrx      s     $(O -{{}""O$,,.$/2I000"&#D/:%&,O- (  
	 	 	")00r!   c                    dddddd}fd| D        }|D cg c]  }t        |      s ||       c}S c c}w )Nc                $    | j                  d      S )Nr^   )r_   rh   s    r"   	is_optionz%get_dirs_from_args.<locals>.is_option   s    ||C  r!   c                *    | j                  d      d   S )Nz::r   )splitr{   s    r"   get_file_part_from_node_idz6get_dirs_from_args.<locals>.get_file_part_from_node_id   s    wwt}Qr!   c                >    | j                         r| S | j                  S r?   )is_dirrd   )r)   s    r"   get_dir_from_pathz-get_dirs_from_args.<locals>.get_dir_from_path   s    ;;=K{{r!   c              3  P   K   | ]  } |      st         |              y wr?   r   ).0rk   r   r|   s     r"   	<genexpr>z%get_dirs_from_args.<locals>.<genexpr>   s+      ~ 	/45s   #&)rh   r'   rD   bool)rh   r'   rD   r'   )r)   r   rD   r   r   )rf   r   possible_pathsr)   r   r|   s       @@r"   get_dirs_from_argsr      sD    ! N 1?T+dBSd#TTTs   =
=c                    i }| xs dD ])  }	 |j                  dd      \  }}t        |dd      ||<   + |S # t        $ r}t        d|d      |d	}~ww xY w)
zParse the -o/--override-ini command line arguments and return the overrides.

    :raises UsageError:
        If one of the values is malformed.
    r    =r   overrider/   r0   z3-o/--override-ini expects option=value style (got: z).N)r~   r   
ValueErrorr   )override_ini	overridesrZ   keyuser_ini_valuees         r"   parse_override_inir      s     I #(b X
	X","2"23":C )
QVWIcNX   	Ej^SUV	s   7	A AAz][pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead.c                \   d}t        |      }g }| r+t        |       }|}	t        |      xs i }
||j                  }nt	        ||      }t        ||g      \  }}	}
}|b|`|g|j                  D ]  }|dz  j                         s|} n5 ||gk7  rt        ||      \  }}	}
}|t	        |||g      }t        |      r|}|rGt        t        j                  j                  |            }|j                         st        d| d      t        |      }|
j                  |       |J ||	|
|fS )a  Determine the rootdir, inifile and ini configuration values from the
    command line arguments.

    :param inifile:
        The `--inifile` command line argument, if given.
    :param override_ini:
        The -o/--override-ini command line arguments, if given.
    :param args:
        The free command line arguments.
    :param rootdir_cmd_arg:
        The `--rootdir` command line argument, if given.
    :param invocation_dir:
        The working directory when pytest was invoked.

    :raises UsageError:
    Nzsetup.pyzDirectory 'z+' not found. Check your '--rootdir' option.)r   r   r[   rd   rx   rr   r`   ra   
is_fs_rootosr)   
expandvarsr   r   r   update)inifiler   rf   rootdir_cmd_argre   rootdirdirsrj   inipath_inipathinicfgancestorpossible_rootdirr   ini_overridess                  r"   determine_setupr     sq   0 Gd#D*,('+H5;"ooG&~t<9FXJ:
6&"6 ?6%-$A0@0@$A + $z1::<.G+
 H:%2?PT2U/GWfa?1&(BG "'*"*rww11/BC~~gY&QR  '|4M
MM- GV%999r!   c                z    t         j                  j                  t        |             d   t         j                  k(  S )z
    Return True if the given path is pointing to the root of the
    file system ("/" on Unix and "C:\\" on Windows for example).
    r   )r   r)   
splitdriver'   sep)ro   s    r"   r   r   Y  s+    
 77c!f%a(BFF22r!   )r)   r   rD   ziniconfig.IniConfig)rS   r   rD   zConfigDict | None)re   r   rf   Iterable[Path]rD   z:tuple[Path | None, Path | None, ConfigDict, Sequence[str]])re   r   ru   r   rD   r   )rf   zIterable[str]rD   z
list[Path])r   Sequence[str] | NonerD   r#   )r   
str | Noner   r   rf   zSequence[str]r   r   re   r   rD   z3tuple[Path, Path | None, ConfigDict, Sequence[str]])ro   r   rD   r   )&
__future__r   collections.abcr   r   dataclassesr   r   r   pathlibr   rK   typingr	   r
   r%   
exceptionsr   _pytest.outcomesr   _pytest.pathlibr   r   r   r   dictr'   r#   r   r+   r[   rr   rx   r   r   rI   r   r   r    r!   r"   <module>r      s'   " $ $ !  	  
    " ! ( & ' $! ! !( S+-.
I .	,aaaH,,
, @,^ 
4U,, u @:@: '@: 	@:
  @: @: 9@:F3r!   