
    e`                        d Z ddlZddlZddlmZmZmZ ddlZddlmZ ddl	m
Z
mZmZmZmZmZ  ej                          Zej%                  ej&                  dz  dz        Zd Zej,                  j/                  d	d
dg      d        Zej,                  j/                  d	d
dg      d        Zej,                  j/                  d	d
dg      d        Zd Zd Zej,                  j;                  exr  ee       ed      k  d      d        Zd Zd Z d Z!d Z"ej,                  j;                  e
xs ed      d        Z#ej,                  j;                  exs ed      d        Z$ej,                  j;                  e
xr  ejJ                  d      d       d!        Z&ej,                  j;                  exr  ejJ                  d"      d#      d$        Z'd% Z(y)&zTest QtCore.    N)datedatetimetime)parse)PYQT5PYQT6PYQT_VERSIONPYSIDE2PYSIDE_VERSIONQtCorei  )microsecondc                  (    t         j                  J y)zTest qtpy.QtMsgHandlerN)r   qInstallMessageHandler     8/usr/lib/python3/dist-packages/qtpy/tests/test_qtcore.pytest_qtmsghandlerr      s    ((444r   methodtoPythontoPyDateTimec                     t        j                  t              } t        ||              }t	        |t
              sJ |t        k(  sJ y)z6Test `QDateTime.toPython` and `QDateTime.toPyDateTime`N)r   	QDateTimeNOWgetattr
isinstancer   )r   
q_datetimepy_datetimes      r   (test_QDateTime_toPython_and_toPyDateTimer      sC     !!#&J-'*f-/Kk8,,,#r   toPyDatec                     t        j                  t              j                         } t	        ||              }t        |t              sJ |t        j                         k(  sJ y)z*Test `QDate.toPython` and `QDate.toPyDate`N)r   r   r   r   r   r   )r   q_datepy_dates      r    test_QDate_toPython_and_toPyDater#   &   R     c"'')F%gff%'Ggt$$$chhj   r   toPyTimec                     t        j                  t              j                         } t	        ||              }t        |t              sJ |t        j                         k(  sJ y)z*Test `QTime.toPython` and `QTime.toPyTime`N)r   r   r   r   r   r   )r   q_timepy_times      r    test_QTime_toPython_and_toPyTimer)   /   r$   r   c                    t         j                  j                  J t         j                  j                  J t        j                  d      }t         j                  j                  d|j                         |j                          t         j                  j                  d|j                         |j                          y)z-Test `QEventLoop.exec_` and `QEventLoop.exec`Nd   )r   
QEventLoopexec_execQTimer
singleShotquit)qtbot
event_loops     r   test_qeventloop_execr4   8   s    ""...!!---""4(J
MMS*//2
MMS*//2OOr   c                  t    t         j                  j                  J t         j                  j                  J y)z(Test `QThread.exec_` and `QThread.exec_`N)r   QThreadr-   r.   r   r   r   test_qthread_execr7   C   s.    >>+++>>***r   z5.15z7QEnum macro doesn't seem to be present on PySide2 <5.15)reasonc                       G d dt         j                        }  |        }|j                         j                  d      j	                         dk(  sJ y)zTest QEnum macroc                   Z    e Zd Z G d dej                        Z ej                  e       y)test_qenum.<locals>.EnumTestc                       e Zd ZdZdZdZdZy)%test_qenum.<locals>.EnumTest.Positionr            N)__name__
__module____qualname__WestNorthSouthEastr   r   r   Positionr=   Q   s    DEEDr   rH   N)rA   rB   rC   enumIntEnumrH   r   QEnumr   r   r   EnumTestr;   P   s"    	t|| 	 	Xr   rL   r   rH   N)r   QObject
metaObject
enumeratorname)rL   objs     r   
test_qenumrR   I   sD    6>>  *C>>&&q)..0J>>>r   c                  Z   t         j                  j                  J t         j                  j                  t         j                  j                        	 J t         j                  j                  J t         j                  j	                  t         j                  j                        J y)z4Test `QLibraryInfo.location` and `QLibraryInfo.path`N)r   QLibraryInfolocation
PrefixPathpathr   r   r   #test_QLibraryInfo_location_and_pathrX   ]   s    ''333$$V%8%8%C%CD		 ##///##F$7$7$B$BCOOOr   c                  t    t         j                  j                  J t         j                  j                  J y)zBTest `QLibraryInfo.LibraryLocation` and `QLibraryInfo.LibraryPath`N)r   rT   LibraryLocationLibraryPathr   r   r   1test_QLibraryInfo_LibraryLocation_and_LibraryPathr\   h   s2    ..:::**666r   c                    t         j                  j                  J t         j                  j                         xs) t        j                  t        j
                  t        g      }|J t         j                  j                  dt         j                  j                         j                         t         j                  j                          t         j                  j                         xs) t        j                  t        j
                  t        g      }|J t         j                  j                  dt         j                  j                         j                         |j                          y)z$Test `QtCore.QCoreApplication.exec_`Nr+   )
r   QCoreApplicationr-   instancesys
executable__file__r/   r0   r1   qappapps     r   test_QCoreApplication_exec_rf   n   s   ""((444

!
!
*
*
, 0G0G	"1C ??
MMS&"9"9"B"B"D"I"IJ
!!#

!
!
*
*
, 0G0G	"1C ??
MMS&"9"9"B"B"D"I"IJIIKr   c                    t         j                  j                  J t         j                  j                         xs) t        j                  t        j
                  t        g      }|J t         j                  j                  dt         j                  j                         j                         t         j                  j                          t         j                  j                         xs) t        j                  t        j
                  t        g      }|J t         j                  j                  dt         j                  j                         j                         |j                          y)z#Test `QtCore.QCoreApplication.exec`Nr+   )
r   r^   r.   r_   r`   ra   rb   r/   r0   r1   rc   s     r   test_QCoreApplication_execrh      s   ""''333

