ó
cV]c           @@  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z m Z e j	 d  d k Z
 d d  Z d e f d     YZ e j j e
 p² 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 S(   i    (   t   absolute_importN(   t   PYSIDE2t   QtGuit	   QtWidgetst   3c         C@  s4   t  j j   } | d  k r0 t  j d g  } n  | S(   Nt    (   R   t   QApplicationt   instancet   None(   t	   icon_patht   qapp(    (    s>   lib/python2.7/site-packages/qtpy/tests/test_patch_qcombobox.pyt   get_qapp   s    t   Datac           B@  s   e  Z d  Z d   Z RS(   sv   
    Test class to store in userData. The __getitem__ is needed in order to
    reproduce the segmentation fault.
    c         C@  s   t  d   d  S(   Nt   Failing(   t
   ValueError(   t   selft   item(    (    s>   lib/python2.7/site-packages/qtpy/tests/test_patch_qcombobox.pyt   __getitem__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s>   lib/python2.7/site-packages/qtpy/tests/test_patch_qcombobox.pyR      s   t   CIt   reasons4   It segfaults in Python 3 and in our CIs with PySide2c    
      C@  s  t    }  t   } t   } t   } t   } t   } t   } t j   } t j   } t j   }	 |	 j d |  |	 j d d |  |	 j d |  |	 j d |  |	 j | d |  |	 j d | d |  |	 j | d	  |	 j d
 | d  |	 j	   |	 j
 |  d k st  |	 j
 |  d k s2t  |	 j
 |  d k sMt  |	 j
 |  d k sht  |	 j
 |  d k st  |	 j
 |  d k st  |	 j d  | k sıt  |	 j d  | k sÔt  |	 j d  | k sït  |	 j d  | k s
t  |	 j d  | k s%t  |	 j d
  d k s@t  |	 j d  d k s[t  |	 j d  d k svt  |	 j d  d k st  |	 j d  d k sĴt  |	 j d  d k sÇt  |	 j d  d k sât  |	 j d
  d k sŭt  |	 j d  d	 k st  d S(   sĤ  
    In PySide, using Python objects as userData in QComboBox causes
    Segmentation faults under certain conditions. Even in cases where it
    doesn't, findData does not work correctly. Likewise, findData also
    does not work correctly with Python objects when using PyQt4. On the
    other hand, PyQt5 deals with this case correctly. We therefore patch
    QComboBox when using PyQt4 and PySide to avoid issues.
    t   ai    t   bt   ci   t   di   t   et   fi   t   gi   i   i˙˙˙˙i   N(   R   R   R   t   QIconR   t	   QComboBoxt   addItemt
   insertItemt   setItemDatat   showt   findDatat   AssertionErrort   itemDataR   t   itemText(
   t   appt   data1t   data2t   data3t   data4t   data5t   data6t   icon1t   icon2t   widget(    (    s>   lib/python2.7/site-packages/qtpy/tests/test_patch_qcombobox.pyt   test_patched_qcombobox   sN    							
s$   It segfaults in our CIs with PYSIDE2c          C@  s   t    }  t j   } d g } xm t d  D]_ } | j   x3 t |  D]% \ } \ } } | j | d | qH W| j   } | j	 d  q+ Wd S(   s  
    This is a regression test for an issue that caused the call to item(0)
    below to trigger segmentation faults in PySide. The issue is
    non-deterministic when running the call once, so we include a loop to make
    sure that we trigger the fault.
    R   i'  t   userDatai    N(   R   N(
   R   R   R   R   t   ranget   cleart	   enumerateR    t   modelR   (   R(   t   combot
   label_datat   itert   it   labelt   dataR7   (    (    s>   lib/python2.7/site-packages/qtpy/tests/test_patch_qcombobox.pyt   test_model_itemY   s    			
(   t
   __future__R    t   ost   syst   pytestt   qtpyR   R   R   t   versiont   PY3R   R   t   objectR   t   markt   skipift   environt   getR2   R>   (    (    (    s>   lib/python2.7/site-packages/qtpy/tests/test_patch_qcombobox.pyt   <module>   s   	0;*