a
    äzeÙ  ã                   @   s|   d Z ddlZddlmZ e def¡ e d¡ZW d  ƒ n1 sF0    Y  G dd„ dejƒZ	dd	„ Z
ed
krxe
ƒ  dS )z‡Test script for the binhex C module

   Uses the mechanism of the python binhex module
   Based on an original test by Roger E. Masse.
é    N)ÚsupportÚ Úbinhexc                   @   s8   e Zd Zdd„ Zdd„ ZdZdd„ Zdd	„ Zd
d„ ZdS )ÚBinHexTestCasec                 C   s(   t jd | _t jd | _t jd | _d S )NÚ1Ú2ZPvery_long_filename__very_long_filename__very_long_filename__very_long_filename__)r   ZTESTFN_ASCIIÚfname1Úfname2Úfname3©Úself© r   ú&/usr/lib/python3.9/test/test_binhex.pyÚsetUp   s    zBinHexTestCase.setUpc                 C   s(   t  | j¡ t  | j¡ t  | j¡ d S ©N)r   Úunlinkr   r	   r
   r   r   r   r   ÚtearDown   s    zBinHexTestCase.tearDowns   Jack is my heroc                 C   sž   t | jdƒ}| | j¡ W d   ƒ n1 s.0    Y  t | j| j¡ t | j| j¡ t | jdƒ}| ¡ }W d   ƒ n1 s‚0    Y  |  | j|¡ d S )NÚwbÚrb)	Úopenr   ÚwriteÚDATAr   r	   ZhexbinÚreadlineZassertEqual)r   ÚfZfinishr   r   r   Útest_binhex   s    *&zBinHexTestCase.test_binhexc                 C   s0   t | jdƒ}| ¡  |  tjtj| j| j¡ dS )zÛ
        The testcase fails if no exception is raised when a filename parameter provided to binhex.binhex()
        is too long, or if the exception raised in binhex.binhex() is not an instance of binhex.Error.
        r   N)r   r
   ÚcloseZassertRaisesr   ÚErrorr	   )r   Zf3r   r   r   Ú"test_binhex_error_on_long_filename)   s    z1BinHexTestCase.test_binhex_error_on_long_filenamec                 C   sŒ   t | jdƒ}| | j¡ W d   ƒ n1 s.0    Y  t | j| j¡ t | jdƒ}| ¡ }W d   ƒ n1 sr0    Y  |  d|¡ d S )Nr   r   ó   
)r   r   r   r   r   r	   ÚreadZassertNotIn)r   r   ÚfpÚcontentsr   r   r   Útest_binhex_line_endings3   s    *&z'BinHexTestCase.test_binhex_line_endingsN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r"   r   r   r   r   r      s   
r   c                   C   s   t  t¡ d S r   )r   Zrun_unittestr   r   r   r   r   Ú	test_main?   s    r&   Ú__main__)Ú__doc__ZunittestÚtestr   Zcheck_warningsÚDeprecationWarningZimport_fresh_moduler   ZTestCaser   r&   r#   r   r   r   r   Ú<module>   s   (2