!
!
*
*
, 0G0G	"1C ??
MMS&"9"9"B"B"D"I"IJ
  "

!
!
*
*
, 0G0G	"1C ??
MMS&"9"9"B"B"D"I"IJHHJr   z-Doesn't seem to be present on PyQt5 and PyQt6c                  t    t         j                  j                  J t         j                  j                  J y)zETest `QTextStreamManipulator.exec_` and `QTextStreamManipulator.exec`N)r   QTextStreamManipulatorr-   r.   r   r   r    test_qtextstreammanipulator_execrk      s4     ((..:::((--999r   z/Doesn't seem to be present on PySide2 and PyQt6c                       G d dt         j                        }  |        }t        |j                  t         j                        sJ y )Nc                   .    e Zd Z ej                         Zy)3test_QtCore_SignalInstance.<locals>.ClassWithSignalN)rA   rB   rC   r   Signalsignalr   r   r   ClassWithSignalrn      s    r   rq   )r   rM   r   rp   SignalInstance)rq   r_   s     r   test_QtCore_SignalInstancers      s6    
!&.. !  Hhoov'<'<===r   z5.9zaA specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.*to work with scoped enum accessc                     t         j                  j                  t         j                  j                  j                  k(  sJ t         j                  j
                  t         j                  j                  j
                  k(  sJ t         j                  j                  t         j                  j                  j                  k(  sJ t         j                  j                  t         j                  j                  j                  k(  sJ t         j                  j                  t         j                  j                  j                  k(  sJ t         j                  j                  t         j                  j                  j                  k(  sJ t         j                  j                   t         j                  j"                  j                   k(  sJ t         j                  j$                  t         j                  j"                  j$                  k(  sJ t         j                  j&                  t         j                  j(                  j&                  k(  sJ t         j                  j*                  t         j                  j(                  j*                  k(  sJ t         j                  j,                  t         j                  j"                  j.                  k(  sJ y)z7Test scoped and unscoped enum access for qtpy.QtCore.*.N)r   QAbstractAnimationStoppedStateQEventActionAddedTypeQt	AlignLeftAlignmentFlag
Key_ReturnKeytransparentGlobalColorWidget
WindowType
BackButtonMouseButtonXButton1BackgroundColorRoleItemDataRoleTextColorRole	MidButtonMiddleButtonr   r   r   test_enum_accessr      s    	!!))$$**22	3	3 ==$$(:(:(F(FFFF99&))"9"9"C"CCCC99699==#;#;;;;99  FII$9$9$E$EEEE99vyy33:::::99699#8#8#C#CCCC99!6!6!?!????		%%99!!55	6	6 99""fii&<&<&J&JJJJ99&))"7"7"D"DDDDr   z5.12.0z0Utility functions unavailable for PySide2 5.12.0c                  <    t         j                  j                  J y)zx
    Test included elements (mightBeRichText) from module QtGui.

    See: https://doc.qt.io/qt-5/qt-sub-qtgui.html
    N)r   r{   mightBeRichTextr   r   r   $test_qtgui_namespace_mightBeRichTextr      s     99$$000r   c                      t         j                  j                  J t         j                  j                         t         j                  j                  d      k(  sJ y)z^
    Test existence of `QFlags<ItemFlag>` typedef `ItemFlags` that was removed from PyQt6
    Nr   )r   r{   	ItemFlagsItemFlagr   r   r   test_itemflags_typedefr      sD     99***99 FII$6$6q$9999r   ))__doc__rI   r`   r   r   r   pytestpackaging.versionr   qtpyr   r   r	   r
   r   r   now_nowreplacer   r   r   markparametrizer   r#   r)   r4   r7   skipifrR   rX   r\   rf   rh   rk   rs   
startswithr   r   r   r   r   r   <module>r      s'     
 ) )  #  x||~
ll 0 0D 84 ?lA5
 J#?@ A J
#;<! =! J
#;<! =!+ 5n%f5D  ?	? P7"" 	NU:  :	: u<  >	> 	,%l%%e,&  
E
E* 3)))(3=  1	1:r   