a ze @sddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z ej jsze e Wn eefyedYn0ddZGdddejZedkredS) N)rmtree change_cwdTESTFN_ENCODINGTESTFN_UNICODETESTFN_UNENCODABLEcreate_empty_filez1No Unicode filesystem semantics on this platform.cCstj|rt|dSN)ospathexistsunlink)filenamerJ/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_unicode_file.pyremove_if_existss rc@s<eZdZddZddZddZddZd d Zd d Zd S)TestUnicodeFilesc Cs>|tj||tj||t|tj|tjtj||tjtj||ttj|tjt|dt |dt |t t f| |||tj|tjt t |dktjtj|\}}t|}td|}dd|D}|||dS)NirNFDcSsg|]}td|qS)r) unicodedata normalize).0frrr 2z/TestUnicodeFiles._do_single..) assertTruer r r isfileaccessR_OKabspathchmodutimetime _do_copyishglobescapesplitlistdirrrZassertIn)selfr r baseZ file_listrrr _do_singles$   &  zTestUnicodeFiles._do_singlecCs^|tj|t||d|tj||tj|dt|d||tj|d|tj|t||dt|dt ||d|tj ||tj |dt |d||tj |d|tj |t ||d|tj|dt|d|tj |ddS)Nz.new) rr r rrenameZ assertFalseshutilcopyr mover copy2)r&Z filename1 filename2rrrr!7s&zTestUnicodeFiles._do_copyishc Cstj|rt|t|znt|Ht}|}td|}td|}| tj ||Wdn1sv0YWt |n t |0dS)Nr) r r isdirrmkdirrgetcwdrrZ assertEqualbasenamermdir)r&Z make_nameZ chdir_nameZ cwd_resultZ name_resultrrr _do_directoryTs     4zTestUnicodeFiles._do_directoryc Cst|t|z||Wt|n t|0|tj| t|tj }t |z||Wt|n t|0dSr) rrr(r r rr r openO_CREATclose)r&r rrrr _test_singlefs   zTestUnicodeFiles._test_singlecCs |ttdur|tdSr)r8rr)r&rrrtest_single_filesxs z"TestUnicodeFiles.test_single_filescCs8d}|t|t|tdur4|t|t|dS)Nz.dir)r4rr)r&extrrrtest_directories}s  z!TestUnicodeFiles.test_directoriesN) __name__ __module__ __qualname__r(r!r4r8r9r;rrrrrs r__main__)r r"r r*rZunittestZ test.supportrrrrrrr supports_unicode_filenamesencode UnicodeError TypeErrorZSkipTestrZTestCaserr<mainrrrrs  r