Server IP : 103.119.228.120 / Your IP : 18.188.113.185 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/mysqlsh/lib/python3.9/site-packages/setuptools/tests/ |
Upload File : |
import os import platform import sys import textwrap import pytest IS_PYPY = '__pypy__' in sys.builtin_module_names _TEXT_KWARGS = {"text": True, "encoding": "utf-8"} # For subprocess.run def win_sr(env): """ On Windows, SYSTEMROOT must be present to avoid > Fatal Python error: _Py_HashRandomization_Init: failed to > get random numbers to initialize Python """ if env and platform.system() == 'Windows': env['SYSTEMROOT'] = os.environ['SYSTEMROOT'] return env def find_distutils(venv, imports='distutils', env=None, **kwargs): py_cmd = 'import {imports}; print(distutils.__file__)'.format(**locals()) cmd = ['python', '-c', py_cmd] return venv.run(cmd, env=win_sr(env), **_TEXT_KWARGS, **kwargs) def count_meta_path(venv, env=None): py_cmd = textwrap.dedent( """ import sys is_distutils = lambda finder: finder.__class__.__name__ == "DistutilsMetaFinder" print(len(list(filter(is_distutils, sys.meta_path)))) """ ) cmd = ['python', '-c', py_cmd] return int(venv.run(cmd, env=win_sr(env), **_TEXT_KWARGS)) skip_without_stdlib_distutils = pytest.mark.skipif( sys.version_info >= (3, 12), reason='stdlib distutils is removed from Python 3.12+', ) @skip_without_stdlib_distutils def test_distutils_stdlib(venv): """ Ensure stdlib distutils is used when appropriate. """ env = dict(SETUPTOOLS_USE_DISTUTILS='stdlib') assert venv.name not in find_distutils(venv, env=env).split(os.sep) assert count_meta_path(venv, env=env) == 0 def test_distutils_local_with_setuptools(venv): """ Ensure local distutils is used when appropriate. """ env = dict(SETUPTOOLS_USE_DISTUTILS='local') loc = find_distutils(venv, imports='setuptools, distutils', env=env) assert venv.name in loc.split(os.sep) assert count_meta_path(venv, env=env) <= 1 @pytest.mark.xfail('IS_PYPY', reason='pypy imports distutils on startup') def test_distutils_local(venv): """ Even without importing, the setuptools-local copy of distutils is preferred. """ env = dict(SETUPTOOLS_USE_DISTUTILS='local') assert venv.name in find_distutils(venv, env=env).split(os.sep) assert count_meta_path(venv, env=env) <= 1 def test_pip_import(venv): """ Ensure pip can be imported. Regression test for #3002. """ cmd = ['python', '-c', 'import pip'] venv.run(cmd, **_TEXT_KWARGS) def test_distutils_has_origin(): """ Distutils module spec should have an origin. #2990. """ assert __import__('distutils').__spec__.origin ENSURE_IMPORTS_ARE_NOT_DUPLICATED = r""" # Depending on the importlib machinery and _distutils_hack, some imports are # duplicated resulting in different module objects being loaded, which prevents # patches as shown in #3042. # This script provides a way of verifying if this duplication is happening. from distutils import cmd import distutils.command.sdist as sdist # import last to prevent caching from distutils import {imported_module} for mod in (cmd, sdist): assert mod.{imported_module} == {imported_module}, ( f"\n{{mod.dir_util}}\n!=\n{{{imported_module}}}" ) print("success") """ @pytest.mark.parametrize( "distutils_version, imported_module", [ pytest.param("stdlib", "dir_util", marks=skip_without_stdlib_distutils), pytest.param("stdlib", "file_util", marks=skip_without_stdlib_distutils), pytest.param("stdlib", "archive_util", marks=skip_without_stdlib_distutils), ("local", "dir_util"), ("local", "file_util"), ("local", "archive_util"), ], ) def test_modules_are_not_duplicated_on_import( distutils_version, imported_module, tmpdir_cwd, venv ): env = dict(SETUPTOOLS_USE_DISTUTILS=distutils_version) script = ENSURE_IMPORTS_ARE_NOT_DUPLICATED.format(imported_module=imported_module) cmd = ['python', '-c', script] output = venv.run(cmd, env=win_sr(env), **_TEXT_KWARGS).strip() assert output == "success" ENSURE_LOG_IMPORT_IS_NOT_DUPLICATED = r""" import types import distutils.dist as dist from distutils import log if isinstance(dist.log, types.ModuleType): assert dist.log == log, f"\n{dist.log}\n!=\n{log}" print("success") """ @pytest.mark.parametrize( "distutils_version", [ "local", pytest.param("stdlib", marks=skip_without_stdlib_distutils), ], ) def test_log_module_is_not_duplicated_on_import(distutils_version, tmpdir_cwd, venv): env = dict(SETUPTOOLS_USE_DISTUTILS=distutils_version) cmd = ['python', '-c', ENSURE_LOG_IMPORT_IS_NOT_DUPLICATED] output = venv.run(cmd, env=win_sr(env), **_TEXT_KWARGS).strip() assert output == "success"