Linux server1.dn-server.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
LiteSpeed
Server IP : 195.201.204.189 & Your IP : 216.73.216.37
Domains :
Cant Read [ /etc/named.conf ]
User : beriska1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
python34 /
lib64 /
python3.4 /
test /
Delete
Unzip
Name
Size
Permission
Date
Action
__pycache__
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
audiodata
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
capath
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
cjkencodings
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
data
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
decimaltestdata
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
encoded_modules
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
imghdrdata
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
sndhdrdata
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
subprocessdata
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
support
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
test_asyncio
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
test_email
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
test_importlib
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
test_json
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
tracedmodules
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
xmltestdata
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
185test.db
16
KB
-rw-r--r--
2019-03-18 20:21
Sine-1000Hz-300ms.aif
60.25
KB
-rw-r--r--
2019-03-18 20:21
__init__.py
47
B
-rw-r--r--
2024-04-17 20:39
__main__.py
55
B
-rw-r--r--
2024-04-17 20:39
_test_multiprocessing.py
120.53
KB
-rw-r--r--
2024-04-17 20:39
audiotests.py
12.13
KB
-rw-r--r--
2024-04-17 20:39
autotest.py
211
B
-rw-r--r--
2024-04-17 20:39
bad_coding.py
24
B
-rw-r--r--
2024-04-17 20:39
bad_coding2.py
30
B
-rw-r--r--
2024-04-17 20:39
badcert.pem
1.88
KB
-rw-r--r--
2019-03-18 20:21
badkey.pem
2.11
KB
-rw-r--r--
2019-03-18 20:21
badsyntax_3131.py
32
B
-rw-r--r--
2024-04-17 20:39
badsyntax_future10.py
95
B
-rw-r--r--
2024-04-17 20:39
badsyntax_future3.py
172
B
-rw-r--r--
2024-04-17 20:39
badsyntax_future4.py
153
B
-rw-r--r--
2024-04-17 20:39
badsyntax_future5.py
184
B
-rw-r--r--
2024-04-17 20:40
badsyntax_future6.py
161
B
-rw-r--r--
2024-04-17 20:39
badsyntax_future7.py
196
B
-rw-r--r--
2024-04-17 20:39
badsyntax_future8.py
122
B
-rw-r--r--
2024-04-17 20:39
badsyntax_future9.py
142
B
-rw-r--r--
2024-04-17 20:39
badsyntax_pep3120.py
14
B
-rw-r--r--
2024-04-17 20:39
buffer_tests.py
11.11
KB
-rw-r--r--
2024-04-17 20:39
bytecode_helper.py
1.57
KB
-rw-r--r--
2024-04-17 20:39
cfgparser.1
21
B
-rw-r--r--
2019-03-18 20:21
cfgparser.2
19.02
KB
-rw-r--r--
2019-03-18 20:21
cfgparser.3
1.55
KB
-rw-r--r--
2019-03-18 20:21
check_soundcard.vbs
411
B
-rw-r--r--
2019-03-18 20:21
cmath_testcases.txt
133.86
KB
-rw-r--r--
2019-03-18 20:21
coding20731.py
18
B
-rw-r--r--
2024-04-17 20:39
curses_tests.py
1.22
KB
-rwxr-xr-x
2024-04-17 20:39
datetimetester.py
150.77
KB
-rw-r--r--
2024-04-17 20:39
dh1024.pem
300
B
-rw-r--r--
2019-03-18 20:21
dis_module.py
76
B
-rw-r--r--
2024-04-17 20:39
doctest_aliases.py
240
B
-rw-r--r--
2024-04-17 20:39
double_const.py
1.18
KB
-rw-r--r--
2024-04-17 20:39
empty.vbs
70
B
-rw-r--r--
2019-03-18 20:21
exception_hierarchy.txt
1.69
KB
-rw-r--r--
2019-03-18 20:21
final_a.py
411
B
-rw-r--r--
2024-04-17 20:39
final_b.py
411
B
-rw-r--r--
2024-04-17 20:39
floating_points.txt
15.92
KB
-rw-r--r--
2019-03-18 20:21
fork_wait.py
2.1
KB
-rw-r--r--
2024-04-17 20:39
formatfloat_testcases.txt
7.45
KB
-rw-r--r--
2019-03-18 20:21
future_test1.py
229
B
-rw-r--r--
2024-04-17 20:39
future_test2.py
149
B
-rw-r--r--
2024-04-17 20:39
gdb_sample.py
153
B
-rw-r--r--
2024-04-17 20:39
ieee754.txt
3.21
KB
-rw-r--r--
2019-03-18 20:21
inspect_fodder.py
854
B
-rw-r--r--
2024-04-17 20:39
inspect_fodder2.py
1.39
KB
-rw-r--r--
2024-04-17 20:39
keycert.passwd.pem
1.79
KB
-rw-r--r--
2019-03-18 20:21
keycert.pem
1.74
KB
-rw-r--r--
2019-03-18 20:21
keycert2.pem
1.75
KB
-rw-r--r--
2019-03-18 20:21
keycert3.pem
3.96
KB
-rw-r--r--
2019-03-18 20:21
keycert4.pem
3.96
KB
-rw-r--r--
2019-03-18 20:21
list_tests.py
17.26
KB
-rw-r--r--
2024-04-17 20:39
lock_tests.py
26.9
KB
-rw-r--r--
2024-04-17 20:39
mailcap.txt
1.24
KB
-rw-r--r--
2019-03-18 20:21
make_ssl_certs.py
5.51
KB
-rw-r--r--
2024-04-17 20:39
mapping_tests.py
21.49
KB
-rw-r--r--
2024-04-17 20:39
math_testcases.txt
23.19
KB
-rw-r--r--
2019-03-18 20:21
memory_watchdog.py
859
B
-rw-r--r--
2024-04-17 20:39
mime.types
47.37
KB
-rw-r--r--
2019-03-18 20:21
mock_socket.py
3.31
KB
-rw-r--r--
2024-04-17 20:39
mp_fork_bomb.py
448
B
-rw-r--r--
2024-04-17 20:39
multibytecodec_support.py
14.44
KB
-rw-r--r--
2024-04-17 20:39
nokia.pem
1.88
KB
-rw-r--r--
2019-03-18 20:21
nullbytecert.pem
5.31
KB
-rw-r--r--
2019-03-18 20:21
nullcert.pem
0
B
-rw-r--r--
2019-03-18 20:21
outstanding_bugs.py
370
B
-rw-r--r--
2024-04-17 20:39
pickletester.py
95.66
KB
-rw-r--r--
2024-04-17 20:39
profilee.py
2.97
KB
-rw-r--r--
2024-04-17 20:39
pstats.pck
65.05
KB
-rw-r--r--
2019-03-18 20:21
pycacert.pem
4.21
KB
-rw-r--r--
2019-03-18 20:21
pycakey.pem
1.66
KB
-rw-r--r--
2019-03-18 20:21
pyclbr_input.py
648
B
-rw-r--r--
2024-04-17 20:39
pydoc_mod.py
708
B
-rw-r--r--
2024-04-17 20:39
pydocfodder.py
6.18
KB
-rw-r--r--
2024-04-17 20:39
pystone.py
7.57
KB
-rwxr-xr-x
2024-04-17 20:39
randv2_32.pck
7.34
KB
-rw-r--r--
2019-03-18 20:21
randv2_64.pck
7.19
KB
-rw-r--r--
2019-03-18 20:21
randv3.pck
7.82
KB
-rw-r--r--
2019-03-18 20:21
re_tests.py
31.06
KB
-rwxr-xr-x
2024-04-17 20:39
regrtest.py
60.32
KB
-rwxr-xr-x
2024-04-17 20:39
relimport.py
27
B
-rw-r--r--
2024-04-17 20:39
reperf.py
538
B
-rw-r--r--
2024-04-17 20:39
revocation.crl
625
B
-rw-r--r--
2019-03-18 20:21
sample_doctest.py
1.02
KB
-rw-r--r--
2024-04-17 20:39
sample_doctest_no_docstrings.py
227
B
-rw-r--r--
2024-04-17 20:39
sample_doctest_no_doctests.py
269
B
-rw-r--r--
2024-04-17 20:39
script_helper.py
8.68
KB
-rw-r--r--
2024-04-17 20:39
selfsigned_pythontestdotnet.pem
956
B
-rw-r--r--
2019-03-18 20:21
seq_tests.py
13.87
KB
-rw-r--r--
2024-04-17 20:39
sgml_input.html
8.1
KB
-rw-r--r--
2019-03-18 20:21
sha256.pem
8.15
KB
-rw-r--r--
2019-03-18 20:21
sortperf.py
4.69
KB
-rw-r--r--
2024-04-17 20:39
ssl_cert.pem
867
B
-rw-r--r--
2019-03-18 20:21
ssl_key.passwd.pem
963
B
-rw-r--r--
2019-03-18 20:21
ssl_key.pem
916
B
-rw-r--r--
2019-03-18 20:21
ssl_servers.py
6.88
KB
-rw-r--r--
2024-04-17 20:39
ssltests.py
640
B
-rw-r--r--
2024-04-17 20:39
string_tests.py
63.25
KB
-rw-r--r--
2024-04-17 20:39
talos-2019-0758.pem
1.3
KB
-rw-r--r--
2019-03-18 20:21
test___all__.py
4.11
KB
-rw-r--r--
2024-04-17 20:39
test___future__.py
2.44
KB
-rw-r--r--
2024-04-17 20:39
test__locale.py
7.72
KB
-rw-r--r--
2024-04-17 20:39
test__opcode.py
908
B
-rw-r--r--
2024-04-17 20:39
test__osx_support.py
11.5
KB
-rw-r--r--
2024-04-17 20:39
test_abc.py
13.33
KB
-rw-r--r--
2024-04-17 20:39
test_abstract_numbers.py
1.49
KB
-rw-r--r--
2024-04-17 20:39
test_aifc.py
15.14
KB
-rw-r--r--
2024-04-17 20:39
test_argparse.py
160.4
KB
-rw-r--r--
2024-04-17 20:39
test_array.py
44.56
KB
-rw-r--r--
2024-04-17 20:39
test_ast.py
42.97
KB
-rw-r--r--
2024-04-17 20:39
test_asynchat.py
10.9
KB
-rw-r--r--
2024-04-17 20:39
test_asyncore.py
26.76
KB
-rw-r--r--
2024-04-17 20:39
test_atexit.py
4.54
KB
-rw-r--r--
2024-04-17 20:39
test_audioop.py
28.05
KB
-rw-r--r--
2024-04-17 20:39
test_augassign.py
7.16
KB
-rw-r--r--
2024-04-17 20:39
test_base64.py
28.9
KB
-rw-r--r--
2024-04-17 20:39
test_bigaddrspace.py
2.92
KB
-rw-r--r--
2024-04-17 20:39
test_bigmem.py
44.18
KB
-rw-r--r--
2024-04-17 20:39
test_binascii.py
10.66
KB
-rw-r--r--
2024-04-17 20:39
test_binhex.py
1.47
KB
-rw-r--r--
2024-04-17 20:39
test_binop.py
12.84
KB
-rw-r--r--
2024-04-17 20:39
test_bisect.py
13.63
KB
-rw-r--r--
2024-04-17 20:39
test_bool.py
11.75
KB
-rw-r--r--
2024-04-17 20:39
test_buffer.py
155.57
KB
-rw-r--r--
2024-04-17 20:39
test_bufio.py
2.54
KB
-rw-r--r--
2024-04-17 20:39
test_builtin.py
58.71
KB
-rw-r--r--
2024-04-17 20:39
test_bytes.py
57.01
KB
-rw-r--r--
2024-04-17 20:39
test_bz2.py
32.29
KB
-rw-r--r--
2024-04-17 20:39
test_calendar.py
42.74
KB
-rw-r--r--
2024-04-17 20:39
test_call.py
3.08
KB
-rw-r--r--
2024-04-17 20:39
test_capi.py
18.04
KB
-rw-r--r--
2024-04-17 20:39
test_cgi.py
18.94
KB
-rw-r--r--
2024-04-17 20:39
test_cgitb.py
2.49
KB
-rw-r--r--
2024-04-17 20:39
test_charmapcodec.py
1.75
KB
-rw-r--r--
2024-04-17 20:39
test_class.py
14.14
KB
-rw-r--r--
2024-04-17 20:40
test_cmath.py
21.47
KB
-rw-r--r--
2024-04-17 20:39
test_cmd.py
6.11
KB
-rw-r--r--
2024-04-17 20:39
test_cmd_line.py
19.91
KB
-rw-r--r--
2024-04-17 20:39
test_cmd_line_script.py
20.21
KB
-rw-r--r--
2024-04-17 20:39
test_code.py
3.54
KB
-rw-r--r--
2024-04-17 20:39
test_code_module.py
2.94
KB
-rw-r--r--
2024-04-17 20:39
test_codeccallbacks.py
37.64
KB
-rw-r--r--
2024-04-17 20:39
test_codecencodings_cn.py
3.38
KB
-rw-r--r--
2024-04-17 20:40
test_codecencodings_hk.py
775
B
-rw-r--r--
2024-04-17 20:39
test_codecencodings_iso2022.py
1.43
KB
-rw-r--r--
2024-04-17 20:39
test_codecencodings_jp.py
4.86
KB
-rw-r--r--
2024-04-17 20:39
test_codecencodings_kr.py
3.03
KB
-rw-r--r--
2024-04-17 20:39
test_codecencodings_tw.py
755
B
-rw-r--r--
2024-04-17 20:39
test_codecmaps_cn.py
771
B
-rw-r--r--
2024-04-17 20:39
test_codecmaps_hk.py
411
B
-rw-r--r--
2024-04-17 20:39
test_codecmaps_jp.py
1.73
KB
-rw-r--r--
2024-04-17 20:39
test_codecmaps_kr.py
1.19
KB
-rw-r--r--
2024-04-17 20:39
test_codecmaps_tw.py
730
B
-rw-r--r--
2024-04-17 20:39
test_codecs.py
114.61
KB
-rw-r--r--
2024-04-17 20:39
test_codeop.py
7.45
KB
-rw-r--r--
2024-04-17 20:39
test_collections.py
50.45
KB
-rw-r--r--
2024-04-17 20:39
test_colorsys.py
3.83
KB
-rw-r--r--
2024-04-17 20:39
test_compare.py
3.9
KB
-rw-r--r--
2024-04-17 20:39
test_compile.py
22.5
KB
-rw-r--r--
2024-04-17 20:39
test_compileall.py
16.65
KB
-rw-r--r--
2024-04-17 20:39
test_complex.py
27.48
KB
-rw-r--r--
2024-04-17 20:39
test_concurrent_futures.py
23.27
KB
-rw-r--r--
2024-04-17 20:39
test_configparser.py
70.43
KB
-rw-r--r--
2024-04-17 20:39
test_contains.py
2.58
KB
-rw-r--r--
2024-04-17 20:39
test_contextlib.py
25.77
KB
-rw-r--r--
2024-04-17 20:39
test_copy.py
22.22
KB
-rw-r--r--
2024-04-17 20:39
test_copyreg.py
4.12
KB
-rw-r--r--
2024-04-17 20:39
test_cprofile.py
5.41
KB
-rw-r--r--
2024-04-17 20:39
test_crashers.py
1.18
KB
-rw-r--r--
2024-04-17 20:39
test_crypt.py
1.06
KB
-rw-r--r--
2024-04-17 20:39
test_csv.py
41.48
KB
-rw-r--r--
2024-04-17 20:39
test_ctypes.py
184
B
-rw-r--r--
2024-04-17 20:39
test_curses.py
12.66
KB
-rw-r--r--
2024-04-17 20:39
test_datetime.py
1.81
KB
-rw-r--r--
2024-04-17 20:39
test_dbm.py
5.52
KB
-rw-r--r--
2024-04-17 20:39
test_dbm_dumb.py
7.07
KB
-rw-r--r--
2024-04-17 20:39
test_dbm_gnu.py
3.28
KB
-rw-r--r--
2024-04-17 20:39
test_dbm_ndbm.py
1.58
KB
-rw-r--r--
2024-04-17 20:39
test_decimal.py
198.92
KB
-rw-r--r--
2024-04-17 20:39
test_decorators.py
9.6
KB
-rw-r--r--
2024-04-17 20:39
test_defaultdict.py
5.94
KB
-rw-r--r--
2024-04-17 20:39
test_deque.py
25.26
KB
-rw-r--r--
2024-04-17 20:39
test_descr.py
175.81
KB
-rw-r--r--
2024-04-17 20:39
test_descrtut.py
11.5
KB
-rw-r--r--
2024-04-17 20:39
test_devpoll.py
4.53
KB
-rw-r--r--
2024-04-17 20:39
test_dict.py
32.36
KB
-rw-r--r--
2024-04-17 20:39
test_dictcomps.py
3.69
KB
-rw-r--r--
2024-04-17 20:39
test_dictviews.py
9.46
KB
-rw-r--r--
2024-04-17 20:39
test_difflib.py
11.96
KB
-rw-r--r--
2024-04-17 20:39
test_difflib_expect.html
100.86
KB
-rw-r--r--
2019-03-18 20:21
test_dis.py
40.48
KB
-rw-r--r--
2024-04-17 20:40
test_distutils.py
375
B
-rw-r--r--
2024-04-17 20:39
test_doctest.py
92.94
KB
-rw-r--r--
2024-04-17 20:39
test_doctest.txt
300
B
-rw-r--r--
2019-03-18 20:21
test_doctest2.py
2.3
KB
-rw-r--r--
2024-04-17 20:39
test_doctest2.txt
392
B
-rw-r--r--
2019-03-18 20:21
test_doctest3.txt
82
B
-rw-r--r--
2019-03-18 20:21
test_doctest4.txt
244
B
-rw-r--r--
2019-03-18 20:21
test_docxmlrpc.py
8.32
KB
-rw-r--r--
2024-04-17 20:39
test_dummy_thread.py
6.99
KB
-rw-r--r--
2024-04-17 20:39
test_dummy_threading.py
1.76
KB
-rw-r--r--
2024-04-17 20:39
test_dynamic.py
4.37
KB
-rw-r--r--
2024-04-17 20:39
test_dynamicclassattribute.py
9.67
KB
-rw-r--r--
2024-04-17 20:39
test_ensurepip.py
11.42
KB
-rw-r--r--
2024-04-17 20:39
test_enum.py
56.4
KB
-rw-r--r--
2024-04-17 20:39
test_enumerate.py
8
KB
-rw-r--r--
2024-04-17 20:39
test_eof.py
855
B
-rw-r--r--
2024-04-17 20:39
test_epoll.py
8.67
KB
-rw-r--r--
2024-04-17 20:39
test_errno.py
1.14
KB
-rw-r--r--
2024-04-17 20:39
test_exception_variations.py
3.94
KB
-rw-r--r--
2024-04-17 20:39
test_exceptions.py
36.05
KB
-rw-r--r--
2024-04-17 20:39
test_extcall.py
8.64
KB
-rw-r--r--
2024-04-17 20:39
test_faulthandler.py
21.18
KB
-rw-r--r--
2024-04-17 20:39
test_fcntl.py
5.1
KB
-rw-r--r--
2024-04-17 20:39
test_file.py
11.09
KB
-rw-r--r--
2024-04-17 20:39
test_file_eintr.py
10.09
KB
-rw-r--r--
2024-04-17 20:39
test_filecmp.py
8.69
KB
-rw-r--r--
2024-04-17 20:39
test_fileinput.py
34.13
KB
-rw-r--r--
2024-04-17 20:39
test_fileio.py
15.58
KB
-rw-r--r--
2024-04-17 20:39
test_finalization.py
14.21
KB
-rw-r--r--
2024-04-17 20:39
test_float.py
59.14
KB
-rw-r--r--
2024-04-17 20:39
test_flufl.py
836
B
-rw-r--r--
2024-04-17 20:40
test_fnmatch.py
2.84
KB
-rw-r--r--
2024-04-17 20:39
test_fork1.py
3.69
KB
-rw-r--r--
2024-04-17 20:39
test_format.py
16.82
KB
-rw-r--r--
2024-04-17 20:39
test_fractions.py
24.77
KB
-rw-r--r--
2024-04-17 20:39
test_frame.py
4.42
KB
-rw-r--r--
2024-04-17 20:39
test_ftplib.py
37.37
KB
-rw-r--r--
2024-04-17 20:39
test_funcattrs.py
13.05
KB
-rw-r--r--
2024-04-17 20:39
test_functools.py
59.52
KB
-rw-r--r--
2024-04-17 20:39
test_future.py
4.05
KB
-rw-r--r--
2024-04-17 20:39
test_future3.py
490
B
-rw-r--r--
2024-04-17 20:39
test_future4.py
105
B
-rw-r--r--
2024-04-17 20:39
test_future5.py
510
B
-rw-r--r--
2024-04-17 20:39
test_gc.py
33.03
KB
-rw-r--r--
2024-04-17 20:39
test_gdb.py
36.71
KB
-rw-r--r--
2024-04-17 20:39
test_generators.py
54.27
KB
-rw-r--r--
2024-04-17 20:39
test_genericpath.py
15.84
KB
-rw-r--r--
2024-04-17 20:39
test_genexps.py
7.12
KB
-rw-r--r--
2024-04-17 20:39
test_getargs2.py
23.96
KB
-rw-r--r--
2024-04-17 20:39
test_getopt.py
6.8
KB
-rw-r--r--
2024-04-17 20:39
test_getpass.py
6.29
KB
-rw-r--r--
2024-04-17 20:39
test_gettext.py
22.97
KB
-rw-r--r--
2024-04-17 20:39
test_glob.py
7.49
KB
-rw-r--r--
2024-04-17 20:39
test_global.py
1.25
KB
-rw-r--r--
2024-04-17 20:39
test_grammar.py
33.54
KB
-rw-r--r--
2024-04-17 20:39
test_grp.py
3.18
KB
-rw-r--r--
2024-04-17 20:39
test_gzip.py
21
KB
-rw-r--r--
2024-04-17 20:39
test_hash.py
11.43
KB
-rw-r--r--
2024-04-17 20:39
test_hashlib.py
24.43
KB
-rw-r--r--
2024-04-17 20:39
test_heapq.py
14.14
KB
-rw-r--r--
2024-04-17 20:39
test_hmac.py
20.21
KB
-rw-r--r--
2024-04-17 20:39
test_html.py
4.27
KB
-rw-r--r--
2024-04-17 20:39
test_htmlparser.py
34.04
KB
-rw-r--r--
2024-04-17 20:39
test_http_cookiejar.py
73.57
KB
-rw-r--r--
2024-04-17 20:39
test_http_cookies.py
10.48
KB
-rw-r--r--
2024-04-17 20:39
test_httplib.py
47.04
KB
-rw-r--r--
2024-04-17 20:39
test_httpservers.py
32.38
KB
-rw-r--r--
2024-04-17 20:39
test_idle.py
786
B
-rw-r--r--
2024-04-17 20:39
test_imaplib.py
17.49
KB
-rw-r--r--
2024-04-17 20:39
test_imghdr.py
4.31
KB
-rw-r--r--
2024-04-17 20:39
test_imp.py
19.42
KB
-rw-r--r--
2024-04-17 20:39
test_import.py
39.28
KB
-rw-r--r--
2024-04-17 20:39
test_index.py
8.37
KB
-rw-r--r--
2024-04-17 20:39
test_inspect.py
119.28
KB
-rw-r--r--
2024-04-17 20:39
test_int.py
17.77
KB
-rw-r--r--
2024-04-17 20:39
test_int_literal.py
6.96
KB
-rw-r--r--
2024-04-17 20:39
test_io.py
133.84
KB
-rw-r--r--
2024-04-17 20:39
test_ioctl.py
3.21
KB
-rw-r--r--
2024-04-17 20:39
test_ipaddress.py
74.26
KB
-rw-r--r--
2024-04-17 20:39
test_isinstance.py
9.93
KB
-rw-r--r--
2024-04-17 20:39
test_iter.py
29.43
KB
-rw-r--r--
2024-04-17 20:39
test_iterlen.py
7.12
KB
-rw-r--r--
2024-04-17 20:39
test_itertools.py
87.8
KB
-rw-r--r--
2024-04-17 20:39
test_keyword.py
5.7
KB
-rw-r--r--
2024-04-17 20:39
test_keywordonlyarg.py
7.14
KB
-rw-r--r--
2024-04-17 20:39
test_kqueue.py
8.22
KB
-rw-r--r--
2024-04-17 20:39
test_largefile.py
6.4
KB
-rw-r--r--
2024-04-17 20:39
test_lib2to3.py
101
B
-rw-r--r--
2024-04-17 20:39
test_linecache.py
4.58
KB
-rw-r--r--
2024-04-17 20:39
test_list.py
4.33
KB
-rw-r--r--
2024-04-17 20:39
test_listcomps.py
3.76
KB
-rw-r--r--
2024-04-17 20:39
test_locale.py
20.16
KB
-rw-r--r--
2024-04-17 20:39
test_logging.py
141.36
KB
-rw-r--r--
2024-04-17 20:39
test_long.py
48.02
KB
-rw-r--r--
2024-04-17 20:39
test_longexp.py
308
B
-rw-r--r--
2024-04-17 20:39
test_lzma.py
71.03
KB
-rw-r--r--
2024-04-17 20:40
test_macpath.py
6
KB
-rw-r--r--
2024-04-17 20:39
test_macurl2path.py
1.8
KB
-rw-r--r--
2024-04-17 20:39
test_mailbox.py
90.51
KB
-rw-r--r--
2024-04-17 20:39
test_mailcap.py
9
KB
-rw-r--r--
2024-04-17 20:39
test_marshal.py
17.7
KB
-rw-r--r--
2024-04-17 20:39
test_math.py
45.89
KB
-rw-r--r--
2024-04-17 20:39
test_memoryio.py
28.34
KB
-rw-r--r--
2024-04-17 20:39
test_memoryview.py
16.23
KB
-rw-r--r--
2024-04-17 20:39
test_metaclass.py
6.2
KB
-rw-r--r--
2024-04-17 20:39
test_mimetypes.py
4.18
KB
-rw-r--r--
2024-04-17 20:39
test_minidom.py
63.38
KB
-rw-r--r--
2024-04-17 20:39
test_mmap.py
26.57
KB
-rw-r--r--
2024-04-17 20:39
test_module.py
7.89
KB
-rw-r--r--
2024-04-17 20:39
test_modulefinder.py
8.74
KB
-rw-r--r--
2024-04-17 20:39
test_msilib.py
1.43
KB
-rw-r--r--
2024-04-17 20:39
test_multibytecodec.py
10.07
KB
-rw-r--r--
2024-04-17 20:39
test_multiprocessing_fork.py
174
B
-rw-r--r--
2024-04-17 20:39
test_multiprocessing_forkserver.py
180
B
-rw-r--r--
2024-04-17 20:39
test_multiprocessing_main_handling.py
11.16
KB
-rw-r--r--
2024-04-17 20:39
test_multiprocessing_spawn.py
175
B
-rw-r--r--
2024-04-17 20:39
test_netrc.py
4.5
KB
-rw-r--r--
2024-04-17 20:39
test_nis.py
1.19
KB
-rw-r--r--
2024-04-17 20:39
test_nntplib.py
58.39
KB
-rw-r--r--
2024-04-17 20:39
test_normalization.py
3.15
KB
-rw-r--r--
2024-04-17 20:39
test_ntpath.py
18.09
KB
-rw-r--r--
2024-04-17 20:39
test_numeric_tower.py
7.27
KB
-rw-r--r--
2024-04-17 20:39
test_opcodes.py
2.61
KB
-rw-r--r--
2024-04-17 20:39
test_openpty.py
682
B
-rw-r--r--
2024-04-17 20:39
test_operator.py
18.17
KB
-rw-r--r--
2024-04-17 20:39
test_optparse.py
60.8
KB
-rw-r--r--
2024-04-17 20:39
test_ordered_dict.py
11.98
KB
-rw-r--r--
2024-04-17 20:39
test_os.py
98.21
KB
-rw-r--r--
2024-04-17 20:39
test_ossaudiodev.py
7.05
KB
-rw-r--r--
2024-04-17 20:39
test_osx_env.py
1.31
KB
-rw-r--r--
2024-04-17 20:39
test_parser.py
25.5
KB
-rw-r--r--
2024-04-17 20:39
test_pathlib.py
74.59
KB
-rw-r--r--
2024-04-17 20:39
test_pdb.py
33.25
KB
-rw-r--r--
2024-04-17 20:39
test_peepholer.py
12.8
KB
-rw-r--r--
2024-04-17 20:39
test_pep247.py
2.19
KB
-rw-r--r--
2024-04-17 20:39
test_pep277.py
6.84
KB
-rw-r--r--
2024-04-17 20:39
test_pep292.py
9.58
KB
-rw-r--r--
2024-04-17 20:39
test_pep3120.py
1.24
KB
-rw-r--r--
2024-04-17 20:39
test_pep3131.py
977
B
-rw-r--r--
2024-04-17 20:39
test_pep3151.py
7.31
KB
-rw-r--r--
2024-04-17 20:39
test_pep352.py
6.88
KB
-rw-r--r--
2024-04-17 20:39
test_pep380.py
28.92
KB
-rw-r--r--
2024-04-17 20:39
test_pickle.py
15.36
KB
-rw-r--r--
2024-04-17 20:39
test_pickletools.py
2.37
KB
-rw-r--r--
2024-04-17 20:39
test_pipes.py
6.32
KB
-rw-r--r--
2024-04-17 20:39
test_pkg.py
9.53
KB
-rw-r--r--
2024-04-17 20:39
test_pkgimport.py
2.72
KB
-rw-r--r--
2024-04-17 20:39
test_pkgutil.py
14.4
KB
-rw-r--r--
2024-04-17 20:39
test_platform.py
12.12
KB
-rw-r--r--
2024-04-17 20:39
test_plistlib.py
22.74
KB
-rw-r--r--
2024-04-17 20:39
test_poll.py
6.4
KB
-rw-r--r--
2024-04-17 20:39
test_popen.py
2.03
KB
-rw-r--r--
2024-04-17 20:39
test_poplib.py
15.99
KB
-rw-r--r--
2024-04-17 20:39
test_posix.py
50.82
KB
-rw-r--r--
2024-04-17 20:39
test_posixpath.py
22.97
KB
-rw-r--r--
2024-04-17 20:39
test_pow.py
4.49
KB
-rw-r--r--
2024-04-17 20:39
test_pprint.py
29.85
KB
-rw-r--r--
2024-04-17 20:39
test_print.py
4.16
KB
-rw-r--r--
2024-04-17 20:39
test_profile.py
7.61
KB
-rw-r--r--
2024-04-17 20:39
test_property.py
7.63
KB
-rw-r--r--
2024-04-17 20:39
test_pstats.py
1.26
KB
-rw-r--r--
2024-04-17 20:40
test_pty.py
11.02
KB
-rw-r--r--
2024-04-17 20:39
test_pulldom.py
12.17
KB
-rw-r--r--
2024-04-17 20:39
test_pwd.py
4.13
KB
-rw-r--r--
2024-04-17 20:39
test_py_compile.py
4.95
KB
-rw-r--r--
2024-04-17 20:39
test_pyclbr.py
6.85
KB
-rw-r--r--
2024-04-17 20:39
test_pydoc.py
39.37
KB
-rw-r--r--
2024-04-17 20:39
test_pyexpat.py
27.2
KB
-rw-r--r--
2024-04-17 20:39
test_queue.py
12.84
KB
-rw-r--r--
2024-04-17 20:39
test_quopri.py
7.86
KB
-rw-r--r--
2024-04-17 20:39
test_raise.py
11.08
KB
-rw-r--r--
2024-04-17 20:39
test_random.py
31.32
KB
-rw-r--r--
2024-04-17 20:39
test_range.py
22.9
KB
-rw-r--r--
2024-04-17 20:39
test_re.py
73.16
KB
-rw-r--r--
2024-04-17 20:39
test_readline.py
2.37
KB
-rw-r--r--
2024-04-17 20:40
test_regrtest.py
10.36
KB
-rw-r--r--
2024-04-17 20:39
test_reprlib.py
14.27
KB
-rw-r--r--
2024-04-17 20:39
test_resource.py
6.46
KB
-rw-r--r--
2024-04-17 20:39
test_richcmp.py
10.83
KB
-rw-r--r--
2024-04-17 20:39
test_rlcompleter.py
4.59
KB
-rw-r--r--
2024-04-17 20:39
test_robotparser.py
7.35
KB
-rw-r--r--
2024-04-17 20:39
test_runpy.py
28.64
KB
-rw-r--r--
2024-04-17 20:39
test_sax.py
41.76
KB
-rw-r--r--
2024-04-17 20:39
test_sched.py
6.43
KB
-rw-r--r--
2024-04-17 20:39
test_scope.py
19.76
KB
-rw-r--r--
2024-04-17 20:39
test_script_helper.py
5.02
KB
-rw-r--r--
2024-04-17 20:39
test_select.py
2.68
KB
-rw-r--r--
2024-04-17 20:39
test_selectors.py
14.96
KB
-rw-r--r--
2024-04-17 20:39
test_set.py
62.66
KB
-rw-r--r--
2024-04-17 20:39
test_setcomps.py
3.7
KB
-rw-r--r--
2024-04-17 20:39
test_shelve.py
6.12
KB
-rw-r--r--
2024-04-17 20:39
test_shlex.py
5.77
KB
-rw-r--r--
2024-04-17 20:39
test_shutil.py
72.37
KB
-rw-r--r--
2024-04-17 20:39
test_signal.py
33.08
KB
-rw-r--r--
2024-04-17 20:40
test_site.py
18.81
KB
-rw-r--r--
2024-04-17 20:39
test_slice.py
8.08
KB
-rw-r--r--
2024-04-17 20:39
test_smtpd.py
22.06
KB
-rw-r--r--
2024-04-17 20:39
test_smtplib.py
35.02
KB
-rw-r--r--
2024-04-17 20:39
test_smtpnet.py
2.76
KB
-rw-r--r--
2024-04-17 20:39
test_sndhdr.py
868
B
-rw-r--r--
2024-04-17 20:39
test_socket.py
191.2
KB
-rw-r--r--
2024-04-17 20:39
test_socketserver.py
10.83
KB
-rw-r--r--
2024-04-17 20:39
test_sort.py
8.95
KB
-rw-r--r--
2024-04-17 20:39
test_source_encoding.py
5.14
KB
-rw-r--r--
2024-04-17 20:39
test_spwd.py
2.29
KB
-rw-r--r--
2024-04-17 20:39
test_sqlite.py
893
B
-rw-r--r--
2024-04-17 20:39
test_ssl.py
130.33
KB
-rw-r--r--
2024-04-17 20:39
test_ssl.py.openssl11
129.64
KB
-rw-r--r--
2019-03-18 20:21
test_startfile.py
1.21
KB
-rw-r--r--
2024-04-17 20:39
test_stat.py
6.83
KB
-rw-r--r--
2024-04-17 20:39
test_statistics.py
68.88
KB
-rw-r--r--
2024-04-17 20:39
test_strftime.py
7.42
KB
-rw-r--r--
2024-04-17 20:39
test_string.py
7.69
KB
-rw-r--r--
2024-04-17 20:39
test_stringprep.py
3.12
KB
-rw-r--r--
2024-04-17 20:39
test_strlit.py
8.03
KB
-rw-r--r--
2024-04-17 20:39
test_strptime.py
28.14
KB
-rw-r--r--
2024-04-17 20:39
test_strtod.py
20.11
KB
-rw-r--r--
2024-04-17 20:39
test_struct.py
26.91
KB
-rw-r--r--
2024-04-17 20:39
test_structmembers.py
4.77
KB
-rw-r--r--
2024-04-17 20:39
test_structseq.py
3.95
KB
-rw-r--r--
2024-04-17 20:39
test_subprocess.py
108.35
KB
-rw-r--r--
2024-04-17 20:39
test_sunau.py
4.55
KB
-rw-r--r--
2024-04-17 20:40
test_sundry.py
2.17
KB
-rw-r--r--
2024-04-17 20:39
test_super.py
4.43
KB
-rw-r--r--
2024-04-17 20:39
test_support.py
10.09
KB
-rw-r--r--
2024-04-17 20:39
test_symtable.py
5.82
KB
-rw-r--r--
2024-04-17 20:39
test_syntax.py
17.64
KB
-rw-r--r--
2024-04-17 20:39
test_sys.py
38.82
KB
-rw-r--r--
2024-04-17 20:39
test_sys_setprofile.py
11.09
KB
-rw-r--r--
2024-04-17 20:39
test_sys_settrace.py
24.66
KB
-rw-r--r--
2024-04-17 20:39
test_sysconfig.py
16.42
KB
-rw-r--r--
2024-04-17 20:39
test_syslog.py
1.2
KB
-rw-r--r--
2024-04-17 20:39
test_systemtap.py
8.86
KB
-rw-r--r--
2024-04-17 20:39
test_systemtap.py.systemtap
0
B
-rw-r--r--
2024-04-17 20:35
test_tarfile.py
79.11
KB
-rw-r--r--
2024-04-17 20:39
test_tcl.py
26.92
KB
-rw-r--r--
2024-04-17 20:39
test_telnetlib.py
12.68
KB
-rw-r--r--
2024-04-17 20:39
test_tempfile.py
44.4
KB
-rw-r--r--
2024-04-17 20:39
test_textwrap.py
35.65
KB
-rw-r--r--
2024-04-17 20:39
test_thread.py
8.09
KB
-rw-r--r--
2024-04-17 20:39
test_threaded_import.py
8.25
KB
-rw-r--r--
2024-04-17 20:39
test_threadedtempfile.py
1.89
KB
-rw-r--r--
2024-04-17 20:39
test_threading.py
38.23
KB
-rw-r--r--
2024-04-17 20:39
test_threading_local.py
6.14
KB
-rw-r--r--
2024-04-17 20:39
test_threadsignals.py
9.22
KB
-rw-r--r--
2024-04-17 20:39
test_time.py
29.97
KB
-rw-r--r--
2024-04-17 20:39
test_timeit.py
11.92
KB
-rw-r--r--
2024-04-17 20:39
test_timeout.py
11.11
KB
-rw-r--r--
2024-04-17 20:39
test_tk.py
458
B
-rw-r--r--
2024-04-17 20:39
test_tokenize.py
48.45
KB
-rw-r--r--
2024-04-17 20:39
test_trace.py
14.45
KB
-rw-r--r--
2024-04-17 20:39
test_traceback.py
17.82
KB
-rw-r--r--
2024-04-17 20:39
test_tracemalloc.py
30.24
KB
-rw-r--r--
2024-04-17 20:39
test_ttk_guionly.py
847
B
-rw-r--r--
2024-04-17 20:39
test_ttk_textonly.py
405
B
-rw-r--r--
2024-04-17 20:39
test_tuple.py
6.99
KB
-rw-r--r--
2024-04-17 20:39
test_typechecks.py
2.64
KB
-rw-r--r--
2024-04-17 20:39
test_types.py
42.96
KB
-rw-r--r--
2024-04-17 20:39
test_ucn.py
9.41
KB
-rw-r--r--
2024-04-17 20:39
test_unary.py
1.71
KB
-rw-r--r--
2024-04-17 20:39
test_unicode.py
122.38
KB
-rw-r--r--
2024-04-17 20:39
test_unicode_file.py
5.73
KB
-rw-r--r--
2024-04-17 20:39
test_unicodedata.py
12.06
KB
-rw-r--r--
2024-04-17 20:39
test_unittest.py
286
B
-rw-r--r--
2024-04-17 20:39
test_univnewlines.py
3.83
KB
-rw-r--r--
2024-04-17 20:39
test_unpack.py
2.56
KB
-rw-r--r--
2024-04-17 20:39
test_unpack_ex.py
4.04
KB
-rw-r--r--
2024-04-17 20:39
test_urllib.py
59.03
KB
-rw-r--r--
2024-04-17 20:39
test_urllib2.py
65.68
KB
-rw-r--r--
2024-04-17 20:39
test_urllib2_localnet.py
25.61
KB
-rw-r--r--
2024-04-17 20:39
test_urllib2net.py
11.96
KB
-rw-r--r--
2024-04-17 20:39
test_urllib_response.py
1.69
KB
-rw-r--r--
2024-04-17 20:39
test_urllibnet.py
8.78
KB
-rw-r--r--
2024-04-17 20:39
test_urlparse.py
51.51
KB
-rw-r--r--
2024-04-17 20:39
test_userdict.py
7.71
KB
-rw-r--r--
2024-04-17 20:39
test_userlist.py
1.85
KB
-rw-r--r--
2024-04-17 20:39
test_userstring.py
1.46
KB
-rw-r--r--
2024-04-17 20:39
test_uu.py
7.39
KB
-rw-r--r--
2024-04-17 20:39
test_uuid.py
21.84
KB
-rw-r--r--
2024-04-17 20:39
test_venv.py
16.16
KB
-rw-r--r--
2024-04-17 20:39
test_wait3.py
1.13
KB
-rw-r--r--
2024-04-17 20:39
test_wait4.py
1.11
KB
-rw-r--r--
2024-04-17 20:39
test_warnings.py
37.13
KB
-rw-r--r--
2024-04-17 20:39
test_wave.py
3.93
KB
-rw-r--r--
2024-04-17 20:39
test_weakref.py
62.02
KB
-rw-r--r--
2024-04-17 20:39
test_weakset.py
15.18
KB
-rw-r--r--
2024-04-17 20:39
test_webbrowser.py
5.65
KB
-rw-r--r--
2024-04-17 20:39
test_winreg.py
20.52
KB
-rw-r--r--
2024-04-17 20:39
test_winsound.py
8.86
KB
-rw-r--r--
2024-04-17 20:39
test_with.py
25.85
KB
-rw-r--r--
2024-04-17 20:40
test_wsgiref.py
22.5
KB
-rw-r--r--
2024-04-17 20:39
test_xdrlib.py
2.29
KB
-rw-r--r--
2024-04-17 20:39
test_xml_dom_minicompat.py
4.18
KB
-rw-r--r--
2024-04-17 20:39
test_xml_etree.py
106.56
KB
-rw-r--r--
2024-04-17 20:39
test_xml_etree_c.py
3.99
KB
-rw-r--r--
2024-04-17 20:39
test_xmlrpc.py
42.05
KB
-rw-r--r--
2024-04-17 20:39
test_xmlrpc_net.py
1.03
KB
-rw-r--r--
2024-04-17 20:39
test_zipfile.py
76.19
KB
-rw-r--r--
2024-04-17 20:39
test_zipfile64.py
5.56
KB
-rw-r--r--
2024-04-17 20:39
test_zipimport.py
17.69
KB
-rw-r--r--
2024-04-17 20:40
test_zipimport_support.py
10.45
KB
-rw-r--r--
2024-04-17 20:39
test_zlib.py
26.79
KB
-rw-r--r--
2024-04-17 20:39
testcodec.py
1.02
KB
-rw-r--r--
2024-04-17 20:39
testtar.tar
425
KB
-rw-r--r--
2019-03-18 20:21
tf_inherit_check.py
577
B
-rw-r--r--
2024-04-17 20:39
threaded_import_hangers.py
1.45
KB
-rw-r--r--
2024-04-17 20:39
time_hashlib.py
2.83
KB
-rw-r--r--
2024-04-17 20:39
tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt
444
B
-rw-r--r--
2019-03-18 20:21
tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt
303
B
-rw-r--r--
2019-03-18 20:21
tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt
421
B
-rw-r--r--
2019-03-18 20:21
tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt
327
B
-rw-r--r--
2019-03-18 20:21
tokenize_tests.txt
2.65
KB
-rw-r--r--
2019-03-18 20:21
warning_tests.py
240
B
-rw-r--r--
2024-04-17 20:39
win_console_handler.py
1.38
KB
-rw-r--r--
2024-04-17 20:39
xmltests.py
499
B
-rw-r--r--
2024-04-17 20:39
zip_cp437_header.zip
270
B
-rw-r--r--
2019-03-18 20:21
zipdir.zip
374
B
-rw-r--r--
2019-03-18 20:21
Save
Rename
# regression test for SAX 2.0 # $Id$ from xml.sax import make_parser, ContentHandler, \ SAXException, SAXReaderNotAvailable, SAXParseException import unittest try: make_parser() except SAXReaderNotAvailable: # don't try to test this module if we cannot create a parser raise unittest.SkipTest("no XML parsers available") from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \ XMLFilterBase, prepare_input_source from xml.sax.expatreader import create_parser from xml.sax.handler import feature_namespaces from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl from io import BytesIO, StringIO import codecs import gc import os.path import shutil from test import support from test.support import findfile, run_unittest, TESTFN TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata") TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata") try: TEST_XMLFILE.encode("utf-8") TEST_XMLFILE_OUT.encode("utf-8") except UnicodeEncodeError: raise unittest.SkipTest("filename is not encodable to utf8") supports_nonascii_filenames = True if not os.path.supports_unicode_filenames: try: support.TESTFN_UNICODE.encode(support.TESTFN_ENCODING) except (UnicodeError, TypeError): # Either the file system encoding is None, or the file name # cannot be encoded in the file system encoding. supports_nonascii_filenames = False requires_nonascii_filenames = unittest.skipUnless( supports_nonascii_filenames, 'Requires non-ascii filenames support') ns_uri = "http://www.python.org/xml-ns/saxtest/" class XmlTestBase(unittest.TestCase): def verify_empty_attrs(self, attrs): self.assertRaises(KeyError, attrs.getValue, "attr") self.assertRaises(KeyError, attrs.getValueByQName, "attr") self.assertRaises(KeyError, attrs.getNameByQName, "attr") self.assertRaises(KeyError, attrs.getQNameByName, "attr") self.assertRaises(KeyError, attrs.__getitem__, "attr") self.assertEqual(attrs.getLength(), 0) self.assertEqual(attrs.getNames(), []) self.assertEqual(attrs.getQNames(), []) self.assertEqual(len(attrs), 0) self.assertNotIn("attr", attrs) self.assertEqual(list(attrs.keys()), []) self.assertEqual(attrs.get("attrs"), None) self.assertEqual(attrs.get("attrs", 25), 25) self.assertEqual(list(attrs.items()), []) self.assertEqual(list(attrs.values()), []) def verify_empty_nsattrs(self, attrs): self.assertRaises(KeyError, attrs.getValue, (ns_uri, "attr")) self.assertRaises(KeyError, attrs.getValueByQName, "ns:attr") self.assertRaises(KeyError, attrs.getNameByQName, "ns:attr") self.assertRaises(KeyError, attrs.getQNameByName, (ns_uri, "attr")) self.assertRaises(KeyError, attrs.__getitem__, (ns_uri, "attr")) self.assertEqual(attrs.getLength(), 0) self.assertEqual(attrs.getNames(), []) self.assertEqual(attrs.getQNames(), []) self.assertEqual(len(attrs), 0) self.assertNotIn((ns_uri, "attr"), attrs) self.assertEqual(list(attrs.keys()), []) self.assertEqual(attrs.get((ns_uri, "attr")), None) self.assertEqual(attrs.get((ns_uri, "attr"), 25), 25) self.assertEqual(list(attrs.items()), []) self.assertEqual(list(attrs.values()), []) def verify_attrs_wattr(self, attrs): self.assertEqual(attrs.getLength(), 1) self.assertEqual(attrs.getNames(), ["attr"]) self.assertEqual(attrs.getQNames(), ["attr"]) self.assertEqual(len(attrs), 1) self.assertIn("attr", attrs) self.assertEqual(list(attrs.keys()), ["attr"]) self.assertEqual(attrs.get("attr"), "val") self.assertEqual(attrs.get("attr", 25), "val") self.assertEqual(list(attrs.items()), [("attr", "val")]) self.assertEqual(list(attrs.values()), ["val"]) self.assertEqual(attrs.getValue("attr"), "val") self.assertEqual(attrs.getValueByQName("attr"), "val") self.assertEqual(attrs.getNameByQName("attr"), "attr") self.assertEqual(attrs["attr"], "val") self.assertEqual(attrs.getQNameByName("attr"), "attr") def xml_str(doc, encoding=None): if encoding is None: return doc return '<?xml version="1.0" encoding="%s"?>\n%s' % (encoding, doc) def xml_bytes(doc, encoding, decl_encoding=...): if decl_encoding is ...: decl_encoding = encoding return xml_str(doc, decl_encoding).encode(encoding, 'xmlcharrefreplace') def make_xml_file(doc, encoding, decl_encoding=...): if decl_encoding is ...: decl_encoding = encoding with open(TESTFN, 'w', encoding=encoding, errors='xmlcharrefreplace') as f: f.write(xml_str(doc, decl_encoding)) class ParseTest(unittest.TestCase): data = '<money value="$\xa3\u20ac\U0001017b">$\xa3\u20ac\U0001017b</money>' def tearDown(self): support.unlink(TESTFN) def check_parse(self, f): from xml.sax import parse result = StringIO() parse(f, XMLGenerator(result, 'utf-8')) self.assertEqual(result.getvalue(), xml_str(self.data, 'utf-8')) def test_parse_text(self): encodings = ('us-ascii', 'iso-8859-1', 'utf-8', 'utf-16', 'utf-16le', 'utf-16be') for encoding in encodings: self.check_parse(StringIO(xml_str(self.data, encoding))) make_xml_file(self.data, encoding) with open(TESTFN, 'r', encoding=encoding) as f: self.check_parse(f) self.check_parse(StringIO(self.data)) make_xml_file(self.data, encoding, None) with open(TESTFN, 'r', encoding=encoding) as f: self.check_parse(f) def test_parse_bytes(self): # UTF-8 is default encoding, US-ASCII is compatible with UTF-8, # UTF-16 is autodetected encodings = ('us-ascii', 'utf-8', 'utf-16', 'utf-16le', 'utf-16be') for encoding in encodings: self.check_parse(BytesIO(xml_bytes(self.data, encoding))) make_xml_file(self.data, encoding) self.check_parse(TESTFN) with open(TESTFN, 'rb') as f: self.check_parse(f) self.check_parse(BytesIO(xml_bytes(self.data, encoding, None))) make_xml_file(self.data, encoding, None) self.check_parse(TESTFN) with open(TESTFN, 'rb') as f: self.check_parse(f) # accept UTF-8 with BOM self.check_parse(BytesIO(xml_bytes(self.data, 'utf-8-sig', 'utf-8'))) make_xml_file(self.data, 'utf-8-sig', 'utf-8') self.check_parse(TESTFN) with open(TESTFN, 'rb') as f: self.check_parse(f) self.check_parse(BytesIO(xml_bytes(self.data, 'utf-8-sig', None))) make_xml_file(self.data, 'utf-8-sig', None) self.check_parse(TESTFN) with open(TESTFN, 'rb') as f: self.check_parse(f) # accept data with declared encoding self.check_parse(BytesIO(xml_bytes(self.data, 'iso-8859-1'))) make_xml_file(self.data, 'iso-8859-1') self.check_parse(TESTFN) with open(TESTFN, 'rb') as f: self.check_parse(f) # fail on non-UTF-8 incompatible data without declared encoding with self.assertRaises(SAXException): self.check_parse(BytesIO(xml_bytes(self.data, 'iso-8859-1', None))) make_xml_file(self.data, 'iso-8859-1', None) with support.check_warnings(('unclosed file', ResourceWarning)): # XXX Failed parser leaks an opened file. with self.assertRaises(SAXException): self.check_parse(TESTFN) # Collect leaked file. gc.collect() with open(TESTFN, 'rb') as f: with self.assertRaises(SAXException): self.check_parse(f) def test_parse_InputSource(self): # accept data without declared but with explicitly specified encoding make_xml_file(self.data, 'iso-8859-1', None) with open(TESTFN, 'rb') as f: input = InputSource() input.setByteStream(f) input.setEncoding('iso-8859-1') self.check_parse(input) def check_parseString(self, s): from xml.sax import parseString result = StringIO() parseString(s, XMLGenerator(result, 'utf-8')) self.assertEqual(result.getvalue(), xml_str(self.data, 'utf-8')) def test_parseString_bytes(self): # UTF-8 is default encoding, US-ASCII is compatible with UTF-8, # UTF-16 is autodetected encodings = ('us-ascii', 'utf-8', 'utf-16', 'utf-16le', 'utf-16be') for encoding in encodings: self.check_parseString(xml_bytes(self.data, encoding)) self.check_parseString(xml_bytes(self.data, encoding, None)) # accept UTF-8 with BOM self.check_parseString(xml_bytes(self.data, 'utf-8-sig', 'utf-8')) self.check_parseString(xml_bytes(self.data, 'utf-8-sig', None)) # accept data with declared encoding self.check_parseString(xml_bytes(self.data, 'iso-8859-1')) # fail on non-UTF-8 incompatible data without declared encoding with self.assertRaises(SAXException): self.check_parseString(xml_bytes(self.data, 'iso-8859-1', None)) class MakeParserTest(unittest.TestCase): def test_make_parser2(self): # Creating parsers several times in a row should succeed. # Testing this because there have been failures of this kind # before. from xml.sax import make_parser p = make_parser() from xml.sax import make_parser p = make_parser() from xml.sax import make_parser p = make_parser() from xml.sax import make_parser p = make_parser() from xml.sax import make_parser p = make_parser() from xml.sax import make_parser p = make_parser() # =========================================================================== # # saxutils tests # # =========================================================================== class SaxutilsTest(unittest.TestCase): # ===== escape def test_escape_basic(self): self.assertEqual(escape("Donald Duck & Co"), "Donald Duck & Co") def test_escape_all(self): self.assertEqual(escape("<Donald Duck & Co>"), "<Donald Duck & Co>") def test_escape_extra(self): self.assertEqual(escape("Hei på deg", {"å" : "å"}), "Hei på deg") # ===== unescape def test_unescape_basic(self): self.assertEqual(unescape("Donald Duck & Co"), "Donald Duck & Co") def test_unescape_all(self): self.assertEqual(unescape("<Donald Duck & Co>"), "<Donald Duck & Co>") def test_unescape_extra(self): self.assertEqual(unescape("Hei på deg", {"å" : "å"}), "Hei på deg") def test_unescape_amp_extra(self): self.assertEqual(unescape("&foo;", {"&foo;": "splat"}), "&foo;") # ===== quoteattr def test_quoteattr_basic(self): self.assertEqual(quoteattr("Donald Duck & Co"), '"Donald Duck & Co"') def test_single_quoteattr(self): self.assertEqual(quoteattr('Includes "double" quotes'), '\'Includes "double" quotes\'') def test_double_quoteattr(self): self.assertEqual(quoteattr("Includes 'single' quotes"), "\"Includes 'single' quotes\"") def test_single_double_quoteattr(self): self.assertEqual(quoteattr("Includes 'single' and \"double\" quotes"), "\"Includes 'single' and "double" quotes\"") # ===== make_parser def test_make_parser(self): # Creating a parser should succeed - it should fall back # to the expatreader p = make_parser(['xml.parsers.no_such_parser']) class PrepareInputSourceTest(unittest.TestCase): def setUp(self): self.file = support.TESTFN with open(self.file, "w") as tmp: tmp.write("This was read from a file.") def tearDown(self): support.unlink(self.file) def make_byte_stream(self): return BytesIO(b"This is a byte stream.") def checkContent(self, stream, content): self.assertIsNotNone(stream) self.assertEqual(stream.read(), content) stream.close() def test_byte_stream(self): # If the source is an InputSource that does not have a character # stream but does have a byte stream, use the byte stream. src = InputSource(self.file) src.setByteStream(self.make_byte_stream()) prep = prepare_input_source(src) self.assertIsNone(prep.getCharacterStream()) self.checkContent(prep.getByteStream(), b"This is a byte stream.") def test_system_id(self): # If the source is an InputSource that has neither a character # stream nor a byte stream, open the system ID. src = InputSource(self.file) prep = prepare_input_source(src) self.assertIsNone(prep.getCharacterStream()) self.checkContent(prep.getByteStream(), b"This was read from a file.") def test_string(self): # If the source is a string, use it as a system ID and open it. prep = prepare_input_source(self.file) self.assertIsNone(prep.getCharacterStream()) self.checkContent(prep.getByteStream(), b"This was read from a file.") def test_binary_file(self): # If the source is a binary file-like object, use it as a byte # stream. prep = prepare_input_source(self.make_byte_stream()) self.assertIsNone(prep.getCharacterStream()) self.checkContent(prep.getByteStream(), b"This is a byte stream.") # ===== XMLGenerator class XmlgenTest: def test_xmlgen_basic(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startElement("doc", {}) gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<doc></doc>")) def test_xmlgen_basic_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) gen.startDocument() gen.startElement("doc", {}) gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<doc/>")) def test_xmlgen_content(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startElement("doc", {}) gen.characters("huhei") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<doc>huhei</doc>")) def test_xmlgen_content_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) gen.startDocument() gen.startElement("doc", {}) gen.characters("huhei") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<doc>huhei</doc>")) def test_xmlgen_pi(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.processingInstruction("test", "data") gen.startElement("doc", {}) gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<?test data?><doc></doc>")) def test_xmlgen_content_escape(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startElement("doc", {}) gen.characters("<huhei&") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<doc><huhei&</doc>")) def test_xmlgen_attr_escape(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startElement("doc", {"a": '"'}) gen.startElement("e", {"a": "'"}) gen.endElement("e") gen.startElement("e", {"a": "'\""}) gen.endElement("e") gen.startElement("e", {"a": "\n\r\t"}) gen.endElement("e") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml( "<doc a='\"'><e a=\"'\"></e>" "<e a=\"'"\"></e>" "<e a=\" 	\"></e></doc>")) def test_xmlgen_encoding(self): encodings = ('iso-8859-15', 'utf-8', 'utf-8-sig', 'utf-16', 'utf-16be', 'utf-16le', 'utf-32', 'utf-32be', 'utf-32le') for encoding in encodings: result = self.ioclass() gen = XMLGenerator(result, encoding=encoding) gen.startDocument() gen.startElement("doc", {"a": '\u20ac'}) gen.characters("\u20ac") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<doc a="\u20ac">\u20ac</doc>', encoding=encoding)) def test_xmlgen_unencodable(self): result = self.ioclass() gen = XMLGenerator(result, encoding='ascii') gen.startDocument() gen.startElement("doc", {"a": '\u20ac'}) gen.characters("\u20ac") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<doc a="€">€</doc>', encoding='ascii')) def test_xmlgen_ignorable(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startElement("doc", {}) gen.ignorableWhitespace(" ") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<doc> </doc>")) def test_xmlgen_ignorable_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) gen.startDocument() gen.startElement("doc", {}) gen.ignorableWhitespace(" ") gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml("<doc> </doc>")) def test_xmlgen_encoding_bytes(self): encodings = ('iso-8859-15', 'utf-8', 'utf-8-sig', 'utf-16', 'utf-16be', 'utf-16le', 'utf-32', 'utf-32be', 'utf-32le') for encoding in encodings: result = self.ioclass() gen = XMLGenerator(result, encoding=encoding) gen.startDocument() gen.startElement("doc", {"a": '\u20ac'}) gen.characters("\u20ac".encode(encoding)) gen.ignorableWhitespace(" ".encode(encoding)) gen.endElement("doc") gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<doc a="\u20ac">\u20ac </doc>', encoding=encoding)) def test_xmlgen_ns(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startPrefixMapping("ns1", ns_uri) gen.startElementNS((ns_uri, "doc"), "ns1:doc", {}) # add an unqualified name gen.startElementNS((None, "udoc"), None, {}) gen.endElementNS((None, "udoc"), None) gen.endElementNS((ns_uri, "doc"), "ns1:doc") gen.endPrefixMapping("ns1") gen.endDocument() self.assertEqual(result.getvalue(), self.xml( '<ns1:doc xmlns:ns1="%s"><udoc></udoc></ns1:doc>' % ns_uri)) def test_xmlgen_ns_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) gen.startDocument() gen.startPrefixMapping("ns1", ns_uri) gen.startElementNS((ns_uri, "doc"), "ns1:doc", {}) # add an unqualified name gen.startElementNS((None, "udoc"), None, {}) gen.endElementNS((None, "udoc"), None) gen.endElementNS((ns_uri, "doc"), "ns1:doc") gen.endPrefixMapping("ns1") gen.endDocument() self.assertEqual(result.getvalue(), self.xml( '<ns1:doc xmlns:ns1="%s"><udoc/></ns1:doc>' % ns_uri)) def test_1463026_1(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startElementNS((None, 'a'), 'a', {(None, 'b'):'c'}) gen.endElementNS((None, 'a'), 'a') gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<a b="c"></a>')) def test_1463026_1_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) gen.startDocument() gen.startElementNS((None, 'a'), 'a', {(None, 'b'):'c'}) gen.endElementNS((None, 'a'), 'a') gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<a b="c"/>')) def test_1463026_2(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startPrefixMapping(None, 'qux') gen.startElementNS(('qux', 'a'), 'a', {}) gen.endElementNS(('qux', 'a'), 'a') gen.endPrefixMapping(None) gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<a xmlns="qux"></a>')) def test_1463026_2_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) gen.startDocument() gen.startPrefixMapping(None, 'qux') gen.startElementNS(('qux', 'a'), 'a', {}) gen.endElementNS(('qux', 'a'), 'a') gen.endPrefixMapping(None) gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<a xmlns="qux"/>')) def test_1463026_3(self): result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startPrefixMapping('my', 'qux') gen.startElementNS(('qux', 'a'), 'a', {(None, 'b'):'c'}) gen.endElementNS(('qux', 'a'), 'a') gen.endPrefixMapping('my') gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<my:a xmlns:my="qux" b="c"></my:a>')) def test_1463026_3_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) gen.startDocument() gen.startPrefixMapping('my', 'qux') gen.startElementNS(('qux', 'a'), 'a', {(None, 'b'):'c'}) gen.endElementNS(('qux', 'a'), 'a') gen.endPrefixMapping('my') gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<my:a xmlns:my="qux" b="c"/>')) def test_5027_1(self): # The xml prefix (as in xml:lang below) is reserved and bound by # definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had # a bug whereby a KeyError is raised because this namespace is missing # from a dictionary. # # This test demonstrates the bug by parsing a document. test_xml = StringIO( '<?xml version="1.0"?>' '<a:g1 xmlns:a="http://example.com/ns">' '<a:g2 xml:lang="en">Hello</a:g2>' '</a:g1>') parser = make_parser() parser.setFeature(feature_namespaces, True) result = self.ioclass() gen = XMLGenerator(result) parser.setContentHandler(gen) parser.parse(test_xml) self.assertEqual(result.getvalue(), self.xml( '<a:g1 xmlns:a="http://example.com/ns">' '<a:g2 xml:lang="en">Hello</a:g2>' '</a:g1>')) def test_5027_2(self): # The xml prefix (as in xml:lang below) is reserved and bound by # definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had # a bug whereby a KeyError is raised because this namespace is missing # from a dictionary. # # This test demonstrates the bug by direct manipulation of the # XMLGenerator. result = self.ioclass() gen = XMLGenerator(result) gen.startDocument() gen.startPrefixMapping('a', 'http://example.com/ns') gen.startElementNS(('http://example.com/ns', 'g1'), 'g1', {}) lang_attr = {('http://www.w3.org/XML/1998/namespace', 'lang'): 'en'} gen.startElementNS(('http://example.com/ns', 'g2'), 'g2', lang_attr) gen.characters('Hello') gen.endElementNS(('http://example.com/ns', 'g2'), 'g2') gen.endElementNS(('http://example.com/ns', 'g1'), 'g1') gen.endPrefixMapping('a') gen.endDocument() self.assertEqual(result.getvalue(), self.xml( '<a:g1 xmlns:a="http://example.com/ns">' '<a:g2 xml:lang="en">Hello</a:g2>' '</a:g1>')) def test_no_close_file(self): result = self.ioclass() def func(out): gen = XMLGenerator(out) gen.startDocument() gen.startElement("doc", {}) func(result) self.assertFalse(result.closed) def test_xmlgen_fragment(self): result = self.ioclass() gen = XMLGenerator(result) # Don't call gen.startDocument() gen.startElement("foo", {"a": "1.0"}) gen.characters("Hello") gen.endElement("foo") gen.startElement("bar", {"b": "2.0"}) gen.endElement("bar") # Don't call gen.endDocument() self.assertEqual(result.getvalue(), self.xml('<foo a="1.0">Hello</foo><bar b="2.0"></bar>')[len(self.xml('')):]) class StringXmlgenTest(XmlgenTest, unittest.TestCase): ioclass = StringIO def xml(self, doc, encoding='iso-8859-1'): return '<?xml version="1.0" encoding="%s"?>\n%s' % (encoding, doc) test_xmlgen_unencodable = None class BytesXmlgenTest(XmlgenTest, unittest.TestCase): ioclass = BytesIO def xml(self, doc, encoding='iso-8859-1'): return ('<?xml version="1.0" encoding="%s"?>\n%s' % (encoding, doc)).encode(encoding, 'xmlcharrefreplace') class WriterXmlgenTest(BytesXmlgenTest): class ioclass(list): write = list.append closed = False def seekable(self): return True def tell(self): # return 0 at start and not 0 after start return len(self) def getvalue(self): return b''.join(self) class StreamWriterXmlgenTest(XmlgenTest, unittest.TestCase): def ioclass(self): raw = BytesIO() writer = codecs.getwriter('ascii')(raw, 'xmlcharrefreplace') writer.getvalue = raw.getvalue return writer def xml(self, doc, encoding='iso-8859-1'): return ('<?xml version="1.0" encoding="%s"?>\n%s' % (encoding, doc)).encode('ascii', 'xmlcharrefreplace') class StreamReaderWriterXmlgenTest(XmlgenTest, unittest.TestCase): fname = support.TESTFN + '-codecs' def ioclass(self): writer = codecs.open(self.fname, 'w', encoding='ascii', errors='xmlcharrefreplace', buffering=0) def cleanup(): writer.close() support.unlink(self.fname) self.addCleanup(cleanup) def getvalue(): # Windows will not let use reopen without first closing writer.close() with open(writer.name, 'rb') as f: return f.read() writer.getvalue = getvalue return writer def xml(self, doc, encoding='iso-8859-1'): return ('<?xml version="1.0" encoding="%s"?>\n%s' % (encoding, doc)).encode('ascii', 'xmlcharrefreplace') start = b'<?xml version="1.0" encoding="iso-8859-1"?>\n' class XMLFilterBaseTest(unittest.TestCase): def test_filter_basic(self): result = BytesIO() gen = XMLGenerator(result) filter = XMLFilterBase() filter.setContentHandler(gen) filter.startDocument() filter.startElement("doc", {}) filter.characters("content") filter.ignorableWhitespace(" ") filter.endElement("doc") filter.endDocument() self.assertEqual(result.getvalue(), start + b"<doc>content </doc>") # =========================================================================== # # expatreader tests # # =========================================================================== with open(TEST_XMLFILE_OUT, 'rb') as f: xml_test_out = f.read() class ExpatReaderTest(XmlTestBase): # ===== XMLReader support def test_expat_binary_file(self): parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) with open(TEST_XMLFILE, 'rb') as f: parser.parse(f) self.assertEqual(result.getvalue(), xml_test_out) def test_expat_text_file(self): parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) with open(TEST_XMLFILE, 'rt', encoding='iso-8859-1') as f: parser.parse(f) self.assertEqual(result.getvalue(), xml_test_out) @requires_nonascii_filenames def test_expat_binary_file_nonascii(self): fname = support.TESTFN_UNICODE shutil.copyfile(TEST_XMLFILE, fname) self.addCleanup(support.unlink, fname) parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) parser.parse(open(fname, 'rb')) self.assertEqual(result.getvalue(), xml_test_out) def test_expat_binary_file_bytes_name(self): fname = os.fsencode(TEST_XMLFILE) parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) with open(fname, 'rb') as f: parser.parse(f) self.assertEqual(result.getvalue(), xml_test_out) def test_expat_binary_file_int_name(self): parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) with open(TEST_XMLFILE, 'rb') as f: with open(f.fileno(), 'rb', closefd=False) as f2: parser.parse(f2) self.assertEqual(result.getvalue(), xml_test_out) # ===== DTDHandler support class TestDTDHandler: def __init__(self): self._notations = [] self._entities = [] def notationDecl(self, name, publicId, systemId): self._notations.append((name, publicId, systemId)) def unparsedEntityDecl(self, name, publicId, systemId, ndata): self._entities.append((name, publicId, systemId, ndata)) def test_expat_dtdhandler(self): parser = create_parser() handler = self.TestDTDHandler() parser.setDTDHandler(handler) parser.feed('<!DOCTYPE doc [\n') parser.feed(' <!ENTITY img SYSTEM "expat.gif" NDATA GIF>\n') parser.feed(' <!NOTATION GIF PUBLIC "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN">\n') parser.feed(']>\n') parser.feed('<doc></doc>') parser.close() self.assertEqual(handler._notations, [("GIF", "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN", None)]) self.assertEqual(handler._entities, [("img", None, "expat.gif", "GIF")]) # ===== EntityResolver support class TestEntityResolver: def resolveEntity(self, publicId, systemId): inpsrc = InputSource() inpsrc.setByteStream(BytesIO(b"<entity/>")) return inpsrc def test_expat_entityresolver(self): parser = create_parser() parser.setEntityResolver(self.TestEntityResolver()) result = BytesIO() parser.setContentHandler(XMLGenerator(result)) parser.feed('<!DOCTYPE doc [\n') parser.feed(' <!ENTITY test SYSTEM "whatever">\n') parser.feed(']>\n') parser.feed('<doc>&test;</doc>') parser.close() self.assertEqual(result.getvalue(), start + b"<doc><entity></entity></doc>") # ===== Attributes support class AttrGatherer(ContentHandler): def startElement(self, name, attrs): self._attrs = attrs def startElementNS(self, name, qname, attrs): self._attrs = attrs def test_expat_attrs_empty(self): parser = create_parser() gather = self.AttrGatherer() parser.setContentHandler(gather) parser.feed("<doc/>") parser.close() self.verify_empty_attrs(gather._attrs) def test_expat_attrs_wattr(self): parser = create_parser() gather = self.AttrGatherer() parser.setContentHandler(gather) parser.feed("<doc attr='val'/>") parser.close() self.verify_attrs_wattr(gather._attrs) def test_expat_nsattrs_empty(self): parser = create_parser(1) gather = self.AttrGatherer() parser.setContentHandler(gather) parser.feed("<doc/>") parser.close() self.verify_empty_nsattrs(gather._attrs) def test_expat_nsattrs_wattr(self): parser = create_parser(1) gather = self.AttrGatherer() parser.setContentHandler(gather) parser.feed("<doc xmlns:ns='%s' ns:attr='val'/>" % ns_uri) parser.close() attrs = gather._attrs self.assertEqual(attrs.getLength(), 1) self.assertEqual(attrs.getNames(), [(ns_uri, "attr")]) self.assertTrue((attrs.getQNames() == [] or attrs.getQNames() == ["ns:attr"])) self.assertEqual(len(attrs), 1) self.assertIn((ns_uri, "attr"), attrs) self.assertEqual(attrs.get((ns_uri, "attr")), "val") self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val") self.assertEqual(list(attrs.items()), [((ns_uri, "attr"), "val")]) self.assertEqual(list(attrs.values()), ["val"]) self.assertEqual(attrs.getValue((ns_uri, "attr")), "val") self.assertEqual(attrs[(ns_uri, "attr")], "val") # ===== InputSource support def test_expat_inpsource_filename(self): parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) parser.parse(TEST_XMLFILE) self.assertEqual(result.getvalue(), xml_test_out) def test_expat_inpsource_sysid(self): parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) parser.parse(InputSource(TEST_XMLFILE)) self.assertEqual(result.getvalue(), xml_test_out) @requires_nonascii_filenames def test_expat_inpsource_sysid_nonascii(self): fname = support.TESTFN_UNICODE shutil.copyfile(TEST_XMLFILE, fname) self.addCleanup(support.unlink, fname) parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) parser.parse(InputSource(fname)) self.assertEqual(result.getvalue(), xml_test_out) def test_expat_inpsource_byte_stream(self): parser = create_parser() result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) inpsrc = InputSource() with open(TEST_XMLFILE, 'rb') as f: inpsrc.setByteStream(f) parser.parse(inpsrc) self.assertEqual(result.getvalue(), xml_test_out) # ===== IncrementalParser support def test_expat_incremental(self): result = BytesIO() xmlgen = XMLGenerator(result) parser = create_parser() parser.setContentHandler(xmlgen) parser.feed("<doc>") parser.feed("</doc>") parser.close() self.assertEqual(result.getvalue(), start + b"<doc></doc>") def test_expat_incremental_reset(self): result = BytesIO() xmlgen = XMLGenerator(result) parser = create_parser() parser.setContentHandler(xmlgen) parser.feed("<doc>") parser.feed("text") result = BytesIO() xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) parser.reset() parser.feed("<doc>") parser.feed("text") parser.feed("</doc>") parser.close() self.assertEqual(result.getvalue(), start + b"<doc>text</doc>") # ===== Locator support def test_expat_locator_noinfo(self): result = BytesIO() xmlgen = XMLGenerator(result) parser = create_parser() parser.setContentHandler(xmlgen) parser.feed("<doc>") parser.feed("</doc>") parser.close() self.assertEqual(parser.getSystemId(), None) self.assertEqual(parser.getPublicId(), None) self.assertEqual(parser.getLineNumber(), 1) def test_expat_locator_withinfo(self): result = BytesIO() xmlgen = XMLGenerator(result) parser = create_parser() parser.setContentHandler(xmlgen) parser.parse(TEST_XMLFILE) self.assertEqual(parser.getSystemId(), TEST_XMLFILE) self.assertEqual(parser.getPublicId(), None) @requires_nonascii_filenames def test_expat_locator_withinfo_nonascii(self): fname = support.TESTFN_UNICODE shutil.copyfile(TEST_XMLFILE, fname) self.addCleanup(support.unlink, fname) result = BytesIO() xmlgen = XMLGenerator(result) parser = create_parser() parser.setContentHandler(xmlgen) parser.parse(fname) self.assertEqual(parser.getSystemId(), fname) self.assertEqual(parser.getPublicId(), None) # =========================================================================== # # error reporting # # =========================================================================== class ErrorReportingTest(unittest.TestCase): def test_expat_inpsource_location(self): parser = create_parser() parser.setContentHandler(ContentHandler()) # do nothing source = InputSource() source.setByteStream(BytesIO(b"<foo bar foobar>")) #ill-formed name = "a file name" source.setSystemId(name) try: parser.parse(source) self.fail() except SAXException as e: self.assertEqual(e.getSystemId(), name) def test_expat_incomplete(self): parser = create_parser() parser.setContentHandler(ContentHandler()) # do nothing self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>")) self.assertEqual(parser.getColumnNumber(), 5) self.assertEqual(parser.getLineNumber(), 1) def test_sax_parse_exception_str(self): # pass various values from a locator to the SAXParseException to # make sure that the __str__() doesn't fall apart when None is # passed instead of an integer line and column number # # use "normal" values for the locator: str(SAXParseException("message", None, self.DummyLocator(1, 1))) # use None for the line number: str(SAXParseException("message", None, self.DummyLocator(None, 1))) # use None for the column number: str(SAXParseException("message", None, self.DummyLocator(1, None))) # use None for both: str(SAXParseException("message", None, self.DummyLocator(None, None))) class DummyLocator: def __init__(self, lineno, colno): self._lineno = lineno self._colno = colno def getPublicId(self): return "pubid" def getSystemId(self): return "sysid" def getLineNumber(self): return self._lineno def getColumnNumber(self): return self._colno # =========================================================================== # # xmlreader tests # # =========================================================================== class XmlReaderTest(XmlTestBase): # ===== AttributesImpl def test_attrs_empty(self): self.verify_empty_attrs(AttributesImpl({})) def test_attrs_wattr(self): self.verify_attrs_wattr(AttributesImpl({"attr" : "val"})) def test_nsattrs_empty(self): self.verify_empty_nsattrs(AttributesNSImpl({}, {})) def test_nsattrs_wattr(self): attrs = AttributesNSImpl({(ns_uri, "attr") : "val"}, {(ns_uri, "attr") : "ns:attr"}) self.assertEqual(attrs.getLength(), 1) self.assertEqual(attrs.getNames(), [(ns_uri, "attr")]) self.assertEqual(attrs.getQNames(), ["ns:attr"]) self.assertEqual(len(attrs), 1) self.assertIn((ns_uri, "attr"), attrs) self.assertEqual(list(attrs.keys()), [(ns_uri, "attr")]) self.assertEqual(attrs.get((ns_uri, "attr")), "val") self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val") self.assertEqual(list(attrs.items()), [((ns_uri, "attr"), "val")]) self.assertEqual(list(attrs.values()), ["val"]) self.assertEqual(attrs.getValue((ns_uri, "attr")), "val") self.assertEqual(attrs.getValueByQName("ns:attr"), "val") self.assertEqual(attrs.getNameByQName("ns:attr"), (ns_uri, "attr")) self.assertEqual(attrs[(ns_uri, "attr")], "val") self.assertEqual(attrs.getQNameByName((ns_uri, "attr")), "ns:attr") def test_main(): run_unittest(MakeParserTest, ParseTest, SaxutilsTest, PrepareInputSourceTest, StringXmlgenTest, BytesXmlgenTest, WriterXmlgenTest, StreamWriterXmlgenTest, StreamReaderWriterXmlgenTest, ExpatReaderTest, ErrorReportingTest, XmlReaderTest) if __name__ == "__main__": test_main()