
    DIe~                        d Z ddlZddlZddlZddlmZ ddlmZmZ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  ej        d
          d             Z ej        d          d             Z ej        d
          d             Z ej        d          d             Z ej        d          d             Z ej                    d             Z ej        ddg          d             ZdS )z2Collection of pytest fixtures used in conda tests.    N)dals)conda_tests_ctxt_mgmt_def_polcontextreset_context)YamlRawParameter)env_vars)yaml_round_trip_load)
SubdirData)TemporaryDirectoryT)autousec                  <    t          j        dt                     dS )z
    Suppress `Unclosed Socket Warning`

    It seems urllib3 keeps a socket open to avoid costly recreation costs.

    xref: https://github.com/kennethreitz/requests/issues/1882
    ignore)categoryN)warningsfilterwarningsResourceWarning     6lib/python3.11/site-packages/conda/testing/fixtures.pysuppress_resource_warningr      s      H??????r   function)scopec                     t          t          |                     } |                    | j                   t          j                            | j                  S )N)dir)r   straddfinalizercleanuppypathlocalname)tmpdirrequests     r   r"   r"      sD    CKK000F(((7==%%%r   c                  ,    t          j                     d S )N)r
   clear_cached_local_channel_datar   r   r   clear_subdir_cacher&   %   s    .00000r   c               #      K   t          d          } t          d           dt          j        dt	          |                     i}t          j        |           dV  t          d           dS )z
    Fixture that will set "context.number_channel_notices" to 0 and then set
    it back to its original value.

    This is also a good example of how to override values in the context object.
    z+
        number_channel_notices: 0
        r   testdataN)r   r   r   make_raw_parametersr	   r   _set_raw_data)yaml_strrds     r   disable_channel_noticesr-   *   s       	 H
 "$8,X66
 

B
 "	EEE"r   c               #   .   K   dV  t                       dS )z:Resets the context object after each test function is run.N)r   r   r   r   reset_conda_contextr/   D   s       
EEEOOOOOr   c              #      K   |                      d          }t          dt          |          it                    5  |V  ddd           dS # 1 swxY w Y   dS )zB
    Used to isolate package or index cache from other tests.
    pkgsCONDA_PKGS_DIRS)stack_callbackN)mktempr   r   r   )tmp_path_factorypkgs_dirs     r   temp_package_cacher7   L   s      
  &&v..H		CMM*;X
 
 
                    s   AAAlibmambaclassic)paramsc                     |                     t          d| j                   |                     t          j        dt          j        j                   dS )at  
    A parameterized fixture that sets the solver backend to (1) libmamba
    and (2) classic for each test. It's using autouse=True, so only import it in
    modules that actually need it.

    Note that skips and xfails need to be done _inside_ the test body.
    Decorators can't be used because they are evaluated before the
    fixture has done its work!

    So, instead of:

        @pytest.mark.skipif(context.solver == "libmamba", reason="...")
        def test_foo():
            ...

    Do:

        def test_foo():
            if context.solver == "libmamba":
                pytest.skip("...")
            ...
    solverget_cached_solver_backendN)setattrr   paramplugin_managerget_solver_backend)r#   monkeypatchs     r   parametrized_solver_fixturerC   X   sR    0 7=999#1    r   )__doc__r   r   pytestconda.auxlib.ishr   conda.base.contextr   r   r   conda.common.configurationr   conda.common.ior   conda.common.serializer	   conda.core.subdir_datar
   conda.gateways.disk.creater   fixturer   r"   r&   r-   r/   r7   rC   r   r   r   <module>rN      s   9 8  				  ! ! ! ! ! ! T T T T T T T T T T 7 7 7 7 7 7 $ $ $ $ $ $ 7 7 7 7 7 7 - - - - - - 9 9 9 9 9 9 @ @ @ j!!!& & "!& 1 1 1 j!!!  "!2 j!!!  "!    
I.///  0/  r   