Linux ip-172-26-2-223 5.4.0-1018-aws #18-Ubuntu SMP Wed Jun 24 01:15:00 UTC 2020 x86_64
Apache
: 172.26.2.223 | : 18.222.30.59
Cant Read [ /etc/named.conf ]
8.1.13
www
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
www /
server /
panel /
pyenv /
lib /
python3.12 /
test /
[ HOME SHELL ]
Name
Size
Permission
Action
audiodata
[ DIR ]
drwxr-xr-x
certdata
[ DIR ]
drwxr-xr-x
cjkencodings
[ DIR ]
drwxr-xr-x
configdata
[ DIR ]
drwxr-xr-x
crashers
[ DIR ]
drwxr-xr-x
data
[ DIR ]
drwxr-xr-x
decimaltestdata
[ DIR ]
drwxr-xr-x
dtracedata
[ DIR ]
drwxr-xr-x
encoded_modules
[ DIR ]
drwxr-xr-x
imghdrdata
[ DIR ]
drwxr-xr-x
leakers
[ DIR ]
drwxr-xr-x
libregrtest
[ DIR ]
drwxr-xr-x
regrtestdata
[ DIR ]
drwxr-xr-x
sndhdrdata
[ DIR ]
drwxr-xr-x
subprocessdata
[ DIR ]
drwxr-xr-x
support
[ DIR ]
drwxr-xr-x
test_asyncio
[ DIR ]
drwxr-xr-x
test_capi
[ DIR ]
drwxr-xr-x
test_concurrent_futures
[ DIR ]
drwxr-xr-x
test_cppext
[ DIR ]
drwxr-xr-x
test_ctypes
[ DIR ]
drwxr-xr-x
test_dataclasses
[ DIR ]
drwxr-xr-x
test_doctest
[ DIR ]
drwxr-xr-x
test_email
[ DIR ]
drwxr-xr-x
test_future_stmt
[ DIR ]
drwxr-xr-x
test_gdb
[ DIR ]
drwxr-xr-x
test_import
[ DIR ]
drwxr-xr-x
test_importlib
[ DIR ]
drwxr-xr-x
test_inspect
[ DIR ]
drwxr-xr-x
test_json
[ DIR ]
drwxr-xr-x
test_lib2to3
[ DIR ]
drwxr-xr-x
test_module
[ DIR ]
drwxr-xr-x
test_multiprocessing_fork
[ DIR ]
drwxr-xr-x
test_multiprocessing_forkserve...
[ DIR ]
drwxr-xr-x
test_multiprocessing_spawn
[ DIR ]
drwxr-xr-x
test_peg_generator
[ DIR ]
drwxr-xr-x
test_pydoc
[ DIR ]
drwxr-xr-x
test_sqlite3
[ DIR ]
drwxr-xr-x
test_tkinter
[ DIR ]
drwxr-xr-x
test_tomllib
[ DIR ]
drwxr-xr-x
test_tools
[ DIR ]
drwxr-xr-x
test_ttk
[ DIR ]
drwxr-xr-x
test_unittest
[ DIR ]
drwxr-xr-x
test_warnings
[ DIR ]
drwxr-xr-x
test_zipfile
[ DIR ]
drwxr-xr-x
test_zoneinfo
[ DIR ]
drwxr-xr-x
tokenizedata
[ DIR ]
drwxr-xr-x
tracedmodules
[ DIR ]
drwxr-xr-x
typinganndata
[ DIR ]
drwxr-xr-x
wheeldata
[ DIR ]
drwxr-xr-x
xmltestdata
[ DIR ]
drwxr-xr-x
ziptestdata
[ DIR ]
drwxr-xr-x
Sine-1000Hz-300ms.aif
60.25
KB
-rw-r--r--
__init__.py
47
B
-rw-r--r--
__main__.py
67
B
-rw-r--r--
_test_atexit.py
3.61
KB
-rw-r--r--
_test_eintr.py
17.75
KB
-rw-r--r--
_test_embed_set_config.py
8.64
KB
-rw-r--r--
_test_embed_structseq.py
1.99
KB
-rw-r--r--
_test_multiprocessing.py
206.66
KB
-rw-r--r--
_test_venv_multiprocessing.py
796
B
-rw-r--r--
archiver_tests.py
6.1
KB
-rw-r--r--
audiotest.au
27.48
KB
-rw-r--r--
audiotests.py
12.13
KB
-rw-r--r--
audit-tests.py
13.19
KB
-rw-r--r--
autotest.py
214
B
-rw-r--r--
badsyntax_pep3120.py
14
B
-rw-r--r--
bisect_cmd.py
5.34
KB
-rwxr-xr-x
clinic.test.c
138.59
KB
-rw-r--r--
cmath_testcases.txt
141.2
KB
-rw-r--r--
curses_tests.py
1.21
KB
-rwxr-xr-x
datetimetester.py
260.28
KB
-rw-r--r--
dis_module.py
76
B
-rw-r--r--
empty.vbs
70
B
-rw-r--r--
exception_hierarchy.txt
2.33
KB
-rw-r--r--
floating_points.txt
15.92
KB
-rw-r--r--
fork_wait.py
2.29
KB
-rw-r--r--
formatfloat_testcases.txt
7.45
KB
-rw-r--r--
ieee754.txt
3.15
KB
-rw-r--r--
levenshtein_examples.json
406.44
KB
-rw-r--r--
list_tests.py
16.64
KB
-rw-r--r--
lock_tests.py
35.48
KB
-rw-r--r--
mailcap.txt
1.24
KB
-rw-r--r--
mapping_tests.py
21.87
KB
-rw-r--r--
math_testcases.txt
23.19
KB
-rw-r--r--
memory_watchdog.py
711
B
-rw-r--r--
mime.types
47.37
KB
-rw-r--r--
mock_socket.py
3.69
KB
-rw-r--r--
mp_fork_bomb.py
448
B
-rw-r--r--
mp_preload.py
351
B
-rw-r--r--
multibytecodec_support.py
14.19
KB
-rw-r--r--
pickletester.py
143.84
KB
-rw-r--r--
profilee.py
2.97
KB
-rw-r--r--
pstats.pck
65.05
KB
-rw-r--r--
pyclbr_input.py
648
B
-rw-r--r--
pythoninfo.py
28.32
KB
-rw-r--r--
randv2_32.pck
7.34
KB
-rw-r--r--
randv2_64.pck
7.19
KB
-rw-r--r--
randv3.pck
7.82
KB
-rw-r--r--
re_tests.py
25.93
KB
-rwxr-xr-x
recursion.tar
516
B
-rw-r--r--
regrtest.py
1.27
KB
-rwxr-xr-x
relimport.py
27
B
-rw-r--r--
reperf.py
538
B
-rw-r--r--
seq_tests.py
14.96
KB
-rw-r--r--
signalinterproctester.py
3.12
KB
-rw-r--r--
ssl_servers.py
7.12
KB
-rw-r--r--
ssltests.py
1.03
KB
-rw-r--r--
string_tests.py
71.24
KB
-rw-r--r--
test___all__.py
5.04
KB
-rw-r--r--
test__locale.py
8.09
KB
-rw-r--r--
test__opcode.py
4.14
KB
-rw-r--r--
test__osx_support.py
13.62
KB
-rw-r--r--
test__xxinterpchannels.py
52.19
KB
-rw-r--r--
test__xxsubinterpreters.py
27.5
KB
-rw-r--r--
test_abc.py
23.81
KB
-rw-r--r--
test_abstract_numbers.py
5.81
KB
-rw-r--r--
test_aifc.py
17.84
KB
-rw-r--r--
test_argparse.py
189
KB
-rw-r--r--
test_array.py
55.27
KB
-rwxr-xr-x
test_asdl_parser.py
4.44
KB
-rw-r--r--
test_ast.py
140.71
KB
-rw-r--r--
test_asyncgen.py
47.39
KB
-rw-r--r--
test_atexit.py
3.2
KB
-rw-r--r--
test_audioop.py
28.32
KB
-rw-r--r--
test_audit.py
8.6
KB
-rw-r--r--
test_augassign.py
7.68
KB
-rw-r--r--
test_base64.py
35.05
KB
-rw-r--r--
test_baseexception.py
7.77
KB
-rw-r--r--
test_bdb.py
43.75
KB
-rw-r--r--
test_bigaddrspace.py
2.83
KB
-rw-r--r--
test_bigmem.py
45.01
KB
-rw-r--r--
test_binascii.py
19.35
KB
-rw-r--r--
test_binop.py
14.14
KB
-rw-r--r--
test_bisect.py
16.63
KB
-rw-r--r--
test_bool.py
14.25
KB
-rw-r--r--
test_buffer.py
171.31
KB
-rw-r--r--
test_bufio.py
2.56
KB
-rw-r--r--
test_builtin.py
95.14
KB
-rw-r--r--
test_bytes.py
80.57
KB
-rw-r--r--
test_bz2.py
42.61
KB
-rw-r--r--
test_c_locale_coercion.py
20.99
KB
-rw-r--r--
test_calendar.py
51.25
KB
-rw-r--r--
test_call.py
35.21
KB
-rw-r--r--
test_cgi.py
22.27
KB
-rw-r--r--
test_cgitb.py
2.62
KB
-rw-r--r--
test_charmapcodec.py
1.77
KB
-rw-r--r--
test_class.py
19.77
KB
-rw-r--r--
test_clinic.py
83.96
KB
-rw-r--r--
test_cmath.py
23.55
KB
-rw-r--r--
test_cmd.py
6.49
KB
-rw-r--r--
test_cmd_line.py
39.51
KB
-rw-r--r--
test_cmd_line_script.py
34.93
KB
-rw-r--r--
test_code.py
25.7
KB
-rw-r--r--
test_code_module.py
5.53
KB
-rw-r--r--
test_codeccallbacks.py
47.43
KB
-rw-r--r--
test_codecencodings_cn.py
3.86
KB
-rw-r--r--
test_codecencodings_hk.py
701
B
-rw-r--r--
test_codecencodings_iso2022.py
3.65
KB
-rw-r--r--
test_codecencodings_jp.py
4.79
KB
-rw-r--r--
test_codecencodings_kr.py
2.96
KB
-rw-r--r--
test_codecencodings_tw.py
681
B
-rw-r--r--
test_codecmaps_cn.py
746
B
-rw-r--r--
test_codecmaps_hk.py
386
B
-rw-r--r--
test_codecmaps_jp.py
1.7
KB
-rw-r--r--
test_codecmaps_kr.py
1.16
KB
-rw-r--r--
test_codecmaps_tw.py
705
B
-rw-r--r--
test_codecs.py
136.12
KB
-rw-r--r--
test_codeop.py
8.68
KB
-rw-r--r--
test_collections.py
93.47
KB
-rw-r--r--
test_colorsys.py
4.27
KB
-rw-r--r--
test_compare.py
17.46
KB
-rw-r--r--
test_compile.py
78.68
KB
-rw-r--r--
test_compileall.py
48.27
KB
-rw-r--r--
test_compiler_assemble.py
2.46
KB
-rw-r--r--
test_compiler_codegen.py
1.69
KB
-rw-r--r--
test_complex.py
35.37
KB
-rw-r--r--
test_configparser.py
85.34
KB
-rw-r--r--
test_contains.py
3.35
KB
-rw-r--r--
test_context.py
30.78
KB
-rw-r--r--
test_contextlib.py
43.12
KB
-rw-r--r--
test_contextlib_async.py
23.99
KB
-rw-r--r--
test_copy.py
26.52
KB
-rw-r--r--
test_copyreg.py
4.36
KB
-rw-r--r--
test_coroutines.py
67.47
KB
-rw-r--r--
test_cprofile.py
7.36
KB
-rw-r--r--
test_crashers.py
1.17
KB
-rw-r--r--
test_crypt.py
4.19
KB
-rw-r--r--
test_csv.py
61.27
KB
-rw-r--r--
test_curses.py
49.54
KB
-rw-r--r--
test_datetime.py
2.53
KB
-rw-r--r--
test_dbm.py
6.83
KB
-rw-r--r--
test_dbm_dumb.py
11.08
KB
-rw-r--r--
test_dbm_gnu.py
7.24
KB
-rw-r--r--
test_dbm_ndbm.py
5.91
KB
-rw-r--r--
test_decimal.py
216.13
KB
-rw-r--r--
test_decorators.py
14.63
KB
-rw-r--r--
test_defaultdict.py
6.1
KB
-rw-r--r--
test_deque.py
33.16
KB
-rw-r--r--
test_descr.py
196.13
KB
-rw-r--r--
test_descrtut.py
10.98
KB
-rw-r--r--
test_devpoll.py
4.44
KB
-rw-r--r--
test_dict.py
50.92
KB
-rw-r--r--
test_dict_version.py
6.1
KB
-rw-r--r--
test_dictcomps.py
5.15
KB
-rw-r--r--
test_dictviews.py
14.82
KB
-rw-r--r--
test_difflib.py
21.47
KB
-rw-r--r--
test_difflib_expect.html
100.85
KB
-rw-r--r--
test_dis.py
83
KB
-rw-r--r--
test_docxmlrpc.py
9.1
KB
-rw-r--r--
test_dtrace.py
7.98
KB
-rw-r--r--
test_dynamic.py
6
KB
-rw-r--r--
test_dynamicclassattribute.py
9.57
KB
-rw-r--r--
test_eintr.py
627
B
-rw-r--r--
test_embed.py
69.41
KB
-rw-r--r--
test_ensurepip.py
11.49
KB
-rw-r--r--
test_enum.py
186.78
KB
-rw-r--r--
test_enumerate.py
9.14
KB
-rw-r--r--
test_eof.py
3.1
KB
-rw-r--r--
test_epoll.py
9.4
KB
-rw-r--r--
test_errno.py
1.04
KB
-rw-r--r--
test_except_star.py
38.25
KB
-rw-r--r--
test_exception_group.py
34.03
KB
-rw-r--r--
test_exception_hierarchy.py
7.54
KB
-rw-r--r--
test_exception_variations.py
13.74
KB
-rw-r--r--
test_exceptions.py
76.46
KB
-rw-r--r--
test_extcall.py
14.69
KB
-rw-r--r--
test_faulthandler.py
30.31
KB
-rw-r--r--
test_fcntl.py
7.76
KB
-rw-r--r--
test_file.py
11.78
KB
-rw-r--r--
test_file_eintr.py
10.74
KB
-rw-r--r--
test_filecmp.py
10.33
KB
-rw-r--r--
test_fileinput.py
37.85
KB
-rw-r--r--
test_fileio.py
19.98
KB
-rw-r--r--
test_fileutils.py
951
B
-rw-r--r--
test_finalization.py
14.66
KB
-rw-r--r--
test_float.py
64.76
KB
-rw-r--r--
test_flufl.py
1.53
KB
-rw-r--r--
test_fnmatch.py
10.68
KB
-rw-r--r--
test_fork1.py
3.3
KB
-rw-r--r--
test_format.py
28.44
KB
-rw-r--r--
test_fractions.py
52.53
KB
-rw-r--r--
test_frame.py
14.04
KB
-rw-r--r--
test_frozen.py
2.2
KB
-rw-r--r--
test_fstring.py
64.71
KB
-rw-r--r--
test_ftplib.py
41.94
KB
-rw-r--r--
test_funcattrs.py
15.57
KB
-rw-r--r--
test_functools.py
109.31
KB
-rw-r--r--
test_gc.py
47.71
KB
-rw-r--r--
test_generator_stop.py
943
B
-rw-r--r--
test_generators.py
66.13
KB
-rw-r--r--
test_genericalias.py
17.78
KB
-rw-r--r--
test_genericclass.py
9.44
KB
-rw-r--r--
test_genericpath.py
22.29
KB
-rw-r--r--
test_genexps.py
7.3
KB
-rw-r--r--
test_getopt.py
6.6
KB
-rw-r--r--
test_getpass.py
6.37
KB
-rw-r--r--
test_getpath.py
44.36
KB
-rw-r--r--
test_gettext.py
35.67
KB
-rw-r--r--
test_glob.py
17.19
KB
-rw-r--r--
test_global.py
1.2
KB
-rw-r--r--
test_grammar.py
65.97
KB
-rw-r--r--
test_graphlib.py
8.31
KB
-rw-r--r--
test_grp.py
3.67
KB
-rw-r--r--
test_gzip.py
40.94
KB
-rw-r--r--
test_hash.py
12.11
KB
-rw-r--r--
test_hashlib.py
46.71
KB
-rw-r--r--
test_heapq.py
16.42
KB
-rw-r--r--
test_hmac.py
26.06
KB
-rw-r--r--
test_html.py
4.23
KB
-rw-r--r--
test_htmlparser.py
33.37
KB
-rw-r--r--
test_http_cookiejar.py
81.57
KB
-rw-r--r--
test_http_cookies.py
18.7
KB
-rw-r--r--
test_httplib.py
96.14
KB
-rw-r--r--
test_httpservers.py
56.43
KB
-rw-r--r--
test_idle.py
831
B
-rw-r--r--
test_imaplib.py
41.69
KB
-rw-r--r--
test_imghdr.py
4.81
KB
-rw-r--r--
test_index.py
8.37
KB
-rw-r--r--
test_int.py
33.34
KB
-rw-r--r--
test_int_literal.py
6.89
KB
-rw-r--r--
test_interpreters.py
32.11
KB
-rw-r--r--
test_io.py
182.76
KB
-rw-r--r--
test_ioctl.py
3.24
KB
-rw-r--r--
test_ipaddress.py
119.17
KB
-rw-r--r--
test_isinstance.py
12.95
KB
-rw-r--r--
test_iter.py
36.77
KB
-rw-r--r--
test_iterlen.py
7.1
KB
-rw-r--r--
test_itertools.py
106.61
KB
-rw-r--r--
test_keyword.py
2
KB
-rw-r--r--
test_keywordonlyarg.py
6.89
KB
-rw-r--r--
test_kqueue.py
9.36
KB
-rw-r--r--
test_largefile.py
10.17
KB
-rw-r--r--
test_launcher.py
27.23
KB
-rw-r--r--
test_linecache.py
11.04
KB
-rw-r--r--
test_list.py
8.93
KB
-rw-r--r--
test_listcomps.py
20.71
KB
-rw-r--r--
test_lltrace.py
3.71
KB
-rw-r--r--
test_locale.py
24.43
KB
-rw-r--r--
test_logging.py
241.62
KB
-rw-r--r--
test_long.py
63.33
KB
-rw-r--r--
test_longexp.py
233
B
-rw-r--r--
test_lzma.py
92.65
KB
-rw-r--r--
test_mailbox.py
93.91
KB
-rw-r--r--
test_mailcap.py
11.48
KB
-rw-r--r--
test_marshal.py
23.15
KB
-rw-r--r--
test_math.py
107.6
KB
-rw-r--r--
test_math_property.py
1.15
KB
-rw-r--r--
test_memoryio.py
32.65
KB
-rw-r--r--
test_memoryview.py
21.76
KB
-rw-r--r--
test_metaclass.py
6.19
KB
-rw-r--r--
test_mimetypes.py
15.28
KB
-rw-r--r--
test_minidom.py
68.42
KB
-rw-r--r--
test_mmap.py
38.56
KB
-rw-r--r--
test_modulefinder.py
12.21
KB
-rw-r--r--
test_monitoring.py
55.76
KB
-rw-r--r--
test_msilib.py
5.52
KB
-rw-r--r--
test_multibytecodec.py
15.79
KB
-rw-r--r--
test_multiprocessing_main_hand...
11.48
KB
-rw-r--r--
test_named_expressions.py
29.62
KB
-rw-r--r--
test_netrc.py
11.86
KB
-rw-r--r--
test_nis.py
1.25
KB
-rw-r--r--
test_nntplib.py
62.7
KB
-rw-r--r--
test_ntpath.py
52.48
KB
-rw-r--r--
test_numeric_tower.py
8
KB
-rw-r--r--
test_opcache.py
10.89
KB
-rw-r--r--
test_opcodes.py
3.62
KB
-rw-r--r--
test_openpty.py
600
B
-rw-r--r--
test_operator.py
26.72
KB
-rw-r--r--
test_optparse.py
61.02
KB
-rw-r--r--
test_ordered_dict.py
35.62
KB
-rw-r--r--
test_os.py
179.95
KB
-rw-r--r--
test_ossaudiodev.py
7.27
KB
-rw-r--r--
test_osx_env.py
1.31
KB
-rw-r--r--
test_pathlib.py
137.81
KB
-rw-r--r--
test_patma.py
86.03
KB
-rw-r--r--
test_pdb.py
86.53
KB
-rw-r--r--
test_peepholer.py
40.6
KB
-rw-r--r--
test_pep646_syntax.py
7.79
KB
-rw-r--r--
test_perf_profiler.py
11.27
KB
-rw-r--r--
test_perfmaps.py
685
B
-rw-r--r--
test_pickle.py
20.75
KB
-rw-r--r--
test_picklebuffer.py
4.99
KB
-rw-r--r--
test_pickletools.py
4.13
KB
-rw-r--r--
test_pipes.py
6.79
KB
-rw-r--r--
test_pkg.py
9.59
KB
-rw-r--r--
test_pkgutil.py
22.36
KB
-rw-r--r--
test_platform.py
21.59
KB
-rw-r--r--
test_plistlib.py
41.25
KB
-rw-r--r--
test_poll.py
7.39
KB
-rw-r--r--
test_popen.py
2.11
KB
-rw-r--r--
test_poplib.py
17.05
KB
-rw-r--r--
test_positional_only_arg.py
18.44
KB
-rw-r--r--
test_posix.py
95.07
KB
-rw-r--r--
test_posixpath.py
33.75
KB
-rw-r--r--
test_pow.py
6.38
KB
-rw-r--r--
test_pprint.py
50.59
KB
-rw-r--r--
test_print.py
7.72
KB
-rw-r--r--
test_profile.py
8.69
KB
-rw-r--r--
test_property.py
18.03
KB
-rw-r--r--
test_pstats.py
4.31
KB
-rw-r--r--
test_pty.py
16.18
KB
-rw-r--r--
test_pulldom.py
12.33
KB
-rw-r--r--
test_pwd.py
4.32
KB
-rw-r--r--
test_py_compile.py
11.93
KB
-rw-r--r--
test_pyclbr.py
10.15
KB
-rw-r--r--
test_pyexpat.py
29.35
KB
-rw-r--r--
test_queue.py
20.61
KB
-rw-r--r--
test_quopri.py
7.87
KB
-rw-r--r--
test_raise.py
13.44
KB
-rw-r--r--
test_random.py
56.69
KB
-rw-r--r--
test_range.py
26.53
KB
-rw-r--r--
test_re.py
131.37
KB
-rw-r--r--
test_readline.py
12.76
KB
-rw-r--r--
test_regrtest.py
90.02
KB
-rw-r--r--
test_repl.py
4.99
KB
-rw-r--r--
test_reprlib.py
27.77
KB
-rw-r--r--
test_resource.py
7.12
KB
-rw-r--r--
test_richcmp.py
11.95
KB
-rw-r--r--
test_rlcompleter.py
7.4
KB
-rw-r--r--
test_robotparser.py
11.02
KB
-rw-r--r--
test_runpy.py
33.95
KB
-rw-r--r--
test_sax.py
54.63
KB
-rw-r--r--
test_sched.py
7.38
KB
-rw-r--r--
test_scope.py
21.21
KB
-rw-r--r--
test_script_helper.py
5.82
KB
-rw-r--r--
test_secrets.py
4.28
KB
-rw-r--r--
test_select.py
3.42
KB
-rw-r--r--
test_selectors.py
19.64
KB
-rw-r--r--
test_set.py
71.31
KB
-rw-r--r--
test_setcomps.py
3.8
KB
-rw-r--r--
test_shelve.py
6.42
KB
-rw-r--r--
test_shlex.py
13.39
KB
-rw-r--r--
test_shutil.py
126.96
KB
-rw-r--r--
test_signal.py
52.42
KB
-rw-r--r--
test_site.py
29.79
KB
-rw-r--r--
test_slice.py
9.46
KB
-rw-r--r--
test_smtplib.py
60.02
KB
-rw-r--r--
test_smtpnet.py
3.03
KB
-rw-r--r--
test_sndhdr.py
1.51
KB
-rw-r--r--
test_socket.py
254.72
KB
-rw-r--r--
test_socketserver.py
17.39
KB
-rw-r--r--
test_sort.py
13.59
KB
-rw-r--r--
test_source_encoding.py
12.65
KB
-rw-r--r--
test_spwd.py
2.83
KB
-rw-r--r--
test_ssl.py
215.24
KB
-rw-r--r--
test_stable_abi_ctypes.py
24.75
KB
-rw-r--r--
test_startfile.py
1.7
KB
-rw-r--r--
test_stat.py
8.92
KB
-rw-r--r--
test_statistics.py
120.02
KB
-rw-r--r--
test_strftime.py
7.4
KB
-rw-r--r--
test_string.py
21.86
KB
-rw-r--r--
test_string_literals.py
13.07
KB
-rw-r--r--
test_stringprep.py
3.04
KB
-rw-r--r--
test_strptime.py
36.48
KB
-rw-r--r--
test_strtod.py
20.06
KB
-rw-r--r--
test_struct.py
38.45
KB
-rw-r--r--
test_structseq.py
7.23
KB
-rw-r--r--
test_subclassinit.py
8.04
KB
-rw-r--r--
test_subprocess.py
162.29
KB
-rw-r--r--
test_sunau.py
6.09
KB
-rw-r--r--
test_sundry.py
1.02
KB
-rw-r--r--
test_super.py
13.9
KB
-rw-r--r--
test_support.py
27.05
KB
-rw-r--r--
test_symtable.py
11.05
KB
-rw-r--r--
test_syntax.py
71.87
KB
-rw-r--r--
test_sys.py
65.64
KB
-rw-r--r--
test_sys_setprofile.py
13.71
KB
-rw-r--r--
test_sys_settrace.py
84.56
KB
-rw-r--r--
test_sysconfig.py
22.45
KB
-rw-r--r--
test_syslog.py
4.7
KB
-rw-r--r--
test_tabnanny.py
13.89
KB
-rw-r--r--
test_tarfile.py
159.67
KB
-rw-r--r--
test_tcl.py
27.22
KB
-rw-r--r--
test_telnetlib.py
12.85
KB
-rw-r--r--
test_tempfile.py
73.86
KB
-rw-r--r--
test_termios.py
10.95
KB
-rw-r--r--
test_textwrap.py
41.89
KB
-rw-r--r--
test_thread.py
8.87
KB
-rw-r--r--
test_threadedtempfile.py
1.93
KB
-rw-r--r--
test_threading.py
73
KB
-rw-r--r--
test_threading_local.py
6.58
KB
-rw-r--r--
test_threadsignals.py
9.87
KB
-rw-r--r--
test_time.py
42.44
KB
-rw-r--r--
test_timeit.py
15.2
KB
-rw-r--r--
test_timeout.py
10.74
KB
-rw-r--r--
test_tix.py
1.05
KB
-rw-r--r--
test_tokenize.py
115.33
KB
-rw-r--r--
test_trace.py
20.58
KB
-rw-r--r--
test_traceback.py
142.96
KB
-rw-r--r--
test_tracemalloc.py
39.54
KB
-rw-r--r--
test_ttk_textonly.py
16.69
KB
-rw-r--r--
test_tty.py
3.63
KB
-rw-r--r--
test_tuple.py
19.8
KB
-rw-r--r--
test_turtle.py
14.04
KB
-rw-r--r--
test_type_aliases.py
11.65
KB
-rw-r--r--
test_type_annotations.py
6.23
KB
-rw-r--r--
test_type_cache.py
6.6
KB
-rw-r--r--
test_type_comments.py
10.5
KB
-rw-r--r--
test_type_params.py
34.24
KB
-rw-r--r--
test_typechecks.py
2.55
KB
-rw-r--r--
test_types.py
80.76
KB
-rw-r--r--
test_typing.py
334.07
KB
-rw-r--r--
test_ucn.py
9.52
KB
-rw-r--r--
test_unary.py
1.52
KB
-rw-r--r--
test_unicode.py
124.82
KB
-rw-r--r--
test_unicode_file.py
5.72
KB
-rw-r--r--
test_unicode_file_functions.py
6.91
KB
-rw-r--r--
test_unicode_identifiers.py
997
B
-rw-r--r--
test_unicodedata.py
17.01
KB
-rw-r--r--
test_univnewlines.py
3.85
KB
-rw-r--r--
test_unpack.py
3.51
KB
-rw-r--r--
test_unpack_ex.py
9.89
KB
-rw-r--r--
test_unparse.py
27.75
KB
-rw-r--r--
test_urllib.py
70.17
KB
-rw-r--r--
test_urllib2.py
80.73
KB
-rw-r--r--
test_urllib2_localnet.py
25.59
KB
-rw-r--r--
test_urllib2net.py
13.96
KB
-rw-r--r--
test_urllib_response.py
2
KB
-rw-r--r--
test_urllibnet.py
9.41
KB
-rw-r--r--
test_urlparse.py
73.73
KB
-rw-r--r--
test_userdict.py
7.56
KB
-rw-r--r--
test_userlist.py
1.97
KB
-rw-r--r--
test_userstring.py
2.52
KB
-rw-r--r--
test_utf8_mode.py
10.31
KB
-rw-r--r--
test_utf8source.py
1.15
KB
-rw-r--r--
test_uu.py
9.2
KB
-rw-r--r--
test_uuid.py
44.26
KB
-rwxr-xr-x
test_venv.py
32.42
KB
-rw-r--r--
test_wait3.py
1.74
KB
-rw-r--r--
test_wait4.py
1.14
KB
-rw-r--r--
test_wave.py
7.64
KB
-rw-r--r--
test_weakref.py
74.32
KB
-rw-r--r--
test_weakset.py
16.3
KB
-rw-r--r--
test_webbrowser.py
10.5
KB
-rw-r--r--
test_winconsoleio.py
6.69
KB
-rw-r--r--
test_winreg.py
22.48
KB
-rw-r--r--
test_winsound.py
5.32
KB
-rw-r--r--
test_with.py
26.02
KB
-rw-r--r--
test_wmi.py
2.89
KB
-rw-r--r--
test_wsgiref.py
29.32
KB
-rw-r--r--
test_xdrlib.py
2.25
KB
-rw-r--r--
test_xml_dom_minicompat.py
4.18
KB
-rw-r--r--
test_xml_etree.py
160.22
KB
-rw-r--r--
test_xml_etree_c.py
9.34
KB
-rw-r--r--
test_xmlrpc.py
58.08
KB
-rw-r--r--
test_xmlrpc_net.py
954
B
-rw-r--r--
test_xxlimited.py
2.46
KB
-rw-r--r--
test_xxtestfuzz.py
690
B
-rw-r--r--
test_yield_from.py
50.23
KB
-rw-r--r--
test_zipapp.py
16.6
KB
-rw-r--r--
test_zipfile64.py
5.78
KB
-rw-r--r--
test_zipimport.py
32.97
KB
-rw-r--r--
test_zipimport_support.py
10.57
KB
-rw-r--r--
test_zlib.py
41.47
KB
-rw-r--r--
testcodec.py
1.02
KB
-rw-r--r--
testtar.tar
425
KB
-rw-r--r--
testtar.tar.xz
172
B
-rw-r--r--
tf_inherit_check.py
714
B
-rw-r--r--
time_hashlib.py
2.87
KB
-rw-r--r--
win_console_handler.py
1.38
KB
-rw-r--r--
xmltests.py
499
B
-rw-r--r--
zip_cp437_header.zip
270
B
-rw-r--r--
zipdir.zip
374
B
-rw-r--r--
zipdir_backslash.zip
192
B
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : test_complex.py
import unittest import sys from test import support from test.test_grammar import (VALID_UNDERSCORE_LITERALS, INVALID_UNDERSCORE_LITERALS) from random import random from math import atan2, isnan, copysign import operator INF = float("inf") NAN = float("nan") # These tests ensure that complex math does the right thing ZERO_DIVISION = ( (1+1j, 0+0j), (1+1j, 0.0), (1+1j, 0), (1.0, 0+0j), (1, 0+0j), ) class ComplexTest(unittest.TestCase): def assertAlmostEqual(self, a, b): if isinstance(a, complex): if isinstance(b, complex): unittest.TestCase.assertAlmostEqual(self, a.real, b.real) unittest.TestCase.assertAlmostEqual(self, a.imag, b.imag) else: unittest.TestCase.assertAlmostEqual(self, a.real, b) unittest.TestCase.assertAlmostEqual(self, a.imag, 0.) else: if isinstance(b, complex): unittest.TestCase.assertAlmostEqual(self, a, b.real) unittest.TestCase.assertAlmostEqual(self, 0., b.imag) else: unittest.TestCase.assertAlmostEqual(self, a, b) def assertCloseAbs(self, x, y, eps=1e-9): """Return true iff floats x and y "are close".""" # put the one with larger magnitude second if abs(x) > abs(y): x, y = y, x if y == 0: return abs(x) < eps if x == 0: return abs(y) < eps # check that relative difference < eps self.assertTrue(abs((x-y)/y) < eps) def assertFloatsAreIdentical(self, x, y): """assert that floats x and y are identical, in the sense that: (1) both x and y are nans, or (2) both x and y are infinities, with the same sign, or (3) both x and y are zeros, with the same sign, or (4) x and y are both finite and nonzero, and x == y """ msg = 'floats {!r} and {!r} are not identical' if isnan(x) or isnan(y): if isnan(x) and isnan(y): return elif x == y: if x != 0.0: return # both zero; check that signs match elif copysign(1.0, x) == copysign(1.0, y): return else: msg += ': zeros have different signs' self.fail(msg.format(x, y)) def assertClose(self, x, y, eps=1e-9): """Return true iff complexes x and y "are close".""" self.assertCloseAbs(x.real, y.real, eps) self.assertCloseAbs(x.imag, y.imag, eps) def check_div(self, x, y): """Compute complex z=x*y, and check that z/x==y and z/y==x.""" z = x * y if x != 0: q = z / x self.assertClose(q, y) q = z.__truediv__(x) self.assertClose(q, y) if y != 0: q = z / y self.assertClose(q, x) q = z.__truediv__(y) self.assertClose(q, x) def test_truediv(self): simple_real = [float(i) for i in range(-5, 6)] simple_complex = [complex(x, y) for x in simple_real for y in simple_real] for x in simple_complex: for y in simple_complex: self.check_div(x, y) # A naive complex division algorithm (such as in 2.0) is very prone to # nonsense errors for these (overflows and underflows). self.check_div(complex(1e200, 1e200), 1+0j) self.check_div(complex(1e-200, 1e-200), 1+0j) # Just for fun. for i in range(100): self.check_div(complex(random(), random()), complex(random(), random())) self.assertAlmostEqual(complex.__truediv__(2+0j, 1+1j), 1-1j) self.assertRaises(TypeError, operator.truediv, 1j, None) self.assertRaises(TypeError, operator.truediv, None, 1j) for denom_real, denom_imag in [(0, NAN), (NAN, 0), (NAN, NAN)]: z = complex(0, 0) / complex(denom_real, denom_imag) self.assertTrue(isnan(z.real)) self.assertTrue(isnan(z.imag)) def test_truediv_zero_division(self): for a, b in ZERO_DIVISION: with self.assertRaises(ZeroDivisionError): a / b def test_floordiv(self): with self.assertRaises(TypeError): (1+1j) // (1+0j) with self.assertRaises(TypeError): (1+1j) // 1.0 with self.assertRaises(TypeError): (1+1j) // 1 with self.assertRaises(TypeError): 1.0 // (1+0j) with self.assertRaises(TypeError): 1 // (1+0j) def test_floordiv_zero_division(self): for a, b in ZERO_DIVISION: with self.assertRaises(TypeError): a // b def test_richcompare(self): self.assertIs(complex.__eq__(1+1j, 1<<10000), False) self.assertIs(complex.__lt__(1+1j, None), NotImplemented) self.assertIs(complex.__eq__(1+1j, None), NotImplemented) self.assertIs(complex.__eq__(1+1j, 1+1j), True) self.assertIs(complex.__eq__(1+1j, 2+2j), False) self.assertIs(complex.__ne__(1+1j, 1+1j), False) self.assertIs(complex.__ne__(1+1j, 2+2j), True) for i in range(1, 100): f = i / 100.0 self.assertIs(complex.__eq__(f+0j, f), True) self.assertIs(complex.__ne__(f+0j, f), False) self.assertIs(complex.__eq__(complex(f, f), f), False) self.assertIs(complex.__ne__(complex(f, f), f), True) self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented) self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented) self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented) self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented) self.assertRaises(TypeError, operator.lt, 1+1j, 2+2j) self.assertRaises(TypeError, operator.le, 1+1j, 2+2j) self.assertRaises(TypeError, operator.gt, 1+1j, 2+2j) self.assertRaises(TypeError, operator.ge, 1+1j, 2+2j) self.assertIs(operator.eq(1+1j, 1+1j), True) self.assertIs(operator.eq(1+1j, 2+2j), False) self.assertIs(operator.ne(1+1j, 1+1j), False) self.assertIs(operator.ne(1+1j, 2+2j), True) self.assertIs(operator.eq(1+1j, 2.0), False) def test_richcompare_boundaries(self): def check(n, deltas, is_equal, imag = 0.0): for delta in deltas: i = n + delta z = complex(i, imag) self.assertIs(complex.__eq__(z, i), is_equal(delta)) self.assertIs(complex.__ne__(z, i), not is_equal(delta)) # For IEEE-754 doubles the following should hold: # x in [2 ** (52 + i), 2 ** (53 + i + 1)] -> x mod 2 ** i == 0 # where the interval is representable, of course. for i in range(1, 10): pow = 52 + i mult = 2 ** i check(2 ** pow, range(1, 101), lambda delta: delta % mult == 0) check(2 ** pow, range(1, 101), lambda delta: False, float(i)) check(2 ** 53, range(-100, 0), lambda delta: True) def test_add(self): self.assertEqual(1j + int(+1), complex(+1, 1)) self.assertEqual(1j + int(-1), complex(-1, 1)) self.assertRaises(OverflowError, operator.add, 1j, 10**1000) self.assertRaises(TypeError, operator.add, 1j, None) self.assertRaises(TypeError, operator.add, None, 1j) def test_sub(self): self.assertEqual(1j - int(+1), complex(-1, 1)) self.assertEqual(1j - int(-1), complex(1, 1)) self.assertRaises(OverflowError, operator.sub, 1j, 10**1000) self.assertRaises(TypeError, operator.sub, 1j, None) self.assertRaises(TypeError, operator.sub, None, 1j) def test_mul(self): self.assertEqual(1j * int(20), complex(0, 20)) self.assertEqual(1j * int(-1), complex(0, -1)) self.assertRaises(OverflowError, operator.mul, 1j, 10**1000) self.assertRaises(TypeError, operator.mul, 1j, None) self.assertRaises(TypeError, operator.mul, None, 1j) def test_mod(self): # % is no longer supported on complex numbers with self.assertRaises(TypeError): (1+1j) % (1+0j) with self.assertRaises(TypeError): (1+1j) % 1.0 with self.assertRaises(TypeError): (1+1j) % 1 with self.assertRaises(TypeError): 1.0 % (1+0j) with self.assertRaises(TypeError): 1 % (1+0j) def test_mod_zero_division(self): for a, b in ZERO_DIVISION: with self.assertRaises(TypeError): a % b def test_divmod(self): self.assertRaises(TypeError, divmod, 1+1j, 1+0j) self.assertRaises(TypeError, divmod, 1+1j, 1.0) self.assertRaises(TypeError, divmod, 1+1j, 1) self.assertRaises(TypeError, divmod, 1.0, 1+0j) self.assertRaises(TypeError, divmod, 1, 1+0j) def test_divmod_zero_division(self): for a, b in ZERO_DIVISION: self.assertRaises(TypeError, divmod, a, b) def test_pow(self): self.assertAlmostEqual(pow(1+1j, 0+0j), 1.0) self.assertAlmostEqual(pow(0+0j, 2+0j), 0.0) self.assertEqual(pow(0+0j, 2000+0j), 0.0) self.assertEqual(pow(0, 0+0j), 1.0) self.assertEqual(pow(-1, 0+0j), 1.0) self.assertRaises(ZeroDivisionError, pow, 0+0j, 1j) self.assertRaises(ZeroDivisionError, pow, 0+0j, -1000) self.assertAlmostEqual(pow(1j, -1), 1/1j) self.assertAlmostEqual(pow(1j, 200), 1) self.assertRaises(ValueError, pow, 1+1j, 1+1j, 1+1j) self.assertRaises(OverflowError, pow, 1e200+1j, 1e200+1j) self.assertRaises(TypeError, pow, 1j, None) self.assertRaises(TypeError, pow, None, 1j) self.assertAlmostEqual(pow(1j, 0.5), 0.7071067811865476+0.7071067811865475j) a = 3.33+4.43j self.assertEqual(a ** 0j, 1) self.assertEqual(a ** 0.+0.j, 1) self.assertEqual(3j ** 0j, 1) self.assertEqual(3j ** 0, 1) try: 0j ** a except ZeroDivisionError: pass else: self.fail("should fail 0.0 to negative or complex power") try: 0j ** (3-2j) except ZeroDivisionError: pass else: self.fail("should fail 0.0 to negative or complex power") # The following is used to exercise certain code paths self.assertEqual(a ** 105, a ** 105) self.assertEqual(a ** -105, a ** -105) self.assertEqual(a ** -30, a ** -30) self.assertEqual(0.0j ** 0, 1) b = 5.1+2.3j self.assertRaises(ValueError, pow, a, b, 0) # Check some boundary conditions; some of these used to invoke # undefined behaviour (https://bugs.python.org/issue44698). We're # not actually checking the results of these operations, just making # sure they don't crash (for example when using clang's # UndefinedBehaviourSanitizer). values = (sys.maxsize, sys.maxsize+1, sys.maxsize-1, -sys.maxsize, -sys.maxsize+1, -sys.maxsize+1) for real in values: for imag in values: with self.subTest(real=real, imag=imag): c = complex(real, imag) try: c ** real except OverflowError: pass try: c ** c except OverflowError: pass def test_pow_with_small_integer_exponents(self): # Check that small integer exponents are handled identically # regardless of their type. values = [ complex(5.0, 12.0), complex(5.0e100, 12.0e100), complex(-4.0, INF), complex(INF, 0.0), ] exponents = [-19, -5, -3, -2, -1, 0, 1, 2, 3, 5, 19] for value in values: for exponent in exponents: with self.subTest(value=value, exponent=exponent): try: int_pow = value**exponent except OverflowError: int_pow = "overflow" try: float_pow = value**float(exponent) except OverflowError: float_pow = "overflow" try: complex_pow = value**complex(exponent) except OverflowError: complex_pow = "overflow" self.assertEqual(str(float_pow), str(int_pow)) self.assertEqual(str(complex_pow), str(int_pow)) def test_boolcontext(self): for i in range(100): self.assertTrue(complex(random() + 1e-6, random() + 1e-6)) self.assertTrue(not complex(0.0, 0.0)) self.assertTrue(1j) def test_conjugate(self): self.assertClose(complex(5.3, 9.8).conjugate(), 5.3-9.8j) def test_constructor(self): class NS: def __init__(self, value): self.value = value def __complex__(self): return self.value self.assertEqual(complex(NS(1+10j)), 1+10j) self.assertRaises(TypeError, complex, NS(None)) self.assertRaises(TypeError, complex, {}) self.assertRaises(TypeError, complex, NS(1.5)) self.assertRaises(TypeError, complex, NS(1)) self.assertRaises(TypeError, complex, object()) self.assertRaises(TypeError, complex, NS(4.25+0.5j), object()) self.assertAlmostEqual(complex("1+10j"), 1+10j) self.assertAlmostEqual(complex(10), 10+0j) self.assertAlmostEqual(complex(10.0), 10+0j) self.assertAlmostEqual(complex(10), 10+0j) self.assertAlmostEqual(complex(10+0j), 10+0j) self.assertAlmostEqual(complex(1,10), 1+10j) self.assertAlmostEqual(complex(1,10), 1+10j) self.assertAlmostEqual(complex(1,10.0), 1+10j) self.assertAlmostEqual(complex(1,10), 1+10j) self.assertAlmostEqual(complex(1,10), 1+10j) self.assertAlmostEqual(complex(1,10.0), 1+10j) self.assertAlmostEqual(complex(1.0,10), 1+10j) self.assertAlmostEqual(complex(1.0,10), 1+10j) self.assertAlmostEqual(complex(1.0,10.0), 1+10j) self.assertAlmostEqual(complex(3.14+0j), 3.14+0j) self.assertAlmostEqual(complex(3.14), 3.14+0j) self.assertAlmostEqual(complex(314), 314.0+0j) self.assertAlmostEqual(complex(314), 314.0+0j) self.assertAlmostEqual(complex(3.14+0j, 0j), 3.14+0j) self.assertAlmostEqual(complex(3.14, 0.0), 3.14+0j) self.assertAlmostEqual(complex(314, 0), 314.0+0j) self.assertAlmostEqual(complex(314, 0), 314.0+0j) self.assertAlmostEqual(complex(0j, 3.14j), -3.14+0j) self.assertAlmostEqual(complex(0.0, 3.14j), -3.14+0j) self.assertAlmostEqual(complex(0j, 3.14), 3.14j) self.assertAlmostEqual(complex(0.0, 3.14), 3.14j) self.assertAlmostEqual(complex("1"), 1+0j) self.assertAlmostEqual(complex("1j"), 1j) self.assertAlmostEqual(complex(), 0) self.assertAlmostEqual(complex("-1"), -1) self.assertAlmostEqual(complex("+1"), +1) self.assertAlmostEqual(complex("(1+2j)"), 1+2j) self.assertAlmostEqual(complex("(1.3+2.2j)"), 1.3+2.2j) self.assertAlmostEqual(complex("3.14+1J"), 3.14+1j) self.assertAlmostEqual(complex(" ( +3.14-6J )"), 3.14-6j) self.assertAlmostEqual(complex(" ( +3.14-J )"), 3.14-1j) self.assertAlmostEqual(complex(" ( +3.14+j )"), 3.14+1j) self.assertAlmostEqual(complex("J"), 1j) self.assertAlmostEqual(complex("( j )"), 1j) self.assertAlmostEqual(complex("+J"), 1j) self.assertAlmostEqual(complex("( -j)"), -1j) self.assertAlmostEqual(complex('1e-500'), 0.0 + 0.0j) self.assertAlmostEqual(complex('-1e-500j'), 0.0 - 0.0j) self.assertAlmostEqual(complex('-1e-500+1e-500j'), -0.0 + 0.0j) self.assertEqual(complex('1-1j'), 1.0 - 1j) self.assertEqual(complex('1J'), 1j) class complex2(complex): pass self.assertAlmostEqual(complex(complex2(1+1j)), 1+1j) self.assertAlmostEqual(complex(real=17, imag=23), 17+23j) self.assertAlmostEqual(complex(real=17+23j), 17+23j) self.assertAlmostEqual(complex(real=17+23j, imag=23), 17+46j) self.assertAlmostEqual(complex(real=1+2j, imag=3+4j), -3+5j) # check that the sign of a zero in the real or imaginary part # is preserved when constructing from two floats. (These checks # are harmless on systems without support for signed zeros.) def split_zeros(x): """Function that produces different results for 0. and -0.""" return atan2(x, -1.) self.assertEqual(split_zeros(complex(1., 0.).imag), split_zeros(0.)) self.assertEqual(split_zeros(complex(1., -0.).imag), split_zeros(-0.)) self.assertEqual(split_zeros(complex(0., 1.).real), split_zeros(0.)) self.assertEqual(split_zeros(complex(-0., 1.).real), split_zeros(-0.)) c = 3.14 + 1j self.assertTrue(complex(c) is c) del c self.assertRaises(TypeError, complex, "1", "1") self.assertRaises(TypeError, complex, 1, "1") # SF bug 543840: complex(string) accepts strings with \0 # Fixed in 2.3. self.assertRaises(ValueError, complex, '1+1j\0j') self.assertRaises(TypeError, int, 5+3j) self.assertRaises(TypeError, int, 5+3j) self.assertRaises(TypeError, float, 5+3j) self.assertRaises(ValueError, complex, "") self.assertRaises(TypeError, complex, None) self.assertRaisesRegex(TypeError, "not 'NoneType'", complex, None) self.assertRaises(ValueError, complex, "\0") self.assertRaises(ValueError, complex, "3\09") self.assertRaises(TypeError, complex, "1", "2") self.assertRaises(TypeError, complex, "1", 42) self.assertRaises(TypeError, complex, 1, "2") self.assertRaises(ValueError, complex, "1+") self.assertRaises(ValueError, complex, "1+1j+1j") self.assertRaises(ValueError, complex, "--") self.assertRaises(ValueError, complex, "(1+2j") self.assertRaises(ValueError, complex, "1+2j)") self.assertRaises(ValueError, complex, "1+(2j)") self.assertRaises(ValueError, complex, "(1+2j)123") self.assertRaises(ValueError, complex, "x") self.assertRaises(ValueError, complex, "1j+2") self.assertRaises(ValueError, complex, "1e1ej") self.assertRaises(ValueError, complex, "1e++1ej") self.assertRaises(ValueError, complex, ")1+2j(") self.assertRaisesRegex( TypeError, "first argument must be a string or a number, not 'dict'", complex, {1:2}, 1) self.assertRaisesRegex( TypeError, "second argument must be a number, not 'dict'", complex, 1, {1:2}) # the following three are accepted by Python 2.6 self.assertRaises(ValueError, complex, "1..1j") self.assertRaises(ValueError, complex, "1.11.1j") self.assertRaises(ValueError, complex, "1e1.1j") # check that complex accepts long unicode strings self.assertEqual(type(complex("1"*500)), complex) # check whitespace processing self.assertEqual(complex('\N{EM SPACE}(\N{EN SPACE}1+1j ) '), 1+1j) # Invalid unicode string # See bpo-34087 self.assertRaises(ValueError, complex, '\u3053\u3093\u306b\u3061\u306f') class EvilExc(Exception): pass class evilcomplex: def __complex__(self): raise EvilExc self.assertRaises(EvilExc, complex, evilcomplex()) class float2: def __init__(self, value): self.value = value def __float__(self): return self.value self.assertAlmostEqual(complex(float2(42.)), 42) self.assertAlmostEqual(complex(real=float2(17.), imag=float2(23.)), 17+23j) self.assertRaises(TypeError, complex, float2(None)) class MyIndex: def __init__(self, value): self.value = value def __index__(self): return self.value self.assertAlmostEqual(complex(MyIndex(42)), 42.0+0.0j) self.assertAlmostEqual(complex(123, MyIndex(42)), 123.0+42.0j) self.assertRaises(OverflowError, complex, MyIndex(2**2000)) self.assertRaises(OverflowError, complex, 123, MyIndex(2**2000)) class MyInt: def __int__(self): return 42 self.assertRaises(TypeError, complex, MyInt()) self.assertRaises(TypeError, complex, 123, MyInt()) class complex0(complex): """Test usage of __complex__() when inheriting from 'complex'""" def __complex__(self): return 42j class complex1(complex): """Test usage of __complex__() with a __new__() method""" def __new__(self, value=0j): return complex.__new__(self, 2*value) def __complex__(self): return self class complex2(complex): """Make sure that __complex__() calls fail if anything other than a complex is returned""" def __complex__(self): return None self.assertEqual(complex(complex0(1j)), 42j) with self.assertWarns(DeprecationWarning): self.assertEqual(complex(complex1(1j)), 2j) self.assertRaises(TypeError, complex, complex2(1j)) def test___complex__(self): z = 3 + 4j self.assertEqual(z.__complex__(), z) self.assertEqual(type(z.__complex__()), complex) class complex_subclass(complex): pass z = complex_subclass(3 + 4j) self.assertEqual(z.__complex__(), 3 + 4j) self.assertEqual(type(z.__complex__()), complex) @support.requires_IEEE_754 def test_constructor_special_numbers(self): class complex2(complex): pass for x in 0.0, -0.0, INF, -INF, NAN: for y in 0.0, -0.0, INF, -INF, NAN: with self.subTest(x=x, y=y): z = complex(x, y) self.assertFloatsAreIdentical(z.real, x) self.assertFloatsAreIdentical(z.imag, y) z = complex2(x, y) self.assertIs(type(z), complex2) self.assertFloatsAreIdentical(z.real, x) self.assertFloatsAreIdentical(z.imag, y) z = complex(complex2(x, y)) self.assertIs(type(z), complex) self.assertFloatsAreIdentical(z.real, x) self.assertFloatsAreIdentical(z.imag, y) z = complex2(complex(x, y)) self.assertIs(type(z), complex2) self.assertFloatsAreIdentical(z.real, x) self.assertFloatsAreIdentical(z.imag, y) def test_constructor_negative_nans_from_string(self): self.assertEqual(copysign(1., complex("-nan").real), -1.) self.assertEqual(copysign(1., complex("-nanj").imag), -1.) self.assertEqual(copysign(1., complex("-nan-nanj").real), -1.) self.assertEqual(copysign(1., complex("-nan-nanj").imag), -1.) def test_underscores(self): # check underscores for lit in VALID_UNDERSCORE_LITERALS: if not any(ch in lit for ch in 'xXoObB'): self.assertEqual(complex(lit), eval(lit)) self.assertEqual(complex(lit), complex(lit.replace('_', ''))) for lit in INVALID_UNDERSCORE_LITERALS: if lit in ('0_7', '09_99'): # octals are not recognized here continue if not any(ch in lit for ch in 'xXoObB'): self.assertRaises(ValueError, complex, lit) def test_hash(self): for x in range(-30, 30): self.assertEqual(hash(x), hash(complex(x, 0))) x /= 3.0 # now check against floating point self.assertEqual(hash(x), hash(complex(x, 0.))) self.assertNotEqual(hash(2000005 - 1j), -1) def test_abs(self): nums = [complex(x/3., y/7.) for x in range(-9,9) for y in range(-9,9)] for num in nums: self.assertAlmostEqual((num.real**2 + num.imag**2) ** 0.5, abs(num)) def test_repr_str(self): def test(v, expected, test_fn=self.assertEqual): test_fn(repr(v), expected) test_fn(str(v), expected) test(1+6j, '(1+6j)') test(1-6j, '(1-6j)') test(-(1+0j), '(-1+-0j)', test_fn=self.assertNotEqual) test(complex(1., INF), "(1+infj)") test(complex(1., -INF), "(1-infj)") test(complex(INF, 1), "(inf+1j)") test(complex(-INF, INF), "(-inf+infj)") test(complex(NAN, 1), "(nan+1j)") test(complex(1, NAN), "(1+nanj)") test(complex(NAN, NAN), "(nan+nanj)") test(complex(-NAN, -NAN), "(nan+nanj)") test(complex(0, INF), "infj") test(complex(0, -INF), "-infj") test(complex(0, NAN), "nanj") self.assertEqual(1-6j,complex(repr(1-6j))) self.assertEqual(1+6j,complex(repr(1+6j))) self.assertEqual(-6j,complex(repr(-6j))) self.assertEqual(6j,complex(repr(6j))) @support.requires_IEEE_754 def test_negative_zero_repr_str(self): def test(v, expected, test_fn=self.assertEqual): test_fn(repr(v), expected) test_fn(str(v), expected) test(complex(0., 1.), "1j") test(complex(-0., 1.), "(-0+1j)") test(complex(0., -1.), "-1j") test(complex(-0., -1.), "(-0-1j)") test(complex(0., 0.), "0j") test(complex(0., -0.), "-0j") test(complex(-0., 0.), "(-0+0j)") test(complex(-0., -0.), "(-0-0j)") def test_pos(self): class ComplexSubclass(complex): pass self.assertEqual(+(1+6j), 1+6j) self.assertEqual(+ComplexSubclass(1, 6), 1+6j) self.assertIs(type(+ComplexSubclass(1, 6)), complex) def test_neg(self): self.assertEqual(-(1+6j), -1-6j) def test_getnewargs(self): self.assertEqual((1+2j).__getnewargs__(), (1.0, 2.0)) self.assertEqual((1-2j).__getnewargs__(), (1.0, -2.0)) self.assertEqual((2j).__getnewargs__(), (0.0, 2.0)) self.assertEqual((-0j).__getnewargs__(), (0.0, -0.0)) self.assertEqual(complex(0, INF).__getnewargs__(), (0.0, INF)) self.assertEqual(complex(INF, 0).__getnewargs__(), (INF, 0.0)) @support.requires_IEEE_754 def test_plus_minus_0j(self): # test that -0j and 0j literals are not identified z1, z2 = 0j, -0j self.assertEqual(atan2(z1.imag, -1.), atan2(0., -1.)) self.assertEqual(atan2(z2.imag, -1.), atan2(-0., -1.)) @support.requires_IEEE_754 def test_negated_imaginary_literal(self): z0 = -0j z1 = -7j z2 = -1e1000j # Note: In versions of Python < 3.2, a negated imaginary literal # accidentally ended up with real part 0.0 instead of -0.0, thanks to a # modification during CST -> AST translation (see issue #9011). That's # fixed in Python 3.2. self.assertFloatsAreIdentical(z0.real, -0.0) self.assertFloatsAreIdentical(z0.imag, -0.0) self.assertFloatsAreIdentical(z1.real, -0.0) self.assertFloatsAreIdentical(z1.imag, -7.0) self.assertFloatsAreIdentical(z2.real, -0.0) self.assertFloatsAreIdentical(z2.imag, -INF) @support.requires_IEEE_754 def test_overflow(self): self.assertEqual(complex("1e500"), complex(INF, 0.0)) self.assertEqual(complex("-1e500j"), complex(0.0, -INF)) self.assertEqual(complex("-1e500+1.8e308j"), complex(-INF, INF)) @support.requires_IEEE_754 def test_repr_roundtrip(self): vals = [0.0, 1e-500, 1e-315, 1e-200, 0.0123, 3.1415, 1e50, INF, NAN] vals += [-v for v in vals] # complex(repr(z)) should recover z exactly, even for complex # numbers involving an infinity, nan, or negative zero for x in vals: for y in vals: z = complex(x, y) roundtrip = complex(repr(z)) self.assertFloatsAreIdentical(z.real, roundtrip.real) self.assertFloatsAreIdentical(z.imag, roundtrip.imag) # if we predefine some constants, then eval(repr(z)) should # also work, except that it might change the sign of zeros inf, nan = float('inf'), float('nan') infj, nanj = complex(0.0, inf), complex(0.0, nan) for x in vals: for y in vals: z = complex(x, y) roundtrip = eval(repr(z)) # adding 0.0 has no effect beside changing -0.0 to 0.0 self.assertFloatsAreIdentical(0.0 + z.real, 0.0 + roundtrip.real) self.assertFloatsAreIdentical(0.0 + z.imag, 0.0 + roundtrip.imag) def test_format(self): # empty format string is same as str() self.assertEqual(format(1+3j, ''), str(1+3j)) self.assertEqual(format(1.5+3.5j, ''), str(1.5+3.5j)) self.assertEqual(format(3j, ''), str(3j)) self.assertEqual(format(3.2j, ''), str(3.2j)) self.assertEqual(format(3+0j, ''), str(3+0j)) self.assertEqual(format(3.2+0j, ''), str(3.2+0j)) # empty presentation type should still be analogous to str, # even when format string is nonempty (issue #5920). self.assertEqual(format(3.2+0j, '-'), str(3.2+0j)) self.assertEqual(format(3.2+0j, '<'), str(3.2+0j)) z = 4/7. - 100j/7. self.assertEqual(format(z, ''), str(z)) self.assertEqual(format(z, '-'), str(z)) self.assertEqual(format(z, '<'), str(z)) self.assertEqual(format(z, '10'), str(z)) z = complex(0.0, 3.0) self.assertEqual(format(z, ''), str(z)) self.assertEqual(format(z, '-'), str(z)) self.assertEqual(format(z, '<'), str(z)) self.assertEqual(format(z, '2'), str(z)) z = complex(-0.0, 2.0) self.assertEqual(format(z, ''), str(z)) self.assertEqual(format(z, '-'), str(z)) self.assertEqual(format(z, '<'), str(z)) self.assertEqual(format(z, '3'), str(z)) self.assertEqual(format(1+3j, 'g'), '1+3j') self.assertEqual(format(3j, 'g'), '0+3j') self.assertEqual(format(1.5+3.5j, 'g'), '1.5+3.5j') self.assertEqual(format(1.5+3.5j, '+g'), '+1.5+3.5j') self.assertEqual(format(1.5-3.5j, '+g'), '+1.5-3.5j') self.assertEqual(format(1.5-3.5j, '-g'), '1.5-3.5j') self.assertEqual(format(1.5+3.5j, ' g'), ' 1.5+3.5j') self.assertEqual(format(1.5-3.5j, ' g'), ' 1.5-3.5j') self.assertEqual(format(-1.5+3.5j, ' g'), '-1.5+3.5j') self.assertEqual(format(-1.5-3.5j, ' g'), '-1.5-3.5j') self.assertEqual(format(-1.5-3.5e-20j, 'g'), '-1.5-3.5e-20j') self.assertEqual(format(-1.5-3.5j, 'f'), '-1.500000-3.500000j') self.assertEqual(format(-1.5-3.5j, 'F'), '-1.500000-3.500000j') self.assertEqual(format(-1.5-3.5j, 'e'), '-1.500000e+00-3.500000e+00j') self.assertEqual(format(-1.5-3.5j, '.2e'), '-1.50e+00-3.50e+00j') self.assertEqual(format(-1.5-3.5j, '.2E'), '-1.50E+00-3.50E+00j') self.assertEqual(format(-1.5e10-3.5e5j, '.2G'), '-1.5E+10-3.5E+05j') self.assertEqual(format(1.5+3j, '<20g'), '1.5+3j ') self.assertEqual(format(1.5+3j, '*<20g'), '1.5+3j**************') self.assertEqual(format(1.5+3j, '>20g'), ' 1.5+3j') self.assertEqual(format(1.5+3j, '^20g'), ' 1.5+3j ') self.assertEqual(format(1.5+3j, '<20'), '(1.5+3j) ') self.assertEqual(format(1.5+3j, '>20'), ' (1.5+3j)') self.assertEqual(format(1.5+3j, '^20'), ' (1.5+3j) ') self.assertEqual(format(1.123-3.123j, '^20.2'), ' (1.1-3.1j) ') self.assertEqual(format(1.5+3j, '20.2f'), ' 1.50+3.00j') self.assertEqual(format(1.5+3j, '>20.2f'), ' 1.50+3.00j') self.assertEqual(format(1.5+3j, '<20.2f'), '1.50+3.00j ') self.assertEqual(format(1.5e20+3j, '<20.2f'), '150000000000000000000.00+3.00j') self.assertEqual(format(1.5e20+3j, '>40.2f'), ' 150000000000000000000.00+3.00j') self.assertEqual(format(1.5e20+3j, '^40,.2f'), ' 150,000,000,000,000,000,000.00+3.00j ') self.assertEqual(format(1.5e21+3j, '^40,.2f'), ' 1,500,000,000,000,000,000,000.00+3.00j ') self.assertEqual(format(1.5e21+3000j, ',.2f'), '1,500,000,000,000,000,000,000.00+3,000.00j') # Issue 7094: Alternate formatting (specified by #) self.assertEqual(format(1+1j, '.0e'), '1e+00+1e+00j') self.assertEqual(format(1+1j, '#.0e'), '1.e+00+1.e+00j') self.assertEqual(format(1+1j, '.0f'), '1+1j') self.assertEqual(format(1+1j, '#.0f'), '1.+1.j') self.assertEqual(format(1.1+1.1j, 'g'), '1.1+1.1j') self.assertEqual(format(1.1+1.1j, '#g'), '1.10000+1.10000j') # Alternate doesn't make a difference for these, they format the same with or without it self.assertEqual(format(1+1j, '.1e'), '1.0e+00+1.0e+00j') self.assertEqual(format(1+1j, '#.1e'), '1.0e+00+1.0e+00j') self.assertEqual(format(1+1j, '.1f'), '1.0+1.0j') self.assertEqual(format(1+1j, '#.1f'), '1.0+1.0j') # Misc. other alternate tests self.assertEqual(format((-1.5+0.5j), '#f'), '-1.500000+0.500000j') self.assertEqual(format((-1.5+0.5j), '#.0f'), '-2.+0.j') self.assertEqual(format((-1.5+0.5j), '#e'), '-1.500000e+00+5.000000e-01j') self.assertEqual(format((-1.5+0.5j), '#.0e'), '-2.e+00+5.e-01j') self.assertEqual(format((-1.5+0.5j), '#g'), '-1.50000+0.500000j') self.assertEqual(format((-1.5+0.5j), '.0g'), '-2+0.5j') self.assertEqual(format((-1.5+0.5j), '#.0g'), '-2.+0.5j') # zero padding is invalid self.assertRaises(ValueError, (1.5+0.5j).__format__, '010f') # '=' alignment is invalid self.assertRaises(ValueError, (1.5+3j).__format__, '=20') # integer presentation types are an error for t in 'bcdoxX': self.assertRaises(ValueError, (1.5+0.5j).__format__, t) # make sure everything works in ''.format() self.assertEqual('*{0:.3f}*'.format(3.14159+2.71828j), '*3.142+2.718j*') # issue 3382 self.assertEqual(format(complex(NAN, NAN), 'f'), 'nan+nanj') self.assertEqual(format(complex(1, NAN), 'f'), '1.000000+nanj') self.assertEqual(format(complex(NAN, 1), 'f'), 'nan+1.000000j') self.assertEqual(format(complex(NAN, -1), 'f'), 'nan-1.000000j') self.assertEqual(format(complex(NAN, NAN), 'F'), 'NAN+NANj') self.assertEqual(format(complex(1, NAN), 'F'), '1.000000+NANj') self.assertEqual(format(complex(NAN, 1), 'F'), 'NAN+1.000000j') self.assertEqual(format(complex(NAN, -1), 'F'), 'NAN-1.000000j') self.assertEqual(format(complex(INF, INF), 'f'), 'inf+infj') self.assertEqual(format(complex(1, INF), 'f'), '1.000000+infj') self.assertEqual(format(complex(INF, 1), 'f'), 'inf+1.000000j') self.assertEqual(format(complex(INF, -1), 'f'), 'inf-1.000000j') self.assertEqual(format(complex(INF, INF), 'F'), 'INF+INFj') self.assertEqual(format(complex(1, INF), 'F'), '1.000000+INFj') self.assertEqual(format(complex(INF, 1), 'F'), 'INF+1.000000j') self.assertEqual(format(complex(INF, -1), 'F'), 'INF-1.000000j') if __name__ == "__main__": unittest.main()
Close