003 File Manager
Current Path:
/usr/local/lib/python3.8/test
usr
/
local
/
lib
/
python3.8
/
test
/
π
..
π
Sine-1000Hz-300ms.aif
(60.25 KB)
π
__init__.py
(47 B)
π
__main__.py
(41 B)
π
__pycache__
π
_test_multiprocessing.py
(183.09 KB)
π
allsans.pem
(9.87 KB)
π
ann_module.py
(1.08 KB)
π
ann_module2.py
(519 B)
π
ann_module3.py
(448 B)
π
audiodata
π
audiotest.au
(27.48 KB)
π
audiotests.py
(12.46 KB)
π
audit-tests.py
(8.9 KB)
π
autotest.py
(209 B)
π
bad_coding.py
(24 B)
π
bad_coding2.py
(30 B)
π
bad_getattr.py
(61 B)
π
bad_getattr2.py
(77 B)
π
bad_getattr3.py
(139 B)
π
badcert.pem
(1.88 KB)
π
badkey.pem
(2.11 KB)
π
badsyntax_3131.py
(32 B)
π
badsyntax_future10.py
(95 B)
π
badsyntax_future3.py
(172 B)
π
badsyntax_future4.py
(153 B)
π
badsyntax_future5.py
(184 B)
π
badsyntax_future6.py
(161 B)
π
badsyntax_future7.py
(196 B)
π
badsyntax_future8.py
(122 B)
π
badsyntax_future9.py
(142 B)
π
badsyntax_pep3120.py
(14 B)
π
bisect_cmd.py
(4.85 KB)
π
bytecode_helper.py
(1.56 KB)
π
capath
π
cfgparser.1
(67 B)
π
cfgparser.2
(19.02 KB)
π
cfgparser.3
(1.55 KB)
π
cjkencodings
π
clinic.test
(94.65 KB)
π
cmath_testcases.txt
(141.05 KB)
π
coding20731.py
(22 B)
π
curses_tests.py
(1.22 KB)
π
data
π
dataclass_module_1.py
(837 B)
π
dataclass_module_1_str.py
(835 B)
π
dataclass_module_2.py
(756 B)
π
dataclass_module_2_str.py
(754 B)
π
dataclass_textanno.py
(126 B)
π
datetimetester.py
(239.84 KB)
π
decimaltestdata
π
dis_module.py
(76 B)
π
doctest_aliases.py
(240 B)
π
double_const.py
(1.18 KB)
π
dtracedata
π
eintrdata
π
empty.vbs
(70 B)
π
encoded_modules
π
exception_hierarchy.txt
(1.78 KB)
π
ffdh3072.pem
(2.16 KB)
π
final_a.py
(411 B)
π
final_b.py
(411 B)
π
floating_points.txt
(15.92 KB)
π
fork_wait.py
(2.53 KB)
π
formatfloat_testcases.txt
(7.45 KB)
π
future_test1.py
(229 B)
π
future_test2.py
(149 B)
π
gdb_sample.py
(153 B)
π
good_getattr.py
(198 B)
π
idnsans.pem
(9.71 KB)
π
ieee754.txt
(3.21 KB)
π
imghdrdata
π
imp_dummy.py
(63 B)
π
inspect_fodder.py
(1.88 KB)
π
inspect_fodder2.py
(2.06 KB)
π
keycert.passwd.pem
(4.13 KB)
π
keycert.pem
(3.96 KB)
π
keycert2.pem
(3.98 KB)
π
keycert3.pem
(9.23 KB)
π
keycert4.pem
(9.24 KB)
π
keycertecc.pem
(5.5 KB)
π
libregrtest
π
list_tests.py
(16.54 KB)
π
lock_tests.py
(28.26 KB)
π
mailcap.txt
(1.24 KB)
π
make_ssl_certs.py
(9.25 KB)
π
mapping_tests.py
(21.75 KB)
π
math_testcases.txt
(23.19 KB)
π
memory_watchdog.py
(859 B)
π
mime.types
(47.37 KB)
π
mock_socket.py
(3.53 KB)
π
mod_generics_cache.py
(1.13 KB)
π
mp_fork_bomb.py
(448 B)
π
mp_preload.py
(351 B)
π
multibytecodec_support.py
(14.17 KB)
π
nokia.pem
(1.88 KB)
π
nosan.pem
(7.54 KB)
π
nullbytecert.pem
(5.31 KB)
π
nullcert.pem
(0 B)
π
outstanding_bugs.py
(370 B)
π
pickletester.py
(135.99 KB)
π
profilee.py
(2.97 KB)
π
pstats.pck
(65.05 KB)
π
pycacert.pem
(5.53 KB)
π
pycakey.pem
(2.43 KB)
π
pyclbr_input.py
(648 B)
π
pydoc_mod.py
(713 B)
π
pydocfodder.py
(6.18 KB)
π
pythoninfo.py
(20.34 KB)
π
randv2_32.pck
(7.34 KB)
π
randv2_64.pck
(7.19 KB)
π
randv3.pck
(7.82 KB)
π
re_tests.py
(25.93 KB)
π
recursion.tar
(516 B)
π
regrtest.py
(1.34 KB)
π
relimport.py
(27 B)
π
reperf.py
(538 B)
π
revocation.crl
(800 B)
π
sample_doctest.py
(1.02 KB)
π
sample_doctest_no_docstrings.py
(227 B)
π
sample_doctest_no_doctests.py
(269 B)
π
secp384r1.pem
(256 B)
π
selfsigned_pythontestdotnet.pem
(2.08 KB)
π
seq_tests.py
(14.18 KB)
π
sgml_input.html
(8.1 KB)
π
signalinterproctester.py
(2.7 KB)
π
sndhdrdata
π
sortperf.py
(4.69 KB)
π
ssl_cert.pem
(1.53 KB)
π
ssl_key.passwd.pem
(2.59 KB)
π
ssl_key.pem
(2.43 KB)
π
ssl_servers.py
(7.04 KB)
π
ssltests.py
(1.03 KB)
π
string_tests.py
(64.65 KB)
π
subprocessdata
π
support
π
talos-2019-0758.pem
(1.3 KB)
π
test___all__.py
(4.12 KB)
π
test___future__.py
(2.36 KB)
π
test__locale.py
(7.83 KB)
π
test__opcode.py
(3.03 KB)
π
test__osx_support.py
(13.66 KB)
π
test__xxsubinterpreters.py
(68.7 KB)
π
test_abc.py
(18 KB)
π
test_abstract_numbers.py
(1.49 KB)
π
test_aifc.py
(17.68 KB)
π
test_argparse.py
(172.67 KB)
π
test_array.py
(52.57 KB)
π
test_asdl_parser.py
(4.15 KB)
π
test_ast.py
(88.53 KB)
π
test_asyncgen.py
(31.44 KB)
π
test_asynchat.py
(9.28 KB)
π
test_asyncio
π
test_asyncore.py
(25.81 KB)
π
test_atexit.py
(5.81 KB)
π
test_audioop.py
(28.24 KB)
π
test_audit.py
(4.05 KB)
π
test_augassign.py
(7.68 KB)
π
test_base64.py
(30.17 KB)
π
test_baseexception.py
(6.86 KB)
π
test_bdb.py
(41.55 KB)
π
test_bigaddrspace.py
(2.92 KB)
π
test_bigmem.py
(44.88 KB)
π
test_binascii.py
(18 KB)
π
test_binhex.py
(1.79 KB)
π
test_binop.py
(14.14 KB)
π
test_bisect.py
(13.63 KB)
π
test_bool.py
(12.48 KB)
π
test_buffer.py
(160.04 KB)
π
test_bufio.py
(2.54 KB)
π
test_builtin.py
(78.38 KB)
π
test_bytes.py
(72.23 KB)
π
test_bz2.py
(36.76 KB)
π
test_c_locale_coercion.py
(18.82 KB)
π
test_calendar.py
(48.71 KB)
π
test_call.py
(20.88 KB)
π
test_capi.py
(30.46 KB)
π
test_cgi.py
(22.15 KB)
π
test_cgitb.py
(2.5 KB)
π
test_charmapcodec.py
(1.68 KB)
π
test_class.py
(17.42 KB)
π
test_clinic.py
(21.71 KB)
π
test_cmath.py
(24.07 KB)
π
test_cmd.py
(6.1 KB)
π
test_cmd_line.py
(33.72 KB)
π
test_cmd_line_script.py
(31.46 KB)
π
test_code.py
(13.66 KB)
π
test_code_module.py
(5.51 KB)
π
test_codeccallbacks.py
(40.97 KB)
π
test_codecencodings_cn.py
(3.86 KB)
π
test_codecencodings_hk.py
(701 B)
π
test_codecencodings_iso2022.py
(1.36 KB)
π
test_codecencodings_jp.py
(4.79 KB)
π
test_codecencodings_kr.py
(2.96 KB)
π
test_codecencodings_tw.py
(681 B)
π
test_codecmaps_cn.py
(746 B)
π
test_codecmaps_hk.py
(386 B)
π
test_codecmaps_jp.py
(1.7 KB)
π
test_codecmaps_kr.py
(1.16 KB)
π
test_codecmaps_tw.py
(705 B)
π
test_codecs.py
(129.38 KB)
π
test_codeop.py
(7.97 KB)
π
test_collections.py
(83.93 KB)
π
test_colorsys.py
(3.83 KB)
π
test_compare.py
(3.82 KB)
π
test_compile.py
(36.48 KB)
π
test_compileall.py
(26.7 KB)
π
test_complex.py
(30.24 KB)
π
test_concurrent_futures.py
(44.93 KB)
π
test_configparser.py
(84.93 KB)
π
test_contains.py
(3.49 KB)
π
test_context.py
(29.33 KB)
π
test_contextlib.py
(32.54 KB)
π
test_contextlib_async.py
(14.82 KB)
π
test_copy.py
(25.81 KB)
π
test_copyreg.py
(4.39 KB)
π
test_coroutines.py
(62.52 KB)
π
test_cprofile.py
(6.33 KB)
π
test_crashers.py
(1.17 KB)
π
test_crypt.py
(3.97 KB)
π
test_csv.py
(47.77 KB)
π
test_ctypes.py
(184 B)
π
test_curses.py
(45.47 KB)
π
test_dataclasses.py
(108.8 KB)
π
test_datetime.py
(2.15 KB)
π
test_dbm.py
(6.45 KB)
π
test_dbm_dumb.py
(10.61 KB)
π
test_dbm_gnu.py
(6.22 KB)
π
test_dbm_ndbm.py
(5.05 KB)
π
test_decimal.py
(206.63 KB)
π
test_decorators.py
(9.48 KB)
π
test_defaultdict.py
(5.88 KB)
π
test_deque.py
(34.46 KB)
π
test_descr.py
(190.58 KB)
π
test_descrtut.py
(11.53 KB)
π
test_devpoll.py
(4.5 KB)
π
test_dict.py
(45 KB)
π
test_dict_version.py
(5.88 KB)
π
test_dictcomps.py
(4.42 KB)
π
test_dictviews.py
(11.68 KB)
π
test_difflib.py
(19.64 KB)
π
test_difflib_expect.html
(100.85 KB)
π
test_dis.py
(48.4 KB)
π
test_distutils.py
(375 B)
π
test_doctest.py
(98.67 KB)
π
test_doctest.txt
(300 B)
π
test_doctest2.py
(2.3 KB)
π
test_doctest2.txt
(392 B)
π
test_doctest3.txt
(82 B)
π
test_doctest4.txt
(244 B)
π
test_docxmlrpc.py
(8.67 KB)
π
test_dtrace.py
(5.23 KB)
π
test_dummy_thread.py
(9.69 KB)
π
test_dummy_threading.py
(1.7 KB)
π
test_dynamic.py
(4.29 KB)
π
test_dynamicclassattribute.py
(9.57 KB)
π
test_eintr.py
(1.32 KB)
π
test_email
π
test_embed.py
(49.23 KB)
π
test_ensurepip.py
(9.83 KB)
π
test_enum.py
(113.68 KB)
π
test_enumerate.py
(8.46 KB)
π
test_eof.py
(1.94 KB)
π
test_epoll.py
(9.03 KB)
π
test_errno.py
(1.04 KB)
π
test_exception_hierarchy.py
(7.43 KB)
π
test_exception_variations.py
(3.86 KB)
π
test_exceptions.py
(49.81 KB)
π
test_extcall.py
(13.49 KB)
π
test_faulthandler.py
(28.13 KB)
π
test_fcntl.py
(6.21 KB)
π
test_file.py
(11.02 KB)
π
test_file_eintr.py
(10.6 KB)
π
test_filecmp.py
(8.69 KB)
π
test_fileinput.py
(37.33 KB)
π
test_fileio.py
(19.96 KB)
π
test_finalization.py
(14.66 KB)
π
test_float.py
(63.41 KB)
π
test_flufl.py
(1.32 KB)
π
test_fnmatch.py
(5.07 KB)
π
test_fork1.py
(3.67 KB)
π
test_format.py
(22.58 KB)
π
test_fractions.py
(29.83 KB)
π
test_frame.py
(5.67 KB)
π
test_frozen.py
(943 B)
π
test_fstring.py
(46.16 KB)
π
test_ftplib.py
(39.71 KB)
π
test_funcattrs.py
(13.54 KB)
π
test_functools.py
(90.59 KB)
π
test_future.py
(11.9 KB)
π
test_future3.py
(490 B)
π
test_future4.py
(222 B)
π
test_future5.py
(510 B)
π
test_gc.py
(40.49 KB)
π
test_gdb.py
(40.88 KB)
π
test_generator_stop.py
(943 B)
π
test_generators.py
(58.51 KB)
π
test_genericclass.py
(9.28 KB)
π
test_genericpath.py
(21.7 KB)
π
test_genexps.py
(7.12 KB)
π
test_getargs2.py
(50 KB)
π
test_getopt.py
(6.75 KB)
π
test_getpass.py
(6.29 KB)
π
test_gettext.py
(41.38 KB)
π
test_glob.py
(13.03 KB)
π
test_global.py
(1.31 KB)
π
test_grammar.py
(57.5 KB)
π
test_grp.py
(3.54 KB)
π
test_gzip.py
(29.9 KB)
π
test_hash.py
(11.45 KB)
π
test_hashlib.py
(39.43 KB)
π
test_heapq.py
(16.4 KB)
π
test_hmac.py
(22.24 KB)
π
test_html.py
(4.23 KB)
π
test_htmlparser.py
(33.19 KB)
π
test_http_cookiejar.py
(78.36 KB)
π
test_http_cookies.py
(18.71 KB)
π
test_httplib.py
(76.98 KB)
π
test_httpservers.py
(45.24 KB)
π
test_idle.py
(825 B)
π
test_imaplib.py
(38.95 KB)
π
test_imghdr.py
(4.66 KB)
π
test_imp.py
(17.73 KB)
π
test_import
π
test_importlib
π
test_index.py
(8.37 KB)
π
test_inspect.py
(151.79 KB)
π
test_int.py
(20.8 KB)
π
test_int_literal.py
(6.89 KB)
π
test_io.py
(163.94 KB)
π
test_ioctl.py
(3.2 KB)
π
test_ipaddress.py
(90.98 KB)
π
test_isinstance.py
(10.25 KB)
π
test_iter.py
(31.81 KB)
π
test_iterlen.py
(7.1 KB)
π
test_itertools.py
(101.41 KB)
π
test_json
π
test_keyword.py
(1.23 KB)
π
test_keywordonlyarg.py
(6.85 KB)
π
test_kqueue.py
(8.76 KB)
π
test_largefile.py
(6.83 KB)
π
test_lib2to3.py
(101 B)
π
test_linecache.py
(7.79 KB)
π
test_list.py
(7.4 KB)
π
test_listcomps.py
(3.76 KB)
π
test_lltrace.py
(1012 B)
π
test_locale.py
(23.87 KB)
π
test_logging.py
(182.43 KB)
π
test_long.py
(53.21 KB)
π
test_longexp.py
(233 B)
π
test_lzma.py
(87.92 KB)
π
test_mailbox.py
(91.92 KB)
π
test_mailcap.py
(9.88 KB)
π
test_marshal.py
(20.57 KB)
π
test_math.py
(82.18 KB)
π
test_memoryio.py
(31.48 KB)
π
test_memoryview.py
(17.78 KB)
π
test_metaclass.py
(6.2 KB)
π
test_mimetypes.py
(12.14 KB)
π
test_minidom.py
(66.95 KB)
π
test_mmap.py
(29.04 KB)
π
test_module.py
(10.3 KB)
π
test_modulefinder.py
(12.2 KB)
π
test_msilib.py
(5.06 KB)
π
test_multibytecodec.py
(15.04 KB)
π
test_multiprocessing_fork.py
(477 B)
π
test_multiprocessing_forkserver.py
(392 B)
π
test_multiprocessing_main_handling.py
(11.45 KB)
π
test_multiprocessing_spawn.py
(277 B)
π
test_named_expressions.py
(16.51 KB)
π
test_netrc.py
(5.96 KB)
π
test_nis.py
(1.13 KB)
π
test_nntplib.py
(61.7 KB)
π
test_normalization.py
(3.66 KB)
π
test_ntpath.py
(35.08 KB)
π
test_numeric_tower.py
(7.18 KB)
π
test_opcodes.py
(3.61 KB)
π
test_openpty.py
(600 B)
π
test_operator.py
(23.54 KB)
π
test_optparse.py
(60.99 KB)
π
test_ordered_dict.py
(30.22 KB)
π
test_os.py
(150.53 KB)
π
test_ossaudiodev.py
(7.06 KB)
π
test_osx_env.py
(1.3 KB)
π
test_parser.py
(35.72 KB)
π
test_pathlib.py
(97.12 KB)
π
test_pdb.py
(55.36 KB)
π
test_peepholer.py
(19.41 KB)
π
test_pickle.py
(19.16 KB)
π
test_picklebuffer.py
(4.96 KB)
π
test_pickletools.py
(4.33 KB)
π
test_pipes.py
(6.59 KB)
π
test_pkg.py
(9.59 KB)
π
test_pkgimport.py
(2.67 KB)
π
test_pkgutil.py
(19.25 KB)
π
test_platform.py
(14.31 KB)
π
test_plistlib.py
(41.43 KB)
π
test_poll.py
(7.23 KB)
π
test_popen.py
(1.98 KB)
π
test_poplib.py
(16.97 KB)
π
test_positional_only_arg.py
(17.5 KB)
π
test_posix.py
(75.76 KB)
π
test_posixpath.py
(29.19 KB)
π
test_pow.py
(5.44 KB)
π
test_pprint.py
(43.85 KB)
π
test_print.py
(7.37 KB)
π
test_profile.py
(8.72 KB)
π
test_property.py
(8.77 KB)
π
test_pstats.py
(3.04 KB)
π
test_pty.py
(11.97 KB)
π
test_pulldom.py
(12.66 KB)
π
test_pwd.py
(4.17 KB)
π
test_py_compile.py
(10.78 KB)
π
test_pyclbr.py
(10 KB)
π
test_pydoc.py
(56.98 KB)
π
test_pyexpat.py
(26.54 KB)
π
test_queue.py
(20.36 KB)
π
test_quopri.py
(7.78 KB)
π
test_raise.py
(12.86 KB)
π
test_random.py
(45.59 KB)
π
test_range.py
(23.35 KB)
π
test_re.py
(106.41 KB)
π
test_readline.py
(12.95 KB)
π
test_regrtest.py
(46.36 KB)
π
test_repl.py
(3.96 KB)
π
test_reprlib.py
(15.12 KB)
π
test_resource.py
(7.02 KB)
π
test_richcmp.py
(11.91 KB)
π
test_rlcompleter.py
(6.3 KB)
π
test_robotparser.py
(10.69 KB)
π
test_runpy.py
(33.86 KB)
π
test_sax.py
(46.9 KB)
π
test_sched.py
(6.41 KB)
π
test_scope.py
(19.7 KB)
π
test_script_helper.py
(5.78 KB)
π
test_secrets.py
(4.28 KB)
π
test_select.py
(2.69 KB)
π
test_selectors.py
(17.79 KB)
π
test_set.py
(64.41 KB)
π
test_setcomps.py
(3.7 KB)
π
test_shelve.py
(6.24 KB)
π
test_shlex.py
(13.29 KB)
π
test_shutil.py
(101.55 KB)
π
test_signal.py
(46.62 KB)
π
test_site.py
(24.71 KB)
π
test_slice.py
(8.25 KB)
π
test_smtpd.py
(40.14 KB)
π
test_smtplib.py
(56.51 KB)
π
test_smtpnet.py
(2.87 KB)
π
test_sndhdr.py
(1.43 KB)
π
test_socket.py
(232.71 KB)
π
test_socketserver.py
(17.7 KB)
π
test_sort.py
(13.42 KB)
π
test_source_encoding.py
(7.89 KB)
π
test_spwd.py
(2.71 KB)
π
test_sqlite.py
(948 B)
π
test_ssl.py
(203.3 KB)
π
test_startfile.py
(1.29 KB)
π
test_stat.py
(8.3 KB)
π
test_statistics.py
(106.5 KB)
π
test_strftime.py
(7.54 KB)
π
test_string.py
(19.8 KB)
π
test_string_literals.py
(9.88 KB)
π
test_stringprep.py
(3.04 KB)
π
test_strptime.py
(34.42 KB)
π
test_strtod.py
(20.06 KB)
π
test_struct.py
(34.41 KB)
π
test_structmembers.py
(4.7 KB)
π
test_structseq.py
(3.87 KB)
π
test_subclassinit.py
(8.12 KB)
π
test_subprocess.py
(142.64 KB)
π
test_sunau.py
(6.07 KB)
π
test_sundry.py
(2.07 KB)
π
test_super.py
(9.6 KB)
π
test_support.py
(24.12 KB)
π
test_symbol.py
(2.06 KB)
π
test_symtable.py
(9.13 KB)
π
test_syntax.py
(25.75 KB)
π
test_sys.py
(55.24 KB)
π
test_sys_setprofile.py
(12.31 KB)
π
test_sys_settrace.py
(43.08 KB)
π
test_sysconfig.py
(17.01 KB)
π
test_syslog.py
(1.15 KB)
π
test_tabnanny.py
(13.44 KB)
π
test_tarfile.py
(98.31 KB)
π
test_tcl.py
(30.74 KB)
π
test_telnetlib.py
(12.7 KB)
π
test_tempfile.py
(52.57 KB)
π
test_textwrap.py
(38.84 KB)
π
test_thread.py
(8.41 KB)
π
test_threaded_import.py
(8.9 KB)
π
test_threadedtempfile.py
(1.85 KB)
π
test_threading.py
(47.52 KB)
π
test_threading_local.py
(6.09 KB)
π
test_threadsignals.py
(10.09 KB)
π
test_time.py
(38.43 KB)
π
test_timeit.py
(14.8 KB)
π
test_timeout.py
(11.19 KB)
π
test_tix.py
(756 B)
π
test_tk.py
(362 B)
π
test_tokenize.py
(63.18 KB)
π
test_tools
π
test_trace.py
(19.89 KB)
π
test_traceback.py
(46.97 KB)
π
test_tracemalloc.py
(37.41 KB)
π
test_ttk_guionly.py
(746 B)
π
test_ttk_textonly.py
(299 B)
π
test_tuple.py
(18.85 KB)
π
test_turtle.py
(12.79 KB)
π
test_type_comments.py
(10.13 KB)
π
test_typechecks.py
(2.55 KB)
π
test_types.py
(58 KB)
π
test_typing.py
(122.05 KB)
π
test_ucn.py
(9.35 KB)
π
test_unary.py
(1.63 KB)
π
test_unicode.py
(129.94 KB)
π
test_unicode_file.py
(5.74 KB)
π
test_unicode_file_functions.py
(6.84 KB)
π
test_unicode_identifiers.py
(891 B)
π
test_unicodedata.py
(12.7 KB)
π
test_unittest.py
(286 B)
π
test_univnewlines.py
(3.83 KB)
π
test_unpack.py
(3.01 KB)
π
test_unpack_ex.py
(8.73 KB)
π
test_urllib.py
(71.24 KB)
π
test_urllib2.py
(76.95 KB)
π
test_urllib2_localnet.py
(24.24 KB)
π
test_urllib2net.py
(12.39 KB)
π
test_urllib_response.py
(1.69 KB)
π
test_urllibnet.py
(8.9 KB)
π
test_urlparse.py
(64.87 KB)
π
test_userdict.py
(7.64 KB)
π
test_userlist.py
(1.97 KB)
π
test_userstring.py
(2.4 KB)
π
test_utf8_mode.py
(9.22 KB)
π
test_utf8source.py
(1.15 KB)
π
test_uu.py
(8.02 KB)
π
test_uuid.py
(35.74 KB)
π
test_venv.py
(20.46 KB)
π
test_wait3.py
(1.16 KB)
π
test_wait4.py
(1.15 KB)
π
test_warnings
π
test_wave.py
(6.57 KB)
π
test_weakref.py
(69.47 KB)
π
test_weakset.py
(15.03 KB)
π
test_webbrowser.py
(10.47 KB)
π
test_winconsoleio.py
(6.14 KB)
π
test_winreg.py
(21.38 KB)
π
test_winsound.py
(4.57 KB)
π
test_with.py
(25.78 KB)
π
test_wsgiref.py
(30.1 KB)
π
test_xdrlib.py
(2.17 KB)
π
test_xml_dom_minicompat.py
(4.18 KB)
π
test_xml_etree.py
(147.87 KB)
π
test_xml_etree_c.py
(8.06 KB)
π
test_xmlrpc.py
(55.96 KB)
π
test_xmlrpc_net.py
(1015 B)
π
test_xxtestfuzz.py
(670 B)
π
test_yield_from.py
(30.01 KB)
π
test_zipapp.py
(15.92 KB)
π
test_zipfile.py
(115.45 KB)
π
test_zipfile64.py
(5.8 KB)
π
test_zipimport.py
(29.28 KB)
π
test_zipimport_support.py
(10.44 KB)
π
test_zlib.py
(34.48 KB)
π
testcodec.py
(1.02 KB)
π
testtar.tar
(425 KB)
π
tf_inherit_check.py
(714 B)
π
threaded_import_hangers.py
(1.45 KB)
π
time_hashlib.py
(2.87 KB)
π
tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt
(443 B)
π
tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt
(302 B)
π
tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt
(421 B)
π
tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt
(326 B)
π
tokenize_tests.txt
(2.65 KB)
π
tracedmodules
π
win_console_handler.py
(1.38 KB)
π
xmltestdata
π
xmltests.py
(499 B)
π
zip_cp437_header.zip
(270 B)
π
zipdir.zip
(374 B)
π
ziptestdata
Editing: test_imaplib.py
from test import support from contextlib import contextmanager import imaplib import os.path import socketserver import time import calendar import threading import socket from test.support import (reap_threads, verbose, transient_internet, run_with_tz, run_with_locale, cpython_only, requires_hashdigest) import unittest from unittest import mock from datetime import datetime, timezone, timedelta try: import ssl except ImportError: ssl = None CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem") CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem") class TestImaplib(unittest.TestCase): def test_Internaldate2tuple(self): t0 = calendar.timegm((2000, 1, 1, 0, 0, 0, -1, -1, -1)) tt = imaplib.Internaldate2tuple( b'25 (INTERNALDATE "01-Jan-2000 00:00:00 +0000")') self.assertEqual(time.mktime(tt), t0) tt = imaplib.Internaldate2tuple( b'25 (INTERNALDATE "01-Jan-2000 11:30:00 +1130")') self.assertEqual(time.mktime(tt), t0) tt = imaplib.Internaldate2tuple( b'25 (INTERNALDATE "31-Dec-1999 12:30:00 -1130")') self.assertEqual(time.mktime(tt), t0) @run_with_tz('MST+07MDT,M4.1.0,M10.5.0') def test_Internaldate2tuple_issue10941(self): self.assertNotEqual(imaplib.Internaldate2tuple( b'25 (INTERNALDATE "02-Apr-2000 02:30:00 +0000")'), imaplib.Internaldate2tuple( b'25 (INTERNALDATE "02-Apr-2000 03:30:00 +0000")')) def timevalues(self): return [2000000000, 2000000000.0, time.localtime(2000000000), (2033, 5, 18, 5, 33, 20, -1, -1, -1), (2033, 5, 18, 5, 33, 20, -1, -1, 1), datetime.fromtimestamp(2000000000, timezone(timedelta(0, 2 * 60 * 60))), '"18-May-2033 05:33:20 +0200"'] @run_with_locale('LC_ALL', 'de_DE', 'fr_FR') # DST rules included to work around quirk where the Gnu C library may not # otherwise restore the previous time zone @run_with_tz('STD-1DST,M3.2.0,M11.1.0') def test_Time2Internaldate(self): expected = '"18-May-2033 05:33:20 +0200"' for t in self.timevalues(): internal = imaplib.Time2Internaldate(t) self.assertEqual(internal, expected) def test_that_Time2Internaldate_returns_a_result(self): # Without tzset, we can check only that it successfully # produces a result, not the correctness of the result itself, # since the result depends on the timezone the machine is in. for t in self.timevalues(): imaplib.Time2Internaldate(t) def test_imap4_host_default_value(self): # Check whether the IMAP4_PORT is truly unavailable. with socket.socket() as s: try: s.connect(('', imaplib.IMAP4_PORT)) self.skipTest( "Cannot run the test with local IMAP server running.") except socket.error: pass # This is the exception that should be raised. expected_errnos = support.get_socket_conn_refused_errs() with self.assertRaises(OSError) as cm: imaplib.IMAP4() self.assertIn(cm.exception.errno, expected_errnos) if ssl: class SecureTCPServer(socketserver.TCPServer): def get_request(self): newsocket, fromaddr = self.socket.accept() context = ssl.SSLContext() context.load_cert_chain(CERTFILE) connstream = context.wrap_socket(newsocket, server_side=True) return connstream, fromaddr IMAP4_SSL = imaplib.IMAP4_SSL else: class SecureTCPServer: pass IMAP4_SSL = None class SimpleIMAPHandler(socketserver.StreamRequestHandler): timeout = 1 continuation = None capabilities = '' def setup(self): super().setup() self.server.logged = None def _send(self, message): if verbose: print("SENT: %r" % message.strip()) self.wfile.write(message) def _send_line(self, message): self._send(message + b'\r\n') def _send_textline(self, message): self._send_line(message.encode('ASCII')) def _send_tagged(self, tag, code, message): self._send_textline(' '.join((tag, code, message))) def handle(self): # Send a welcome message. self._send_textline('* OK IMAP4rev1') while 1: # Gather up input until we receive a line terminator or we timeout. # Accumulate read(1) because it's simpler to handle the differences # between naked sockets and SSL sockets. line = b'' while 1: try: part = self.rfile.read(1) if part == b'': # Naked sockets return empty strings.. return line += part except OSError: # ..but SSLSockets raise exceptions. return if line.endswith(b'\r\n'): break if verbose: print('GOT: %r' % line.strip()) if self.continuation: try: self.continuation.send(line) except StopIteration: self.continuation = None continue splitline = line.decode('ASCII').split() tag = splitline[0] cmd = splitline[1] args = splitline[2:] if hasattr(self, 'cmd_' + cmd): continuation = getattr(self, 'cmd_' + cmd)(tag, args) if continuation: self.continuation = continuation next(continuation) else: self._send_tagged(tag, 'BAD', cmd + ' unknown') def cmd_CAPABILITY(self, tag, args): caps = ('IMAP4rev1 ' + self.capabilities if self.capabilities else 'IMAP4rev1') self._send_textline('* CAPABILITY ' + caps) self._send_tagged(tag, 'OK', 'CAPABILITY completed') def cmd_LOGOUT(self, tag, args): self.server.logged = None self._send_textline('* BYE IMAP4ref1 Server logging out') self._send_tagged(tag, 'OK', 'LOGOUT completed') def cmd_LOGIN(self, tag, args): self.server.logged = args[0] self._send_tagged(tag, 'OK', 'LOGIN completed') class NewIMAPTestsMixin(): client = None def _setup(self, imap_handler, connect=True): """ Sets up imap_handler for tests. imap_handler should inherit from either: - SimpleIMAPHandler - for testing IMAP commands, - socketserver.StreamRequestHandler - if raw access to stream is needed. Returns (client, server). """ class TestTCPServer(self.server_class): def handle_error(self, request, client_address): """ End request and raise the error if one occurs. """ self.close_request(request) self.server_close() raise self.addCleanup(self._cleanup) self.server = self.server_class((support.HOST, 0), imap_handler) self.thread = threading.Thread( name=self._testMethodName+'-server', target=self.server.serve_forever, # Short poll interval to make the test finish quickly. # Time between requests is short enough that we won't wake # up spuriously too many times. kwargs={'poll_interval': 0.01}) self.thread.daemon = True # In case this function raises. self.thread.start() if connect: self.client = self.imap_class(*self.server.server_address) return self.client, self.server def _cleanup(self): """ Cleans up the test server. This method should not be called manually, it is added to the cleanup queue in the _setup method already. """ # if logout was called already we'd raise an exception trying to # shutdown the client once again if self.client is not None and self.client.state != 'LOGOUT': self.client.shutdown() # cleanup the server self.server.shutdown() self.server.server_close() support.join_thread(self.thread, 3.0) # Explicitly clear the attribute to prevent dangling thread self.thread = None def test_EOF_without_complete_welcome_message(self): # http://bugs.python.org/issue5949 class EOFHandler(socketserver.StreamRequestHandler): def handle(self): self.wfile.write(b'* OK') _, server = self._setup(EOFHandler, connect=False) self.assertRaises(imaplib.IMAP4.abort, self.imap_class, *server.server_address) def test_line_termination(self): class BadNewlineHandler(SimpleIMAPHandler): def cmd_CAPABILITY(self, tag, args): self._send(b'* CAPABILITY IMAP4rev1 AUTH\n') self._send_tagged(tag, 'OK', 'CAPABILITY completed') _, server = self._setup(BadNewlineHandler, connect=False) self.assertRaises(imaplib.IMAP4.abort, self.imap_class, *server.server_address) def test_enable_raises_error_if_not_AUTH(self): class EnableHandler(SimpleIMAPHandler): capabilities = 'AUTH ENABLE UTF8=ACCEPT' client, _ = self._setup(EnableHandler) self.assertFalse(client.utf8_enabled) with self.assertRaisesRegex(imaplib.IMAP4.error, 'ENABLE.*NONAUTH'): client.enable('foo') self.assertFalse(client.utf8_enabled) def test_enable_raises_error_if_no_capability(self): client, _ = self._setup(SimpleIMAPHandler) with self.assertRaisesRegex(imaplib.IMAP4.error, 'does not support ENABLE'): client.enable('foo') def test_enable_UTF8_raises_error_if_not_supported(self): client, _ = self._setup(SimpleIMAPHandler) typ, data = client.login('user', 'pass') self.assertEqual(typ, 'OK') with self.assertRaisesRegex(imaplib.IMAP4.error, 'does not support ENABLE'): client.enable('UTF8=ACCEPT') def test_enable_UTF8_True_append(self): class UTF8AppendServer(SimpleIMAPHandler): capabilities = 'ENABLE UTF8=ACCEPT' def cmd_ENABLE(self, tag, args): self._send_tagged(tag, 'OK', 'ENABLE successful') def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'FAKEAUTH successful') def cmd_APPEND(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'okay') client, server = self._setup(UTF8AppendServer) self.assertEqual(client._encoding, 'ascii') code, _ = client.authenticate('MYAUTH', lambda x: b'fake') self.assertEqual(code, 'OK') self.assertEqual(server.response, b'ZmFrZQ==\r\n') # b64 encoded 'fake' code, _ = client.enable('UTF8=ACCEPT') self.assertEqual(code, 'OK') self.assertEqual(client._encoding, 'utf-8') msg_string = 'Subject: ΓΌΓ±Γ©âðé' typ, data = client.append(None, None, None, msg_string.encode('utf-8')) self.assertEqual(typ, 'OK') self.assertEqual(server.response, ('UTF8 (%s)\r\n' % msg_string).encode('utf-8')) def test_search_disallows_charset_in_utf8_mode(self): class UTF8Server(SimpleIMAPHandler): capabilities = 'AUTH ENABLE UTF8=ACCEPT' def cmd_ENABLE(self, tag, args): self._send_tagged(tag, 'OK', 'ENABLE successful') def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'FAKEAUTH successful') client, _ = self._setup(UTF8Server) typ, _ = client.authenticate('MYAUTH', lambda x: b'fake') self.assertEqual(typ, 'OK') typ, _ = client.enable('UTF8=ACCEPT') self.assertEqual(typ, 'OK') self.assertTrue(client.utf8_enabled) with self.assertRaisesRegex(imaplib.IMAP4.error, 'charset.*UTF8'): client.search('foo', 'bar') def test_bad_auth_name(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_tagged(tag, 'NO', 'unrecognized authentication type {}'.format(args[0])) client, _ = self._setup(MyServer) with self.assertRaisesRegex(imaplib.IMAP4.error, 'unrecognized authentication type METHOD'): client.authenticate('METHOD', lambda: 1) def test_invalid_authentication(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.response = yield self._send_tagged(tag, 'NO', '[AUTHENTICATIONFAILED] invalid') client, _ = self._setup(MyServer) with self.assertRaisesRegex(imaplib.IMAP4.error, r'\[AUTHENTICATIONFAILED\] invalid'): client.authenticate('MYAUTH', lambda x: b'fake') def test_valid_authentication_bytes(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'FAKEAUTH successful') client, server = self._setup(MyServer) code, _ = client.authenticate('MYAUTH', lambda x: b'fake') self.assertEqual(code, 'OK') self.assertEqual(server.response, b'ZmFrZQ==\r\n') # b64 encoded 'fake' def test_valid_authentication_plain_text(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'FAKEAUTH successful') client, server = self._setup(MyServer) code, _ = client.authenticate('MYAUTH', lambda x: 'fake') self.assertEqual(code, 'OK') self.assertEqual(server.response, b'ZmFrZQ==\r\n') # b64 encoded 'fake' @requires_hashdigest('md5') def test_login_cram_md5_bytes(self): class AuthHandler(SimpleIMAPHandler): capabilities = 'LOGINDISABLED AUTH=CRAM-MD5' def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+ PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2Uucm' 'VzdG9uLm1jaS5uZXQ=') r = yield if (r == b'dGltIGYxY2E2YmU0NjRiOWVmYT' b'FjY2E2ZmZkNmNmMmQ5ZjMy\r\n'): self._send_tagged(tag, 'OK', 'CRAM-MD5 successful') else: self._send_tagged(tag, 'NO', 'No access') client, _ = self._setup(AuthHandler) self.assertTrue('AUTH=CRAM-MD5' in client.capabilities) ret, _ = client.login_cram_md5("tim", b"tanstaaftanstaaf") self.assertEqual(ret, "OK") @requires_hashdigest('md5') def test_login_cram_md5_plain_text(self): class AuthHandler(SimpleIMAPHandler): capabilities = 'LOGINDISABLED AUTH=CRAM-MD5' def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+ PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2Uucm' 'VzdG9uLm1jaS5uZXQ=') r = yield if (r == b'dGltIGYxY2E2YmU0NjRiOWVmYT' b'FjY2E2ZmZkNmNmMmQ5ZjMy\r\n'): self._send_tagged(tag, 'OK', 'CRAM-MD5 successful') else: self._send_tagged(tag, 'NO', 'No access') client, _ = self._setup(AuthHandler) self.assertTrue('AUTH=CRAM-MD5' in client.capabilities) ret, _ = client.login_cram_md5("tim", "tanstaaftanstaaf") self.assertEqual(ret, "OK") def test_aborted_authentication(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.response = yield if self.response == b'*\r\n': self._send_tagged( tag, 'NO', '[AUTHENTICATIONFAILED] aborted') else: self._send_tagged(tag, 'OK', 'MYAUTH successful') client, _ = self._setup(MyServer) with self.assertRaisesRegex(imaplib.IMAP4.error, r'\[AUTHENTICATIONFAILED\] aborted'): client.authenticate('MYAUTH', lambda x: None) @mock.patch('imaplib._MAXLINE', 10) def test_linetoolong(self): class TooLongHandler(SimpleIMAPHandler): def handle(self): # send response line longer than the limit set in the next line self.wfile.write(b'* OK ' + 11 * b'x' + b'\r\n') _, server = self._setup(TooLongHandler, connect=False) with self.assertRaisesRegex(imaplib.IMAP4.error, 'got more than 10 bytes'): self.imap_class(*server.server_address) def test_simple_with_statement(self): _, server = self._setup(SimpleIMAPHandler, connect=False) with self.imap_class(*server.server_address): pass def test_with_statement(self): _, server = self._setup(SimpleIMAPHandler, connect=False) with self.imap_class(*server.server_address) as imap: imap.login('user', 'pass') self.assertEqual(server.logged, 'user') self.assertIsNone(server.logged) def test_with_statement_logout(self): # It is legal to log out explicitly inside the with block _, server = self._setup(SimpleIMAPHandler, connect=False) with self.imap_class(*server.server_address) as imap: imap.login('user', 'pass') self.assertEqual(server.logged, 'user') imap.logout() self.assertIsNone(server.logged) self.assertIsNone(server.logged) # command tests def test_login(self): client, _ = self._setup(SimpleIMAPHandler) typ, data = client.login('user', 'pass') self.assertEqual(typ, 'OK') self.assertEqual(data[0], b'LOGIN completed') self.assertEqual(client.state, 'AUTH') def test_logout(self): client, _ = self._setup(SimpleIMAPHandler) typ, data = client.login('user', 'pass') self.assertEqual(typ, 'OK') self.assertEqual(data[0], b'LOGIN completed') typ, data = client.logout() self.assertEqual(typ, 'BYE', (typ, data)) self.assertEqual(data[0], b'IMAP4ref1 Server logging out', (typ, data)) self.assertEqual(client.state, 'LOGOUT') def test_lsub(self): class LsubCmd(SimpleIMAPHandler): def cmd_LSUB(self, tag, args): self._send_textline('* LSUB () "." directoryA') return self._send_tagged(tag, 'OK', 'LSUB completed') client, _ = self._setup(LsubCmd) client.login('user', 'pass') typ, data = client.lsub() self.assertEqual(typ, 'OK') self.assertEqual(data[0], b'() "." directoryA') class NewIMAPTests(NewIMAPTestsMixin, unittest.TestCase): imap_class = imaplib.IMAP4 server_class = socketserver.TCPServer @unittest.skipUnless(ssl, "SSL not available") class NewIMAPSSLTests(NewIMAPTestsMixin, unittest.TestCase): imap_class = IMAP4_SSL server_class = SecureTCPServer def test_ssl_raises(self): ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) self.assertEqual(ssl_context.verify_mode, ssl.CERT_REQUIRED) self.assertEqual(ssl_context.check_hostname, True) ssl_context.load_verify_locations(CAFILE) with self.assertRaisesRegex(ssl.CertificateError, "IP address mismatch, certificate is not valid for " "'127.0.0.1'"): _, server = self._setup(SimpleIMAPHandler) client = self.imap_class(*server.server_address, ssl_context=ssl_context) client.shutdown() def test_ssl_verified(self): ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ssl_context.load_verify_locations(CAFILE) _, server = self._setup(SimpleIMAPHandler) client = self.imap_class("localhost", server.server_address[1], ssl_context=ssl_context) client.shutdown() # Mock the private method _connect(), so mark the test as specific # to CPython stdlib @cpython_only def test_certfile_arg_warn(self): with support.check_warnings(('', DeprecationWarning)): with mock.patch.object(self.imap_class, 'open'): with mock.patch.object(self.imap_class, '_connect'): self.imap_class('localhost', 143, certfile=CERTFILE) class ThreadedNetworkedTests(unittest.TestCase): server_class = socketserver.TCPServer imap_class = imaplib.IMAP4 def make_server(self, addr, hdlr): class MyServer(self.server_class): def handle_error(self, request, client_address): self.close_request(request) self.server_close() raise if verbose: print("creating server") server = MyServer(addr, hdlr) self.assertEqual(server.server_address, server.socket.getsockname()) if verbose: print("server created") print("ADDR =", addr) print("CLASS =", self.server_class) print("HDLR =", server.RequestHandlerClass) t = threading.Thread( name='%s serving' % self.server_class, target=server.serve_forever, # Short poll interval to make the test finish quickly. # Time between requests is short enough that we won't wake # up spuriously too many times. kwargs={'poll_interval': 0.01}) t.daemon = True # In case this function raises. t.start() if verbose: print("server running") return server, t def reap_server(self, server, thread): if verbose: print("waiting for server") server.shutdown() server.server_close() thread.join() if verbose: print("done") @contextmanager def reaped_server(self, hdlr): server, thread = self.make_server((support.HOST, 0), hdlr) try: yield server finally: self.reap_server(server, thread) @contextmanager def reaped_pair(self, hdlr): with self.reaped_server(hdlr) as server: client = self.imap_class(*server.server_address) try: yield server, client finally: client.logout() @reap_threads def test_connect(self): with self.reaped_server(SimpleIMAPHandler) as server: client = self.imap_class(*server.server_address) client.shutdown() @reap_threads def test_bracket_flags(self): # This violates RFC 3501, which disallows ']' characters in tag names, # but imaplib has allowed producing such tags forever, other programs # also produce them (eg: OtherInbox's Organizer app as of 20140716), # and Gmail, for example, accepts them and produces them. So we # support them. See issue #21815. class BracketFlagHandler(SimpleIMAPHandler): def handle(self): self.flags = ['Answered', 'Flagged', 'Deleted', 'Seen', 'Draft'] super().handle() def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'FAKEAUTH successful') def cmd_SELECT(self, tag, args): flag_msg = ' \\'.join(self.flags) self._send_line(('* FLAGS (%s)' % flag_msg).encode('ascii')) self._send_line(b'* 2 EXISTS') self._send_line(b'* 0 RECENT') msg = ('* OK [PERMANENTFLAGS %s \\*)] Flags permitted.' % flag_msg) self._send_line(msg.encode('ascii')) self._send_tagged(tag, 'OK', '[READ-WRITE] SELECT completed.') def cmd_STORE(self, tag, args): new_flags = args[2].strip('(').strip(')').split() self.flags.extend(new_flags) flags_msg = '(FLAGS (%s))' % ' \\'.join(self.flags) msg = '* %s FETCH %s' % (args[0], flags_msg) self._send_line(msg.encode('ascii')) self._send_tagged(tag, 'OK', 'STORE completed.') with self.reaped_pair(BracketFlagHandler) as (server, client): code, data = client.authenticate('MYAUTH', lambda x: b'fake') self.assertEqual(code, 'OK') self.assertEqual(server.response, b'ZmFrZQ==\r\n') client.select('test') typ, [data] = client.store(b'1', "+FLAGS", "[test]") self.assertIn(b'[test]', data) client.select('test') typ, [data] = client.response('PERMANENTFLAGS') self.assertIn(b'[test]', data) @reap_threads def test_issue5949(self): class EOFHandler(socketserver.StreamRequestHandler): def handle(self): # EOF without sending a complete welcome message. self.wfile.write(b'* OK') with self.reaped_server(EOFHandler) as server: self.assertRaises(imaplib.IMAP4.abort, self.imap_class, *server.server_address) @reap_threads def test_line_termination(self): class BadNewlineHandler(SimpleIMAPHandler): def cmd_CAPABILITY(self, tag, args): self._send(b'* CAPABILITY IMAP4rev1 AUTH\n') self._send_tagged(tag, 'OK', 'CAPABILITY completed') with self.reaped_server(BadNewlineHandler) as server: self.assertRaises(imaplib.IMAP4.abort, self.imap_class, *server.server_address) class UTF8Server(SimpleIMAPHandler): capabilities = 'AUTH ENABLE UTF8=ACCEPT' def cmd_ENABLE(self, tag, args): self._send_tagged(tag, 'OK', 'ENABLE successful') def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'FAKEAUTH successful') @reap_threads def test_enable_raises_error_if_not_AUTH(self): with self.reaped_pair(self.UTF8Server) as (server, client): self.assertFalse(client.utf8_enabled) self.assertRaises(imaplib.IMAP4.error, client.enable, 'foo') self.assertFalse(client.utf8_enabled) # XXX Also need a test that enable after SELECT raises an error. @reap_threads def test_enable_raises_error_if_no_capability(self): class NoEnableServer(self.UTF8Server): capabilities = 'AUTH' with self.reaped_pair(NoEnableServer) as (server, client): self.assertRaises(imaplib.IMAP4.error, client.enable, 'foo') @reap_threads def test_enable_UTF8_raises_error_if_not_supported(self): class NonUTF8Server(SimpleIMAPHandler): pass with self.assertRaises(imaplib.IMAP4.error): with self.reaped_pair(NonUTF8Server) as (server, client): typ, data = client.login('user', 'pass') self.assertEqual(typ, 'OK') client.enable('UTF8=ACCEPT') pass @reap_threads def test_enable_UTF8_True_append(self): class UTF8AppendServer(self.UTF8Server): def cmd_APPEND(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'okay') with self.reaped_pair(UTF8AppendServer) as (server, client): self.assertEqual(client._encoding, 'ascii') code, _ = client.authenticate('MYAUTH', lambda x: b'fake') self.assertEqual(code, 'OK') self.assertEqual(server.response, b'ZmFrZQ==\r\n') # b64 encoded 'fake' code, _ = client.enable('UTF8=ACCEPT') self.assertEqual(code, 'OK') self.assertEqual(client._encoding, 'utf-8') msg_string = 'Subject: ΓΌΓ±Γ©âðé' typ, data = client.append( None, None, None, msg_string.encode('utf-8')) self.assertEqual(typ, 'OK') self.assertEqual( server.response, ('UTF8 (%s)\r\n' % msg_string).encode('utf-8') ) # XXX also need a test that makes sure that the Literal and Untagged_status # regexes uses unicode in UTF8 mode instead of the default ASCII. @reap_threads def test_search_disallows_charset_in_utf8_mode(self): with self.reaped_pair(self.UTF8Server) as (server, client): typ, _ = client.authenticate('MYAUTH', lambda x: b'fake') self.assertEqual(typ, 'OK') typ, _ = client.enable('UTF8=ACCEPT') self.assertEqual(typ, 'OK') self.assertTrue(client.utf8_enabled) self.assertRaises(imaplib.IMAP4.error, client.search, 'foo', 'bar') @reap_threads def test_bad_auth_name(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_tagged(tag, 'NO', 'unrecognized authentication ' 'type {}'.format(args[0])) with self.reaped_pair(MyServer) as (server, client): with self.assertRaises(imaplib.IMAP4.error): client.authenticate('METHOD', lambda: 1) @reap_threads def test_invalid_authentication(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.response = yield self._send_tagged(tag, 'NO', '[AUTHENTICATIONFAILED] invalid') with self.reaped_pair(MyServer) as (server, client): with self.assertRaises(imaplib.IMAP4.error): code, data = client.authenticate('MYAUTH', lambda x: b'fake') @reap_threads def test_valid_authentication(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.server.response = yield self._send_tagged(tag, 'OK', 'FAKEAUTH successful') with self.reaped_pair(MyServer) as (server, client): code, data = client.authenticate('MYAUTH', lambda x: b'fake') self.assertEqual(code, 'OK') self.assertEqual(server.response, b'ZmFrZQ==\r\n') # b64 encoded 'fake' with self.reaped_pair(MyServer) as (server, client): code, data = client.authenticate('MYAUTH', lambda x: 'fake') self.assertEqual(code, 'OK') self.assertEqual(server.response, b'ZmFrZQ==\r\n') # b64 encoded 'fake' @reap_threads @requires_hashdigest('md5') def test_login_cram_md5(self): class AuthHandler(SimpleIMAPHandler): capabilities = 'LOGINDISABLED AUTH=CRAM-MD5' def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+ PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2Uucm' 'VzdG9uLm1jaS5uZXQ=') r = yield if (r == b'dGltIGYxY2E2YmU0NjRiOWVmYT' b'FjY2E2ZmZkNmNmMmQ5ZjMy\r\n'): self._send_tagged(tag, 'OK', 'CRAM-MD5 successful') else: self._send_tagged(tag, 'NO', 'No access') with self.reaped_pair(AuthHandler) as (server, client): self.assertTrue('AUTH=CRAM-MD5' in client.capabilities) ret, data = client.login_cram_md5("tim", "tanstaaftanstaaf") self.assertEqual(ret, "OK") with self.reaped_pair(AuthHandler) as (server, client): self.assertTrue('AUTH=CRAM-MD5' in client.capabilities) ret, data = client.login_cram_md5("tim", b"tanstaaftanstaaf") self.assertEqual(ret, "OK") @reap_threads def test_aborted_authentication(self): class MyServer(SimpleIMAPHandler): def cmd_AUTHENTICATE(self, tag, args): self._send_textline('+') self.response = yield if self.response == b'*\r\n': self._send_tagged(tag, 'NO', '[AUTHENTICATIONFAILED] aborted') else: self._send_tagged(tag, 'OK', 'MYAUTH successful') with self.reaped_pair(MyServer) as (server, client): with self.assertRaises(imaplib.IMAP4.error): code, data = client.authenticate('MYAUTH', lambda x: None) def test_linetoolong(self): class TooLongHandler(SimpleIMAPHandler): def handle(self): # Send a very long response line self.wfile.write(b'* OK ' + imaplib._MAXLINE * b'x' + b'\r\n') with self.reaped_server(TooLongHandler) as server: self.assertRaises(imaplib.IMAP4.error, self.imap_class, *server.server_address) @reap_threads def test_simple_with_statement(self): # simplest call with self.reaped_server(SimpleIMAPHandler) as server: with self.imap_class(*server.server_address): pass @reap_threads def test_with_statement(self): with self.reaped_server(SimpleIMAPHandler) as server: with self.imap_class(*server.server_address) as imap: imap.login('user', 'pass') self.assertEqual(server.logged, 'user') self.assertIsNone(server.logged) @reap_threads def test_with_statement_logout(self): # what happens if already logout in the block? with self.reaped_server(SimpleIMAPHandler) as server: with self.imap_class(*server.server_address) as imap: imap.login('user', 'pass') self.assertEqual(server.logged, 'user') imap.logout() self.assertIsNone(server.logged) self.assertIsNone(server.logged) @unittest.skipUnless(ssl, "SSL not available") class ThreadedNetworkedTestsSSL(ThreadedNetworkedTests): server_class = SecureTCPServer imap_class = IMAP4_SSL @reap_threads def test_ssl_verified(self): ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ssl_context.load_verify_locations(CAFILE) with self.assertRaisesRegex( ssl.CertificateError, "IP address mismatch, certificate is not valid for " "'127.0.0.1'"): with self.reaped_server(SimpleIMAPHandler) as server: client = self.imap_class(*server.server_address, ssl_context=ssl_context) client.shutdown() with self.reaped_server(SimpleIMAPHandler) as server: client = self.imap_class("localhost", server.server_address[1], ssl_context=ssl_context) client.shutdown() @unittest.skipUnless( support.is_resource_enabled('network'), 'network resource disabled') @unittest.skip('cyrus.andrew.cmu.edu blocks connections') class RemoteIMAPTest(unittest.TestCase): host = 'cyrus.andrew.cmu.edu' port = 143 username = 'anonymous' password = 'pass' imap_class = imaplib.IMAP4 def setUp(self): with transient_internet(self.host): self.server = self.imap_class(self.host, self.port) def tearDown(self): if self.server is not None: with transient_internet(self.host): self.server.logout() def test_logincapa(self): with transient_internet(self.host): for cap in self.server.capabilities: self.assertIsInstance(cap, str) self.assertIn('LOGINDISABLED', self.server.capabilities) self.assertIn('AUTH=ANONYMOUS', self.server.capabilities) rs = self.server.login(self.username, self.password) self.assertEqual(rs[0], 'OK') def test_logout(self): with transient_internet(self.host): rs = self.server.logout() self.server = None self.assertEqual(rs[0], 'BYE', rs) @unittest.skipUnless(ssl, "SSL not available") @unittest.skipUnless( support.is_resource_enabled('network'), 'network resource disabled') @unittest.skip('cyrus.andrew.cmu.edu blocks connections') class RemoteIMAP_STARTTLSTest(RemoteIMAPTest): def setUp(self): super().setUp() with transient_internet(self.host): rs = self.server.starttls() self.assertEqual(rs[0], 'OK') def test_logincapa(self): for cap in self.server.capabilities: self.assertIsInstance(cap, str) self.assertNotIn('LOGINDISABLED', self.server.capabilities) @unittest.skipUnless(ssl, "SSL not available") @unittest.skip('cyrus.andrew.cmu.edu blocks connections') class RemoteIMAP_SSLTest(RemoteIMAPTest): port = 993 imap_class = IMAP4_SSL def setUp(self): pass def tearDown(self): pass def create_ssl_context(self): ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE ssl_context.load_cert_chain(CERTFILE) return ssl_context def check_logincapa(self, server): try: for cap in server.capabilities: self.assertIsInstance(cap, str) self.assertNotIn('LOGINDISABLED', server.capabilities) self.assertIn('AUTH=PLAIN', server.capabilities) rs = server.login(self.username, self.password) self.assertEqual(rs[0], 'OK') finally: server.logout() def test_logincapa(self): with transient_internet(self.host): _server = self.imap_class(self.host, self.port) self.check_logincapa(_server) def test_logout(self): with transient_internet(self.host): _server = self.imap_class(self.host, self.port) rs = _server.logout() self.assertEqual(rs[0], 'BYE', rs) def test_ssl_context_certfile_exclusive(self): with transient_internet(self.host): self.assertRaises( ValueError, self.imap_class, self.host, self.port, certfile=CERTFILE, ssl_context=self.create_ssl_context()) def test_ssl_context_keyfile_exclusive(self): with transient_internet(self.host): self.assertRaises( ValueError, self.imap_class, self.host, self.port, keyfile=CERTFILE, ssl_context=self.create_ssl_context()) if __name__ == "__main__": unittest.main()
Upload File
Create Folder