
    !hi2                        d Z ddlZddlZddlZddlZddlmZ ej                  j                  Zej                  j                  Z	ej                  j                  Z
ej                  j                  Zej                  j                  ddgd      Zej                  j                  ddgd      Zd	efd
Zd	efdZdefdZddZy)zS
Decorators for skipping PyInstaller tests when specific requirements are not met.
    N)check_requirementpyi_builderonedirT)indirectonefilepackagec                     t        |       s#t        j                  j                  d|  d      S t        j                  j	                  dd|  d      S )a  
    Skip a decorated test if **package** is not importable.

    Arguments:
        package:
            The name of the module. May be anything that is allowed after the ``import`` keyword. e.g. 'numpy' or
            'PIL.Image'.
    Returns:
        A pytest marker which either skips the test or does nothing.

    This function intentionally does not import the module. Doing so can lead to `sys.path` and `PATH` being
    polluted, which then breaks later builds.
    zCan't import 'z'.FDon't skip: 'z' is importable.reason)
importablepytestmarkskipskipif)r   s    CC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/utils/tests.pyimportorskipr   "   sN     g{{.	 <==;;emG9DT,UVV    c                     ddl m} d| v rRt        | j                  d      d         syddlm}m}  |t        j                  dd| z   g||      j                  dk(  S  ||       d uS )	Nr   )	find_spec.F)DEVNULLrunz-czimport )stdoutstderr)
importlib.utilr   r   split
subprocessr   r   sys
executable
returncode)r   r   r   r   s       r   r   r   5   sf    ( g~'--,Q/0+CNND)g*=>wW^_jjnoooWT))r   requirementc                     t        |       r%t        j                  j                  dd|  d      S t        j                  j	                  d|  d      S )a  
    Mark a test to be skipped if **requirement** is not satisfied.

    Args:
        requirement:
            A distribution name and optional version specifier(s). See :func:`PyInstaller.utils.hooks.check_requirement`
            which this argument is forwarded to.
    Returns:
        Either a skip marker or a dummy marker.

    This function operates on distribution metadata, and does not import any modules.
    Fr
   z' is satisfied.r   z	Requires r   )r   r   r   r   r   )r"   s    r   requiresr$   E   sM     %{{!!%-}O0\!]]{{)K= :;;r   c                     t        j                         d   d   }|r|dz   |z   }|j                  dd      }| |dz   z  }t        j                  |      }|j                  |d       |S )	a  
    Generate a source file for testing.

    The source will be written into a file named like the test-function. This file will then be passed to
    `test_script`. If you need other related file, e.g. as `.toc`-file for testing the content, put it at at the
    normal place. Just mind to take the basnename from the test-function's name.

    :param script: Source code to create executable from. This will be saved into a temporary file which is then
                   passed on to `test_script`.

    :param test_id: Test-id for parametrized tests. If given, it will be appended to the script filename,
                    separated by two underscores.
          __r   _z.pyzutf-8)encoding)inspectstackreplacetextwrapdedent
write_text)tmp_pathsourcetest_idtestname
scriptfiles        r   gen_sourcefiler6   X   st     }}q!!$Hd?W, S)HX-.J__V$F&73r   )N)__doc__r+   r   r.   r   PyInstaller.utils.hooksr   r   parametrizer   xfailr   onedir_onlyonefile_onlystrr   r   r$   r6    r   r   <module>r?      s     
   5 kk%%			{{ kk%%mhZ$%O{{&&}ykD&QW# W&* * <# <&r   