ó
cV]c           @   s  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z m Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d Z e j d    Z d d  Z e j j e oĮ e  j j d	 d  d k	 d
 d d    Z e j j e oż e  j j d	 d  d k	 d
 d d    Z d   Z d S(   i’’’’N(   t   PYSIDE2t	   QtWidgets(   t	   QComboBox(   t   uic(   t   loadUisT   
from qtpy.QtWidgets import QComboBox
class _QComboBoxSubclass(QComboBox):
    pass
c         c   s`   t  |  j d  j d   } | j t  Wd QXt j j d |  j  d Vt j j d  d S(   s}   
    Context manager that sets up a temporary module with a QComboBox subclass
    and then removes it once we are done.
    s   qcombobox_subclass.pyt   wNi    (	   t   opent   joint   strpatht   writet   QCOMBOBOX_SUBCLASSt   syst   patht   insertt   pop(   t   tmpdirt   f(    (    s2   lib/python2.7/site-packages/qtpy/tests/test_uic.pyt   enabled_qcombobox_subclass   s
    c         C   s4   t  j j   } | d k r0 t  j d g  } n  | S(   s;   
    Helper function to return a QApplication instance
    t    N(   R   t   QApplicationt   instancet   None(   t	   icon_patht   qapp(    (    s2   lib/python2.7/site-packages/qtpy/tests/test_uic.pyt   get_qapp#   s    t   CIt   reasons$   It segfaults in our CIs with PYSIDE2c          C   sg   t    }  t t j j t j j t  d   } t | j t	 j
  sK t  t | j t  sc t  d S(   sd   
    Make sure that the patched loadUi function behaves as expected with a
    simple .ui file.
    s   test.uiN(   R   R   t   osR   R   t   dirnamet   __file__t
   isinstancet
   pushButtonR   t   QPushButtont   AssertionErrort   comboBoxR   (   t   appt   ui(    (    s2   lib/python2.7/site-packages/qtpy/tests/test_uic.pyt   test_load_ui-   s    	'c         C   s   t    } t |   < d d l m } t t j j t j j t	  d   } Wd QXt
 | j t j  sn t  t
 | j |  s t  d S(   s§   
    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.
    i’’’’(   t   _QComboBoxSubclasss   test_custom.uiN(   R   R   t   qcombobox_subclassR&   R   R   R   R   R   R   R   R   R   R    R!   R"   (   R   R#   R&   R$   (    (    s2   lib/python2.7/site-packages/qtpy/tests/test_uic.pyt   test_load_ui_custom_auto:   s    		-c          C   s   t  j j d d  j   }  |  j d  rX t t d  s? t  t t d  s t  nC d d d d d g } t g  | D] } t t |  ^ qw  s t  d	 S(
   s;   Test that we load the full uic objects for PyQt5 and PyQt4.t   QT_APIR   t   pysideR   t
   loadUiTypet	   compileUit   compileUiDirt   widgetPluginPathN(	   R   t   environt   gett   lowert
   startswitht   hasattrR   R!   t   all(   R)   t   objectst   o(    (    s2   lib/python2.7/site-packages/qtpy/tests/test_uic.pyt   test_load_full_uicM   s    	(   R   R   t
   contextlibt   pytestt   qtpyR    R   t   qtpy.QtWidgetsR   R   t   qtpy.uicR   R
   t   contextmanagerR   R   R   t   markt   skipifR/   R0   R%   R(   R7   (    (    (    s2   lib/python2.7/site-packages/qtpy/tests/test_uic.pyt   <module>   s   
**