
    q'Ve                     "   d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZm	Z	  e j
        e          5  d dlmZ ddd           n# 1 swxY w Y   d Zd Zd Zd Zd Zej                            d	 ej                              d
             ZdS )    N)	API_NAMESQtCoreQtGui	QtWidgets)QtWebEngineWidgetsc                     ddl } t          j        | j        j        u sJ t          j        | j        j        u sJ t
          j        | j        j        u sJ t          j        | j        j        u sJ t          j
        d         dk    sJ dS ),
    Make sure that we are using PySide
    r   NQT_APIpyside2)PySide2r   QEventr   QPainterr   QWidgetr   QWebEnginePageosenviron)r   s    4lib/python3.11/site-packages/qtpy/tests/test_main.pyassert_pyside2r      s     NNN=GN11111>W]33333 1 99999)%4	5 	5 	5 	5 :h9,,,,,,    c                      ddl } t          j        | j        j        u sJ t          j        | j        j        u sJ t
          j        | j        j        u sJ t          j        d         dk    sJ dS )r	   r   Nr
   pyside6)	PySide6r   r   r   r   r   r   r   r   )r   s    r   assert_pyside6r      sw     NNN=GN11111>W]33333 1 99999 :h9,,,,,,r   c                      ddl } t          j        | j        j        u sJ t          j        | j        j        u sJ t
          j        | j        j        u sJ t          j        d         dk    sJ dS )z+
    Make sure that we are using PyQt5
    r   Nr
   pyqt5)	PyQt5r   r   r   r   r   r   r   r   )r   s    r   assert_pyqt5r   -   t     LLL=EL/////>U[11111 77777:h7******r   c                      ddl } t          j        | j        j        u sJ t          j        | j        j        u sJ t
          j        | j        j        u sJ t          j        d         dk    sJ dS )z+
    Make sure that we are using PyQt6
    r   Nr
   pyqt6)	PyQt6r   r   r   r   r   r   r   r   )r!   s    r   assert_pyqt6r"   9   r   r   c                      t           j                            dd                                          } | dk    rt	                       dS | dk    rt                       dS | dk    rt                       dS | dk    rt                       dS 	 ddl}t	                       dS # t          $ rc 	 ddl
}t                       Y dS # t          $ r? 	 ddl}t                       n"# t          $ r ddl}t                       Y nw xY wY Y dS Y Y dS w xY ww xY w)	zO
    If QT_API is specified, we check that the correct Qt wrapper was used
    r
    r   r   r    r   r   N)r   r   getlowerr   r   r"   r   r   ImportErrorr   r!   r   )r
   r   r   r!   r   s        r   test_qt_apir(   E   sw   
 Z^^Hb))//11F	9			7			9			LLL  NNNNN  	! 	! 	!!         # # ## LLL !NNNN # % % %"NNN"$$$$$%
 #NNN %$$$#	!sZ   B   
D+C /D 
D	CD	C=:D	<C==D	 DDD		Dapic                    |  d}t          j        |d|             t          j                                        }dD ]	}||v r||= 
d| d}t          j        t          j        d|g|          }|	                                
                    d	                                          \  }}||                                 k    sJ ||                                 k    sJ d
|d<   d}t          j        t          j        d|g|           dS )z[
    If no QT_API is specified but some Qt is imported, ensure QT_API is set properly.
    z.QtCorez	Requires )reason)r
   
USE_QT_APIz
import zG
from qtpy import API
import os
print(API)
print(os.environ['QT_API'])
z-c)envzutf-8badr
   z
try:
    import qtpy
except ValueError as exc:
    assert 'Specified QT_API' in str(exc), str(exc)
else:
    raise AssertionError('QtPy imported despite bad QT_API')
z-OcN)pytestimportorskipr   r   copy
subprocesscheck_outputsys
executablestripdecode
splitlinesr&   
check_call)r)   modr-   keycmdoutputgot_api
env_qt_apis           r   test_qt_api_environr@   m   s-   
 ///C
$5$5$56666
*//

C'  #::C  C $cndC%@cJJJF ,,..//88CCEEGZciikk!!!!$$$$CMC 3>5#6C@@@@@@r   )
contextlibr   r2   r4   r/   qtpyr   r   r   r   suppress	Exceptionr   r   r   r   r"   r(   markparametrizevaluesr@    r   r   <module>rI      sk       				     



  4 4 4 4 4 4 4 4 4 4 4 4Z## ( (''''''( ( ( ( ( ( ( ( ( ( ( ( ( ( (
- - - - - -	+ 	+ 	+	+ 	+ 	+% % %P  0	 0 2 233 A  A 43 A  A  As   AAA