
    e                        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       d Zd Zd Zd Zd Zej$                  j'                  d	 ej(                               d
        Zy# 1 sw Y   JxY w)    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 y),
    Make sure that we are using PySide
    r   NQT_APIpyside2)PySide2r   QEventr   QPainterr   QWidgetr   QWebEnginePageosenviron)r   s    6/usr/lib/python3/dist-packages/qtpy/tests/test_main.pyassert_pyside2r      s     ==GNN11111>>W]]33333 1 1 9 9999))%%44	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 y)r	   r   Nr
   pyside6)	PySide6r   r   r   r   r   r   r   r   )r   s    r   assert_pyside6r      sx     ==GNN11111>>W]]33333 1 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 y)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     ==ELL/////>>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 y)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                  j                  dd      j                         } | dk(  rt	                y| dk(  rt                y| dk(  rt                y| dk(  rt                y	 ddl}t	                y# t        $ rR 	 ddl
}t                Y y# t        $ r4 	 ddl}t                n # t        $ r ddl}t                Y nw xY wY Y yY Y y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   s    
 ZZ^^Hb)//1F	9		7		9		  N  	!!    ##  !N # %""$% %"#	!sZ   0A? ?	C	B
C	C#B2'C2C	CCCCCCCapic                 
   |  d}t        j                  |d|         t        j                  j	                         }dD ]
  }||v s||=  d| d}t        j                  t        j                  d|g|      }|j                         j                  d	      j                         \  }}|| j                         k(  sJ || j                         k(  sJ d
|d<   d}t        j                  t        j                  d|g|       y)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   
 E/C
iu$56
**//
C' #:Cu C $$cnndC%@cJF ,,.//8CCEGZciik!!!$$$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      s     	  
  4 4Z# ('(
- -	+	+%P  0	 0 0 23 A 4 AI( (s   BB