B
BüÎ_±  ã               @   sà   d dl Zd dlm  mZ d dlZd dlZd dlm	Z	 dd„ Z
e	 eje d¡Zejjdd„ ƒZe	 eje d¡Zejjdd„ ƒZe	jeje dd	d
Zejjdd„ ƒZdZG dd„ dƒZe	 d¡Zejjdd„ ƒZdd„ ZdS )é    N)Útestingc               C   s   dS )NZmocked© r   r   r   úP/home/kop/projects/devel/pgwui/pgwui_testing/PGWUI_Testing/tests/test_testing.pyÚfunc_to_mock(   s    r   c             C   sž   d}|| _ | ƒ }||k}|s–t d|fd||f¡dt ¡ ksFt |¡rPt |¡nddt ¡ ksht |¡rrt |¡nddœ }dd|i }tt |¡ƒ‚d }d S )	Nz
test value)ú==)z%(py0)s == %(py2)sÚresultÚ
test_value)Úpy0Úpy2zassert %(py4)sÚpy4)	Úreturn_valueÚ
@pytest_arÚ_call_reprcompareÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚ	_safereprÚAssertionErrorÚ_format_explanation)Úmocked_funcr   r   Ú@py_assert1Ú@py_format3Ú@py_format5r   r   r   Útest_make_mock_fixture_fixture0   s      `   r   c             C   sž   d}|| _ | ƒ }||k}|s–t d|fd||f¡dt ¡ ksFt |¡rPt |¡nddt ¡ ksht |¡rrt |¡nddœ }dd|i }tt |¡ƒ‚d }d S )	Nz
test value)r   )z%(py0)s == %(py2)sr   r   )r	   r
   zassert %(py4)sr   )	r   r   r   r   r   r   r   r   r   )Úmagic_mocked_funcr   r   r   r   r   r   r   r   Ú'test_make_magicmock_fixture_no_autospecC   s      `   r   T)Zautospecc             C   sž   d}|| _ | ƒ }||k}|s–t d|fd||f¡dt ¡ ksFt |¡rPt |¡nddt ¡ ksht |¡rrt |¡nddœ }dd|i }tt |¡ƒ‚d }d S )	Nz
test value)r   )z%(py0)s == %(py2)sr   r   )r	   r
   zassert %(py4)sr   )	r   r   r   r   r   r   r   r   r   )Úmagic_mocked_autospecced_funcr   r   r   r   r   r   r   r   Ú$test_make_magicmock_fixture_autospecR   s      `   r   z
not mockedc               @   s   e Zd Zdd„ ZdS )Ú	TestClassc             C   s   t S )N)Únormal_return_value)Úselfr   r   r   Úmethod_to_mockg   s    zTestClass.method_to_mockN)Ú__name__Ú
__module__Ú__qualname__r!   r   r   r   r   r   e   s   r   r!   c             C   sª   d}t ƒ }|| |ƒ_| ¡ }||k}|s¢t d|fd||f¡dt ¡ ksRt |¡r\t |¡nddt ¡ kstt |¡r~t |¡nddœ }dd|i }t	t 
|¡ƒ‚d }d S )	Nzmocked value)r   )z%(py0)s == %(py2)sr   r   )r	   r
   zassert %(py4)sr   )r   r   r!   r   r   r   r   r   r   r   r   )Úmocked_methodr   Úclsr   r   r   r   r   r   r   Ú!test_instance_method_mock_fixturen   s    
  `   r'   c              C   sœ   t ƒ } |  ¡ }|tk}|s”t d|fd|tf¡dt ¡ ksDt |¡rNt |¡nddt ¡ ksft t¡rpt t¡nddœ }dd|i }t	t 
|¡ƒ‚d }d S )N)r   )z%(py0)s == %(py2)sr   r   )r	   r
   zassert %(py4)sr   )r   r!   r   r   r   r   r   r   r   r   r   )r&   r   r   r   r   r   r   r   Ú*test_instance_method_mock_fixture_unmocked{   s      `   r(   )Úbuiltinsr   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter   ÚpytestÚsysÚpgwui_testingr   r   Zmake_mock_fixtureÚmodulesr"   r   ÚmarkZintegrationtestr   Zmake_magicmock_fixturer   r   r   r   r   r   Zinstance_method_mock_fixturer%   r'   r(   r   r   r   r   Ú<module>   s&     

