
    eF                     x   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 d dlmZm	Z	m
Z
mZ d dlmZ d dlmZ er ej                   dd       d d	lmZ d
Ze j&                  d        Zd Zej,                  j/                  e	xr*  e       xr!  ee
       ed      k  xr ej0                  dv d      d        Zd Zd Zy)    N)parse)PYSIDE2PYSIDE6PYSIDE_VERSION	QtWidgets)	QComboBox)using_conda
pyside2uiczpyside2uic not installed)reason)uiczT
from qtpy.QtWidgets import QComboBox
class _QComboBoxSubclass(QComboBox):
    pass
c              #     K   t        | dz  dd      5 }|j                  t               ddd       t        j                  j                  dt        |              d t        j                  j                  d       y# 1 sw Y   VxY ww)z}
    Context manager that sets up a temporary module with a QComboBox subclass
    and then removes it once we are done.
    zqcombobox_subclass.pywzutf-8)modeencodingNr   )openwriteQCOMBOBOX_SUBCLASSsyspathinsertstrpop)temp_dir_pathfs     5/usr/lib/python3/dist-packages/qtpy/tests/test_uic.pyenabled_qcombobox_subclassr      sp      
//
 $ 
	"#$ HHOOAs=)*	HHLLO$ $s   BA?AB?BBc                    t        j                         5  t        j                  dt        d       t	        j
                  t        j                  j                  t        j                  j                  t              d            }ddd       t        j                  t        j                        sJ t        |j                  t               sJ y# 1 sw Y   LxY w)zd
    Make sure that the patched loadUi function behaves as expected with a
    simple .ui file.
    ignore.*mode.*categorymessagetest.uiN)warningscatch_warningsfilterwarningsDeprecationWarningr   loadUiosr   joindirname__file__
isinstance
pushButtonr   QPushButtoncomboBoxr   )qtbotuis     r   test_load_uir3   .   s    
 
	 	 	" L'	

 ZZRWW__X%>	JKL bmmY%:%:;;;bkk9---L Ls   A1CCz6.5)darwinlinuxz>pyside6-uic command not contained in all conda-forge packages.c                 @   t        j                         5  t        j                  dt        d       t	        j
                  t        j                  j                  t        j                  j                  t              d            \  }}ddd       j                  dk(  sJ  G d d|      } |       }t        |t        j                        sJ t        |j                  t        j                         sJ t        |j"                  t$              sJ y# 1 sw Y   xY w)	zh
    Make sure that the patched loadUiType function behaves as expected with a
    simple .ui file.
    r   r   r    r#   NUi_Formc                        e Zd Z fdZ xZS )!test_load_ui_type.<locals>.Widgetc                 D    t         |           | j                  |        y N)super__init__setupUi)self	__class__s    r   r=   z*test_load_ui_type.<locals>.Widget.__init__W   s    GLL    )__name__
__module____qualname__r=   __classcell__)r@   s   @r   Widgetr9   V   s    	 	rA   rF   )r$   r%   r&   r'   r   
loadUiTyper)   r   r*   r+   r,   rB   r-   r   QWidgetr.   r/   r0   r   )r1   ui_typeui_base_typerF   r2   s        r   test_load_ui_typerK   ?   s     
	 	 	" 
'	

 !$GGLL2I>!

 y(((w 
 
Bb)++,,,bmmY%:%:;;;bkk9---'
 
s   A4DDc           	         t        |      5  ddlm} t        j                         5  t        j
                  dt        d       t        j                  t        j                  j                  t        j                  j                  t              d            }ddd       ddd       t        j                  t         j"                        sJ t        |j$                        sJ y# 1 sw Y   PxY w# 1 sw Y   TxY w)z
    Test that we can load a .ui file with custom widgets without having to
    explicitly specify a dictionary of custom widgets, even in the case of
    PySide.
    r   )_QComboBoxSubclassr   r   r    ztest_custom.uiN)r   qcombobox_subclassrM   r$   r%   r&   r'   r   r(   r)   r   r*   r+   r,   r-   r.   r   r/   r0   )r1   tmp_pathrM   r2   s       r   test_load_ui_custom_autorP   a   s     
$H	- 9$$& 	##+"
 RWW__X68HIB	 bmmY%:%:;;;bkk#5666	 	 s#   C3A1C'C3'C0	,C33C<c                      t         j                  j                  dd      j                         } | j	                  d      r%t        t        d      sJ t        t        d      sJ yg d}t        d |D              sJ y)	z'Test that we load the full uic objects.QT_API pysider(   rG   )	compileUicompileUiDirr(   rG   widgetPluginPathc              3   <   K   | ]  }t        t        |        y wr;   )hasattrr   ).0os     r   	<genexpr>z%test_load_full_uic.<locals>.<genexpr>   s     4q73?4s   N)r)   environgetlower
startswithrY   r   all)rR   objectss     r   test_load_full_uicrc   x   sj    ZZ^^Hb)//1F"sH%%%sL)))
 4G4444rA   )
contextlibr)   r   r$   pytestpackaging.versionr   qtpyr   r   r   r   qtpy.QtWidgetsr   qtpy.tests.utilsr	   importorskipr   r   contextmanagerr   r3   markskipifplatformrK   rP   rc    rA   r   <module>rp      s     	 
   # < < $ (
F-GH    (."  ..ne,. 
,	,K  ..67.5rA   