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.119.99.38
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_fileinput.py
''' Tests for fileinput module. Nick Mathewson ''' import io import os import sys import re import fileinput import collections import builtins import tempfile import unittest try: import bz2 except ImportError: bz2 = None try: import gzip except ImportError: gzip = None from io import BytesIO, StringIO from fileinput import FileInput, hook_encoded from pathlib import Path from test.support import verbose from test.support.os_helper import TESTFN from test.support.os_helper import unlink as safe_unlink from test.support import os_helper from test import support from unittest import mock # The fileinput module has 2 interfaces: the FileInput class which does # all the work, and a few functions (input, etc.) that use a global _state # variable. class BaseTests: # Write a content (str or bytes) to temp file, and return the # temp file's name. def writeTmp(self, content, *, mode='w'): # opening in text mode is the default fd, name = tempfile.mkstemp() self.addCleanup(os_helper.unlink, name) encoding = None if "b" in mode else "utf-8" with open(fd, mode, encoding=encoding) as f: f.write(content) return name class LineReader: def __init__(self): self._linesread = [] @property def linesread(self): try: return self._linesread[:] finally: self._linesread = [] def openhook(self, filename, mode): self.it = iter(filename.splitlines(True)) return self def readline(self, size=None): line = next(self.it, '') self._linesread.append(line) return line def readlines(self, hint=-1): lines = [] size = 0 while True: line = self.readline() if not line: return lines lines.append(line) size += len(line) if size >= hint: return lines def close(self): pass class BufferSizesTests(BaseTests, unittest.TestCase): def test_buffer_sizes(self): t1 = self.writeTmp(''.join("Line %s of file 1\n" % (i+1) for i in range(15))) t2 = self.writeTmp(''.join("Line %s of file 2\n" % (i+1) for i in range(10))) t3 = self.writeTmp(''.join("Line %s of file 3\n" % (i+1) for i in range(5))) t4 = self.writeTmp(''.join("Line %s of file 4\n" % (i+1) for i in range(1))) pat = re.compile(r'LINE (\d+) OF FILE (\d+)') if verbose: print('1. Simple iteration') fi = FileInput(files=(t1, t2, t3, t4), encoding="utf-8") lines = list(fi) fi.close() self.assertEqual(len(lines), 31) self.assertEqual(lines[4], 'Line 5 of file 1\n') self.assertEqual(lines[30], 'Line 1 of file 4\n') self.assertEqual(fi.lineno(), 31) self.assertEqual(fi.filename(), t4) if verbose: print('2. Status variables') fi = FileInput(files=(t1, t2, t3, t4), encoding="utf-8") s = "x" while s and s != 'Line 6 of file 2\n': s = fi.readline() self.assertEqual(fi.filename(), t2) self.assertEqual(fi.lineno(), 21) self.assertEqual(fi.filelineno(), 6) self.assertFalse(fi.isfirstline()) self.assertFalse(fi.isstdin()) if verbose: print('3. Nextfile') fi.nextfile() self.assertEqual(fi.readline(), 'Line 1 of file 3\n') self.assertEqual(fi.lineno(), 22) fi.close() if verbose: print('4. Stdin') fi = FileInput(files=(t1, t2, t3, t4, '-'), encoding="utf-8") savestdin = sys.stdin try: sys.stdin = StringIO("Line 1 of stdin\nLine 2 of stdin\n") lines = list(fi) self.assertEqual(len(lines), 33) self.assertEqual(lines[32], 'Line 2 of stdin\n') self.assertEqual(fi.filename(), '<stdin>') fi.nextfile() finally: sys.stdin = savestdin if verbose: print('5. Boundary conditions') fi = FileInput(files=(t1, t2, t3, t4), encoding="utf-8") self.assertEqual(fi.lineno(), 0) self.assertEqual(fi.filename(), None) fi.nextfile() self.assertEqual(fi.lineno(), 0) self.assertEqual(fi.filename(), None) if verbose: print('6. Inplace') savestdout = sys.stdout try: fi = FileInput(files=(t1, t2, t3, t4), inplace=1, encoding="utf-8") for line in fi: line = line[:-1].upper() print(line) fi.close() finally: sys.stdout = savestdout fi = FileInput(files=(t1, t2, t3, t4), encoding="utf-8") for line in fi: self.assertEqual(line[-1], '\n') m = pat.match(line[:-1]) self.assertNotEqual(m, None) self.assertEqual(int(m.group(1)), fi.filelineno()) fi.close() class UnconditionallyRaise: def __init__(self, exception_type): self.exception_type = exception_type self.invoked = False def __call__(self, *args, **kwargs): self.invoked = True raise self.exception_type() class FileInputTests(BaseTests, unittest.TestCase): def test_zero_byte_files(self): t1 = self.writeTmp("") t2 = self.writeTmp("") t3 = self.writeTmp("The only line there is.\n") t4 = self.writeTmp("") fi = FileInput(files=(t1, t2, t3, t4), encoding="utf-8") line = fi.readline() self.assertEqual(line, 'The only line there is.\n') self.assertEqual(fi.lineno(), 1) self.assertEqual(fi.filelineno(), 1) self.assertEqual(fi.filename(), t3) line = fi.readline() self.assertFalse(line) self.assertEqual(fi.lineno(), 1) self.assertEqual(fi.filelineno(), 0) self.assertEqual(fi.filename(), t4) fi.close() def test_files_that_dont_end_with_newline(self): t1 = self.writeTmp("A\nB\nC") t2 = self.writeTmp("D\nE\nF") fi = FileInput(files=(t1, t2), encoding="utf-8") lines = list(fi) self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"]) self.assertEqual(fi.filelineno(), 3) self.assertEqual(fi.lineno(), 6) ## def test_unicode_filenames(self): ## # XXX A unicode string is always returned by writeTmp. ## # So is this needed? ## t1 = self.writeTmp("A\nB") ## encoding = sys.getfilesystemencoding() ## if encoding is None: ## encoding = 'ascii' ## fi = FileInput(files=str(t1, encoding), encoding="utf-8") ## lines = list(fi) ## self.assertEqual(lines, ["A\n", "B"]) def test_fileno(self): t1 = self.writeTmp("A\nB") t2 = self.writeTmp("C\nD") fi = FileInput(files=(t1, t2), encoding="utf-8") self.assertEqual(fi.fileno(), -1) line = next(fi) self.assertNotEqual(fi.fileno(), -1) fi.nextfile() self.assertEqual(fi.fileno(), -1) line = list(fi) self.assertEqual(fi.fileno(), -1) def test_invalid_opening_mode(self): for mode in ('w', 'rU', 'U'): with self.subTest(mode=mode): with self.assertRaises(ValueError): FileInput(mode=mode) def test_stdin_binary_mode(self): with mock.patch('sys.stdin') as m_stdin: m_stdin.buffer = BytesIO(b'spam, bacon, sausage, and spam') fi = FileInput(files=['-'], mode='rb') lines = list(fi) self.assertEqual(lines, [b'spam, bacon, sausage, and spam']) def test_detached_stdin_binary_mode(self): orig_stdin = sys.stdin try: sys.stdin = BytesIO(b'spam, bacon, sausage, and spam') self.assertFalse(hasattr(sys.stdin, 'buffer')) fi = FileInput(files=['-'], mode='rb') lines = list(fi) self.assertEqual(lines, [b'spam, bacon, sausage, and spam']) finally: sys.stdin = orig_stdin def test_file_opening_hook(self): try: # cannot use openhook and inplace mode fi = FileInput(inplace=1, openhook=lambda f, m: None) self.fail("FileInput should raise if both inplace " "and openhook arguments are given") except ValueError: pass try: fi = FileInput(openhook=1) self.fail("FileInput should check openhook for being callable") except ValueError: pass class CustomOpenHook: def __init__(self): self.invoked = False def __call__(self, *args, **kargs): self.invoked = True return open(*args, encoding="utf-8") t = self.writeTmp("\n") custom_open_hook = CustomOpenHook() with FileInput([t], openhook=custom_open_hook) as fi: fi.readline() self.assertTrue(custom_open_hook.invoked, "openhook not invoked") def test_readline(self): with open(TESTFN, 'wb') as f: f.write(b'A\nB\r\nC\r') # Fill TextIOWrapper buffer. f.write(b'123456789\n' * 1000) # Issue #20501: readline() shouldn't read whole file. f.write(b'\x80') self.addCleanup(safe_unlink, TESTFN) with FileInput(files=TESTFN, openhook=hook_encoded('ascii')) as fi: try: self.assertEqual(fi.readline(), 'A\n') self.assertEqual(fi.readline(), 'B\n') self.assertEqual(fi.readline(), 'C\n') except UnicodeDecodeError: self.fail('Read to end of file') with self.assertRaises(UnicodeDecodeError): # Read to the end of file. list(fi) self.assertEqual(fi.readline(), '') self.assertEqual(fi.readline(), '') def test_readline_binary_mode(self): with open(TESTFN, 'wb') as f: f.write(b'A\nB\r\nC\rD') self.addCleanup(safe_unlink, TESTFN) with FileInput(files=TESTFN, mode='rb') as fi: self.assertEqual(fi.readline(), b'A\n') self.assertEqual(fi.readline(), b'B\r\n') self.assertEqual(fi.readline(), b'C\rD') # Read to the end of file. self.assertEqual(fi.readline(), b'') self.assertEqual(fi.readline(), b'') def test_inplace_binary_write_mode(self): temp_file = self.writeTmp(b'Initial text.', mode='wb') with FileInput(temp_file, mode='rb', inplace=True) as fobj: line = fobj.readline() self.assertEqual(line, b'Initial text.') # print() cannot be used with files opened in binary mode. sys.stdout.write(b'New line.') with open(temp_file, 'rb') as f: self.assertEqual(f.read(), b'New line.') def test_inplace_encoding_errors(self): temp_file = self.writeTmp(b'Initial text \x88', mode='wb') with FileInput(temp_file, inplace=True, encoding="ascii", errors="replace") as fobj: line = fobj.readline() self.assertEqual(line, 'Initial text \ufffd') print("New line \x88") with open(temp_file, 'rb') as f: self.assertEqual(f.read().rstrip(b'\r\n'), b'New line ?') def test_file_hook_backward_compatibility(self): def old_hook(filename, mode): return io.StringIO("I used to receive only filename and mode") t = self.writeTmp("\n") with FileInput([t], openhook=old_hook) as fi: result = fi.readline() self.assertEqual(result, "I used to receive only filename and mode") def test_context_manager(self): t1 = self.writeTmp("A\nB\nC") t2 = self.writeTmp("D\nE\nF") with FileInput(files=(t1, t2), encoding="utf-8") as fi: lines = list(fi) self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"]) self.assertEqual(fi.filelineno(), 3) self.assertEqual(fi.lineno(), 6) self.assertEqual(fi._files, ()) def test_close_on_exception(self): t1 = self.writeTmp("") try: with FileInput(files=t1, encoding="utf-8") as fi: raise OSError except OSError: self.assertEqual(fi._files, ()) def test_empty_files_list_specified_to_constructor(self): with FileInput(files=[], encoding="utf-8") as fi: self.assertEqual(fi._files, ('-',)) def test_nextfile_oserror_deleting_backup(self): """Tests invoking FileInput.nextfile() when the attempt to delete the backup file would raise OSError. This error is expected to be silently ignored""" os_unlink_orig = os.unlink os_unlink_replacement = UnconditionallyRaise(OSError) try: t = self.writeTmp("\n") self.addCleanup(safe_unlink, t + '.bak') with FileInput(files=[t], inplace=True, encoding="utf-8") as fi: next(fi) # make sure the file is opened os.unlink = os_unlink_replacement fi.nextfile() finally: os.unlink = os_unlink_orig # sanity check to make sure that our test scenario was actually hit self.assertTrue(os_unlink_replacement.invoked, "os.unlink() was not invoked") def test_readline_os_fstat_raises_OSError(self): """Tests invoking FileInput.readline() when os.fstat() raises OSError. This exception should be silently discarded.""" os_fstat_orig = os.fstat os_fstat_replacement = UnconditionallyRaise(OSError) try: t = self.writeTmp("\n") with FileInput(files=[t], inplace=True, encoding="utf-8") as fi: os.fstat = os_fstat_replacement fi.readline() finally: os.fstat = os_fstat_orig # sanity check to make sure that our test scenario was actually hit self.assertTrue(os_fstat_replacement.invoked, "os.fstat() was not invoked") def test_readline_os_chmod_raises_OSError(self): """Tests invoking FileInput.readline() when os.chmod() raises OSError. This exception should be silently discarded.""" os_chmod_orig = os.chmod os_chmod_replacement = UnconditionallyRaise(OSError) try: t = self.writeTmp("\n") with FileInput(files=[t], inplace=True, encoding="utf-8") as fi: os.chmod = os_chmod_replacement fi.readline() finally: os.chmod = os_chmod_orig # sanity check to make sure that our test scenario was actually hit self.assertTrue(os_chmod_replacement.invoked, "os.fstat() was not invoked") def test_fileno_when_ValueError_raised(self): class FilenoRaisesValueError(UnconditionallyRaise): def __init__(self): UnconditionallyRaise.__init__(self, ValueError) def fileno(self): self.__call__() unconditionally_raise_ValueError = FilenoRaisesValueError() t = self.writeTmp("\n") with FileInput(files=[t], encoding="utf-8") as fi: file_backup = fi._file try: fi._file = unconditionally_raise_ValueError result = fi.fileno() finally: fi._file = file_backup # make sure the file gets cleaned up # sanity check to make sure that our test scenario was actually hit self.assertTrue(unconditionally_raise_ValueError.invoked, "_file.fileno() was not invoked") self.assertEqual(result, -1, "fileno() should return -1") def test_readline_buffering(self): src = LineReader() with FileInput(files=['line1\nline2', 'line3\n'], openhook=src.openhook) as fi: self.assertEqual(src.linesread, []) self.assertEqual(fi.readline(), 'line1\n') self.assertEqual(src.linesread, ['line1\n']) self.assertEqual(fi.readline(), 'line2') self.assertEqual(src.linesread, ['line2']) self.assertEqual(fi.readline(), 'line3\n') self.assertEqual(src.linesread, ['', 'line3\n']) self.assertEqual(fi.readline(), '') self.assertEqual(src.linesread, ['']) self.assertEqual(fi.readline(), '') self.assertEqual(src.linesread, []) def test_iteration_buffering(self): src = LineReader() with FileInput(files=['line1\nline2', 'line3\n'], openhook=src.openhook) as fi: self.assertEqual(src.linesread, []) self.assertEqual(next(fi), 'line1\n') self.assertEqual(src.linesread, ['line1\n']) self.assertEqual(next(fi), 'line2') self.assertEqual(src.linesread, ['line2']) self.assertEqual(next(fi), 'line3\n') self.assertEqual(src.linesread, ['', 'line3\n']) self.assertRaises(StopIteration, next, fi) self.assertEqual(src.linesread, ['']) self.assertRaises(StopIteration, next, fi) self.assertEqual(src.linesread, []) def test_pathlib_file(self): t1 = Path(self.writeTmp("Pathlib file.")) with FileInput(t1, encoding="utf-8") as fi: line = fi.readline() self.assertEqual(line, 'Pathlib file.') self.assertEqual(fi.lineno(), 1) self.assertEqual(fi.filelineno(), 1) self.assertEqual(fi.filename(), os.fspath(t1)) def test_pathlib_file_inplace(self): t1 = Path(self.writeTmp('Pathlib file.')) with FileInput(t1, inplace=True, encoding="utf-8") as fi: line = fi.readline() self.assertEqual(line, 'Pathlib file.') print('Modified %s' % line) with open(t1, encoding="utf-8") as f: self.assertEqual(f.read(), 'Modified Pathlib file.\n') class MockFileInput: """A class that mocks out fileinput.FileInput for use during unit tests""" def __init__(self, files=None, inplace=False, backup="", *, mode="r", openhook=None, encoding=None, errors=None): self.files = files self.inplace = inplace self.backup = backup self.mode = mode self.openhook = openhook self.encoding = encoding self.errors = errors self._file = None self.invocation_counts = collections.defaultdict(lambda: 0) self.return_values = {} def close(self): self.invocation_counts["close"] += 1 def nextfile(self): self.invocation_counts["nextfile"] += 1 return self.return_values["nextfile"] def filename(self): self.invocation_counts["filename"] += 1 return self.return_values["filename"] def lineno(self): self.invocation_counts["lineno"] += 1 return self.return_values["lineno"] def filelineno(self): self.invocation_counts["filelineno"] += 1 return self.return_values["filelineno"] def fileno(self): self.invocation_counts["fileno"] += 1 return self.return_values["fileno"] def isfirstline(self): self.invocation_counts["isfirstline"] += 1 return self.return_values["isfirstline"] def isstdin(self): self.invocation_counts["isstdin"] += 1 return self.return_values["isstdin"] class BaseFileInputGlobalMethodsTest(unittest.TestCase): """Base class for unit tests for the global function of the fileinput module.""" def setUp(self): self._orig_state = fileinput._state self._orig_FileInput = fileinput.FileInput fileinput.FileInput = MockFileInput def tearDown(self): fileinput.FileInput = self._orig_FileInput fileinput._state = self._orig_state def assertExactlyOneInvocation(self, mock_file_input, method_name): # assert that the method with the given name was invoked once actual_count = mock_file_input.invocation_counts[method_name] self.assertEqual(actual_count, 1, method_name) # assert that no other unexpected methods were invoked actual_total_count = len(mock_file_input.invocation_counts) self.assertEqual(actual_total_count, 1) class Test_fileinput_input(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.input()""" def test_state_is_not_None_and_state_file_is_not_None(self): """Tests invoking fileinput.input() when fileinput._state is not None and its _file attribute is also not None. Expect RuntimeError to be raised with a meaningful error message and for fileinput._state to *not* be modified.""" instance = MockFileInput() instance._file = object() fileinput._state = instance with self.assertRaises(RuntimeError) as cm: fileinput.input() self.assertEqual(("input() already active",), cm.exception.args) self.assertIs(instance, fileinput._state, "fileinput._state") def test_state_is_not_None_and_state_file_is_None(self): """Tests invoking fileinput.input() when fileinput._state is not None but its _file attribute *is* None. Expect it to create and return a new fileinput.FileInput object with all method parameters passed explicitly to the __init__() method; also ensure that fileinput._state is set to the returned instance.""" instance = MockFileInput() instance._file = None fileinput._state = instance self.do_test_call_input() def test_state_is_None(self): """Tests invoking fileinput.input() when fileinput._state is None Expect it to create and return a new fileinput.FileInput object with all method parameters passed explicitly to the __init__() method; also ensure that fileinput._state is set to the returned instance.""" fileinput._state = None self.do_test_call_input() def do_test_call_input(self): """Tests that fileinput.input() creates a new fileinput.FileInput object, passing the given parameters unmodified to fileinput.FileInput.__init__(). Note that this test depends on the monkey patching of fileinput.FileInput done by setUp().""" files = object() inplace = object() backup = object() mode = object() openhook = object() encoding = object() # call fileinput.input() with different values for each argument result = fileinput.input(files=files, inplace=inplace, backup=backup, mode=mode, openhook=openhook, encoding=encoding) # ensure fileinput._state was set to the returned object self.assertIs(result, fileinput._state, "fileinput._state") # ensure the parameters to fileinput.input() were passed directly # to FileInput.__init__() self.assertIs(files, result.files, "files") self.assertIs(inplace, result.inplace, "inplace") self.assertIs(backup, result.backup, "backup") self.assertIs(mode, result.mode, "mode") self.assertIs(openhook, result.openhook, "openhook") class Test_fileinput_close(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.close()""" def test_state_is_None(self): """Tests that fileinput.close() does nothing if fileinput._state is None""" fileinput._state = None fileinput.close() self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests that fileinput.close() invokes close() on fileinput._state and sets _state=None""" instance = MockFileInput() fileinput._state = instance fileinput.close() self.assertExactlyOneInvocation(instance, "close") self.assertIsNone(fileinput._state) class Test_fileinput_nextfile(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.nextfile()""" def test_state_is_None(self): """Tests fileinput.nextfile() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.nextfile() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.nextfile() when fileinput._state is not None. Ensure that it invokes fileinput._state.nextfile() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" nextfile_retval = object() instance = MockFileInput() instance.return_values["nextfile"] = nextfile_retval fileinput._state = instance retval = fileinput.nextfile() self.assertExactlyOneInvocation(instance, "nextfile") self.assertIs(retval, nextfile_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_filename(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.filename()""" def test_state_is_None(self): """Tests fileinput.filename() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.filename() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.filename() when fileinput._state is not None. Ensure that it invokes fileinput._state.filename() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" filename_retval = object() instance = MockFileInput() instance.return_values["filename"] = filename_retval fileinput._state = instance retval = fileinput.filename() self.assertExactlyOneInvocation(instance, "filename") self.assertIs(retval, filename_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_lineno(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.lineno()""" def test_state_is_None(self): """Tests fileinput.lineno() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.lineno() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.lineno() when fileinput._state is not None. Ensure that it invokes fileinput._state.lineno() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" lineno_retval = object() instance = MockFileInput() instance.return_values["lineno"] = lineno_retval fileinput._state = instance retval = fileinput.lineno() self.assertExactlyOneInvocation(instance, "lineno") self.assertIs(retval, lineno_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_filelineno(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.filelineno()""" def test_state_is_None(self): """Tests fileinput.filelineno() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.filelineno() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.filelineno() when fileinput._state is not None. Ensure that it invokes fileinput._state.filelineno() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" filelineno_retval = object() instance = MockFileInput() instance.return_values["filelineno"] = filelineno_retval fileinput._state = instance retval = fileinput.filelineno() self.assertExactlyOneInvocation(instance, "filelineno") self.assertIs(retval, filelineno_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_fileno(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.fileno()""" def test_state_is_None(self): """Tests fileinput.fileno() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.fileno() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.fileno() when fileinput._state is not None. Ensure that it invokes fileinput._state.fileno() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" fileno_retval = object() instance = MockFileInput() instance.return_values["fileno"] = fileno_retval instance.fileno_retval = fileno_retval fileinput._state = instance retval = fileinput.fileno() self.assertExactlyOneInvocation(instance, "fileno") self.assertIs(retval, fileno_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_isfirstline(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.isfirstline()""" def test_state_is_None(self): """Tests fileinput.isfirstline() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.isfirstline() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.isfirstline() when fileinput._state is not None. Ensure that it invokes fileinput._state.isfirstline() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" isfirstline_retval = object() instance = MockFileInput() instance.return_values["isfirstline"] = isfirstline_retval fileinput._state = instance retval = fileinput.isfirstline() self.assertExactlyOneInvocation(instance, "isfirstline") self.assertIs(retval, isfirstline_retval) self.assertIs(fileinput._state, instance) class Test_fileinput_isstdin(BaseFileInputGlobalMethodsTest): """Unit tests for fileinput.isstdin()""" def test_state_is_None(self): """Tests fileinput.isstdin() when fileinput._state is None. Ensure that it raises RuntimeError with a meaningful error message and does not modify fileinput._state""" fileinput._state = None with self.assertRaises(RuntimeError) as cm: fileinput.isstdin() self.assertEqual(("no active input()",), cm.exception.args) self.assertIsNone(fileinput._state) def test_state_is_not_None(self): """Tests fileinput.isstdin() when fileinput._state is not None. Ensure that it invokes fileinput._state.isstdin() exactly once, returns whatever it returns, and does not modify fileinput._state to point to a different object.""" isstdin_retval = object() instance = MockFileInput() instance.return_values["isstdin"] = isstdin_retval fileinput._state = instance retval = fileinput.isstdin() self.assertExactlyOneInvocation(instance, "isstdin") self.assertIs(retval, isstdin_retval) self.assertIs(fileinput._state, instance) class InvocationRecorder: def __init__(self): self.invocation_count = 0 def __call__(self, *args, **kwargs): self.invocation_count += 1 self.last_invocation = (args, kwargs) return io.BytesIO(b'some bytes') class Test_hook_compressed(unittest.TestCase): """Unit tests for fileinput.hook_compressed()""" def setUp(self): self.fake_open = InvocationRecorder() def test_empty_string(self): self.do_test_use_builtin_open_text("", "r") def test_no_ext(self): self.do_test_use_builtin_open_text("abcd", "r") @unittest.skipUnless(gzip, "Requires gzip and zlib") def test_gz_ext_fake(self): original_open = gzip.open gzip.open = self.fake_open try: result = fileinput.hook_compressed("test.gz", "r") finally: gzip.open = original_open self.assertEqual(self.fake_open.invocation_count, 1) self.assertEqual(self.fake_open.last_invocation, (("test.gz", "r"), {})) @unittest.skipUnless(gzip, "Requires gzip and zlib") def test_gz_with_encoding_fake(self): original_open = gzip.open gzip.open = lambda filename, mode: io.BytesIO(b'Ex-binary string') try: result = fileinput.hook_compressed("test.gz", "r", encoding="utf-8") finally: gzip.open = original_open self.assertEqual(list(result), ['Ex-binary string']) @unittest.skipUnless(bz2, "Requires bz2") def test_bz2_ext_fake(self): original_open = bz2.BZ2File bz2.BZ2File = self.fake_open try: result = fileinput.hook_compressed("test.bz2", "r") finally: bz2.BZ2File = original_open self.assertEqual(self.fake_open.invocation_count, 1) self.assertEqual(self.fake_open.last_invocation, (("test.bz2", "r"), {})) def test_blah_ext(self): self.do_test_use_builtin_open_binary("abcd.blah", "rb") def test_gz_ext_builtin(self): self.do_test_use_builtin_open_binary("abcd.Gz", "rb") def test_bz2_ext_builtin(self): self.do_test_use_builtin_open_binary("abcd.Bz2", "rb") def test_binary_mode_encoding(self): self.do_test_use_builtin_open_binary("abcd", "rb") def test_text_mode_encoding(self): self.do_test_use_builtin_open_text("abcd", "r") def do_test_use_builtin_open_binary(self, filename, mode): original_open = self.replace_builtin_open(self.fake_open) try: result = fileinput.hook_compressed(filename, mode) finally: self.replace_builtin_open(original_open) self.assertEqual(self.fake_open.invocation_count, 1) self.assertEqual(self.fake_open.last_invocation, ((filename, mode), {'encoding': None, 'errors': None})) def do_test_use_builtin_open_text(self, filename, mode): original_open = self.replace_builtin_open(self.fake_open) try: result = fileinput.hook_compressed(filename, mode) finally: self.replace_builtin_open(original_open) self.assertEqual(self.fake_open.invocation_count, 1) self.assertEqual(self.fake_open.last_invocation, ((filename, mode), {'encoding': 'locale', 'errors': None})) @staticmethod def replace_builtin_open(new_open_func): original_open = builtins.open builtins.open = new_open_func return original_open class Test_hook_encoded(unittest.TestCase): """Unit tests for fileinput.hook_encoded()""" def test(self): encoding = object() errors = object() result = fileinput.hook_encoded(encoding, errors=errors) fake_open = InvocationRecorder() original_open = builtins.open builtins.open = fake_open try: filename = object() mode = object() open_result = result(filename, mode) finally: builtins.open = original_open self.assertEqual(fake_open.invocation_count, 1) args, kwargs = fake_open.last_invocation self.assertIs(args[0], filename) self.assertIs(args[1], mode) self.assertIs(kwargs.pop('encoding'), encoding) self.assertIs(kwargs.pop('errors'), errors) self.assertFalse(kwargs) def test_errors(self): with open(TESTFN, 'wb') as f: f.write(b'\x80abc') self.addCleanup(safe_unlink, TESTFN) def check(errors, expected_lines): with FileInput(files=TESTFN, mode='r', openhook=hook_encoded('utf-8', errors=errors)) as fi: lines = list(fi) self.assertEqual(lines, expected_lines) check('ignore', ['abc']) with self.assertRaises(UnicodeDecodeError): check('strict', ['abc']) check('replace', ['\ufffdabc']) check('backslashreplace', ['\\x80abc']) def test_modes(self): with open(TESTFN, 'wb') as f: # UTF-7 is a convenient, seldom used encoding f.write(b'A\nB\r\nC\rD+IKw-') self.addCleanup(safe_unlink, TESTFN) def check(mode, expected_lines): with FileInput(files=TESTFN, mode=mode, openhook=hook_encoded('utf-7')) as fi: lines = list(fi) self.assertEqual(lines, expected_lines) check('r', ['A\n', 'B\n', 'C\n', 'D\u20ac']) with self.assertRaises(ValueError): check('rb', ['A\n', 'B\r\n', 'C\r', 'D\u20ac']) class MiscTest(unittest.TestCase): def test_all(self): support.check__all__(self, fileinput) if __name__ == "__main__": unittest.main()
Close