o
    gg                     @   s   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ede	f e
dZW d   n1 s5w   Y  G d	d
 d
ejZdd ZedkrPe  dS dS )zTest 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)import_helper)	os_helper)warnings_helper 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   F/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/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w   Y  t| j| j t| j| j t | jd}| }W d    n1 sAw   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w   Y  t| j| j t | jd}| }W d    n1 s9w   Y  | d| d S )Nr   r      
)r   r   r   r   r   r   readZassertNotIn)r   r   fpcontentsr   r   r   test_binhex_line_endings7   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_mainC   s   r)   __main__)__doc__Zunittesttestr   Ztest.supportr   r   r   Zcheck_warningsDeprecationWarningZimport_fresh_moduler   ZTestCaser   r)   r&   r   r   r   r   <module>   s    2
