o
    tVg                     @   s\   d dl Z d dlZd dlmZmZ G dd dejZG dd dejZedkr,e	  dS dS )    N)encode_stringencode_file_pathc                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zz
ddlmZ eaW n	 eyC   Y nw dd Zdd Zdd ZdS ) RWopsEncodeStringTestc                 C   s   t d }| | d S Nr   assertIsNone)selfencoded_string r
   N/home/ubuntu/.local/lib/python3.10/site-packages/pygame/tests/rwobject_test.pytest_obj_None
   s   z#RWopsEncodeStringTest.test_obj_Nonec                 C      d}t |}| |t d S NHello)r   assertIsInstancebytesr   ur	   r
   r
   r   test_returns_bytes      z(RWopsEncodeStringTest.test_returns_bytesc                 C   s    d}t |dd}| || d S )Ns   encyclopdiaasciistrict)r   assertIs)r   br	   r
   r
   r   test_obj_bytes   s   z$RWopsEncodeStringTest.test_obj_bytesc                 C   s$   d}| d}| t|d| d S )Nu   Þe Olde Kompüter Shoppeutf-8encodeassertEqualr   r   r   r   r
   r
   r   test_encode_unicode   s   
z)RWopsEncodeStringTest.test_encode_unicodec                 C      |  tt d S r   assertRaisesSyntaxErrorr   r   r
   r
   r   test_error_fowarding       z*RWopsEncodeStringTest.test_error_fowardingc                 C   s(   d}| dd}| t|dd| d S )Nu"   abcĉdefgĝhĥijĵklmnoprsŝtuŭvzr   ignorer   r   r
   r
   r   test_errors#   s   z!RWopsEncodeStringTest.test_errorsc                 C   s   d}t |dd}| | d S Nu   abr   r   r   r   r
   r
   r   test_encoding_error(   s   z)RWopsEncodeStringTest.test_encoding_errorc                 C   s(   d}| dd}t|}| || d S )Nu   aǷbunicode_escapebackslashreplace)r   r   r   )r   r   r   r	   r
   r
   r   test_check_defaults.   s   z)RWopsEncodeStringTest.test_check_defaultsc                 C   s   d}|  tt|ddt d S r*   r"   )r   r   r
   r
   r   
test_etype5   s   z RWopsEncodeStringTest.test_etypec                 C   s$   d| fD ]}| j ttd|d qdS ),Ensures invalid etypes are properly handled.r$   testetypeN)r#   	TypeErrorr   r   r3   r
   r
   r   test_etype__invalid9   s   z)RWopsEncodeStringTest.test_etype__invalidc                 C   s<   d}t |td}t | dd}| || | || d S )N   a b cr2   r   r   )r   r$   decoder   r   )r   r   r	   encoded_decode_stringr
   r
   r   test_string_with_null_bytes?   s
   z1RWopsEncodeStringTest.test_string_with_null_bytesr   )getrefcountc                 C   sR   ddd  }| d}t|}t|}| t|| t|}| t|| d S )Ns%    This is a string that is not cached.   r   )r8   r;   r   r   )r   bpathupathbeforer
   r
   r   test_refcountO   s   
z#RWopsEncodeStringTest.test_refcountc                 C   s&   d}d}t |ddt}| || d S )Ns   a𓂧bu   a𓂧br   r   )r   AssertionErrorr   )r   utf_8r   r   r
   r
   r   test_smpX   s   zRWopsEncodeStringTest.test_smpc                 C   s<   	 t tdd}| |d t td}| |d dS )z4Test loading string representation of pathlib objectfoor   s   foobazs   bazN)r   pathlibPurePathr   Path)r   encodedr
   r
   r   test_pathlib_obj^   s
   z&RWopsEncodeStringTest.test_pathlib_objN)__name__
__module____qualname__r   r   r   r    r&   r)   r+   r.   r/   r6   r:   sysr;   _gImportErrorr@   rC   rJ   r
   r
   r
   r   r      s*    	r   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )RWopsEncodeFilePathTestc                 C   r   r   )r   r   r   )r   r   encoded_file_pathr
   r
   r   test_encodingp   r   z%RWopsEncodeFilePathTest.test_encodingc                 C   r!   r   )r#   r$   r   r%   r
   r
   r   r&   v   r'   z,RWopsEncodeFilePathTest.test_error_fowardingc                 C   s   d}t |}| | d S Nr7   )r   r   )r   r   rR   r
   r
   r   test_path_with_null_bytesy   s   z1RWopsEncodeFilePathTest.test_path_with_null_bytesc                 C   s   d}|  tt|t d S rT   r#   r4   r   )r   r   r
   r
   r   r/      s   z"RWopsEncodeFilePathTest.test_etypec                 C   s"   d| fD ]
}|  ttd| qdS )r0   r$   r1   NrV   r5   r
   r
   r   r6      s   z+RWopsEncodeFilePathTest.test_etype__invalidN)rK   rL   rM   rS   r&   rU   r/   r6   r
   r
   r
   r   rQ   m   s    rQ   __main__)
rF   unittestpygamer   r   TestCaser   rQ   rK   mainr
   r
   r
   r   <module>   s    f