8000 gh-131178: Add tests for `site` command-line interface by ggqlq · Pull Request #133582 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-131178: Add tests for site command-line interface #133582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix windows
  • Loading branch information
ggqlq committed May 8, 2025
commit 3c1ba46cca6a3b840a856a76e93bcd7a27bd11d3
15 changes: 10 additions & 5 deletions Lib/test/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,21 +841,28 @@ def get_excepted_output(self, *args):
elif site.ENABLE_USER_SITE is None:
return_code = 2
output = os.pathsep.join(buffer)
return return_code, dedent(output).strip()
return return_code, os.path.normpath(dedent(output).strip())
else:
return 10, None

def invoke_command_line(self, *args):
args = [sys.executable, "-m", "site", *args]
env = os.environ.copy()
env["PYTHONUTF8"] = "1"
env["PYTHONIOENCODING"] = "utf-8"

proc = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True)
text=True,
env=env,
encoding='utf-8',
errors='replace')
proc.wait()
output = proc.stdout.read()
return_code = proc.returncode
proc.stdout.close()
return return_code, dedent(output).strip()
return return_code, os.path.normpath(dedent(output).strip())

@unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI")
def test_no_args(self):
Expand All @@ -867,13 +874,11 @@ def test_no_args(self):
self.assertEqual(lines[-4], "]")
excepted_base = f"USER_BASE: '{site.getuserbase()}'" +\
f" ({self.exists(site.getuserbase())})"
print(excepted_base)
self.assertEqual(lines[-3], excepted_base)
excepted_site = f"USER_SITE: '{site.getusersitepackages()}'" +\
f" ({self.exists(site.getusersitepackages())})"
self.assertEqual(lines[-2], excepted_site)
self.assertEqual(lines[-1], f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}")


@unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI")
def test_unknown_args(self):
Expand Down
216 changes: 216 additions & 0 deletions confdefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/* confdefs.h */
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _DARWIN_C_SOURCE 1
#define _PYTHONFRAMEWORK ""
#define _XOPEN_SOURCE 700
#define _XOPEN_SOURCE_EXTENDED 1
#define _POSIX_C_SOURCE 200809L
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_STRINGS_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1
#define HAVE_WCHAR_H 1
#define STDC_HEADERS 1
#define _ALL_SOURCE 1
#define _DARWIN_C_SOURCE 1
#define _GNU_SOURCE 1
#define _HPUX_ALT_XOPEN_SOCKET_API 1
#define _NETBSD_SOURCE 1
#define _OPENBSD_SOURCE 1
#define _POSIX_PTHREAD_SEMANTICS 1
#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
#define __STDC_WANT_IEC_60559_BFP_EXT__ 1
#define __STDC_WANT_IEC_60559_DFP_EXT__ 1
#define __STDC_WANT_IEC_60559_EXT__ 1
#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
#define __STDC_WANT_LIB_EXT2__ 1
#define __STDC_WANT_MATH_SPEC_FUNCS__ 1
#define _TANDEM_SOURCE 1
#define __EXTENSIONS__ 1
#define PY_SUPPORT_TIER 1
#define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1
#define HAVE_ASM_TYPES_H 1
#define HAVE_DLFCN_H 1
#define HAVE_ENDIAN_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_GRP_H 1
#define HAVE_LANGINFO_H 1
#define HAVE_LIBINTL_H 1
#define HAVE_LINUX_AUXVEC_H 1
#define HAVE_SYS_AUXV_H 1
#define HAVE_LINUX_FS_H 1
#define HAVE_LINUX_LIMITS_H 1
#define HAVE_LINUX_MEMFD_H 1
#define HAVE_LINUX_NETFILTER_IPV4_H 1
#define HAVE_LINUX_RANDOM_H 1
#define HAVE_LINUX_SOUNDCARD_H 1
#define HAVE_LINUX_SCHED_H 1
#define HAVE_LINUX_TIPC_H 1
#define HAVE_LINUX_WAIT_H 1
#define HAVE_NETDB_H 1
#define HAVE_NET_ETHERNET_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_NETPACKET_PACKET_H 1
#define HAVE_POLL_H 1
#define HAVE_PTHREAD_H 1
#define HAVE_PTY_H 1
#define HAVE_SCHED_H 1
#define HAVE_SETJMP_H 1
#define HAVE_SHADOW_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_SPAWN_H 1
#define HAVE_SYS_EPOLL_H 1
#define HAVE_SYS_EVENTFD_H 1
#define HAVE_SYS_FILE_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_PIDFD_H 1
#define HAVE_SYS_POLL_H 1
#define HAVE_SYS_RANDOM_H 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_SENDFILE_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_SOUNDCARD_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_STATVFS_H 1
#define HAVE_SYS_SYSCALL_H 1
#define HAVE_SYS_SYSMACROS_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMES_H 1
#define HAVE_SYS_TIMERFD_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_UIO_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_SYS_UTSNAME_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_SYS_XATTR_H 1
#define HAVE_SYSEXITS_H 1
#define HAVE_SYSLOG_H 1
#define HAVE_TERMIOS_H 1
#define HAVE_UTIME_H 1
#define HAVE_UTMP_H 1
#define HAVE_DIRENT_H 1
#define MAJOR_IN_SYSMACROS 1
#define HAVE_BLUETOOTH_BLUETOOTH_H 1
#define HAVE_NET_IF_H 1
#define HAVE_LINUX_NETLINK_H 1
#define HAVE_LINUX_QRTR_H 1
#define HAVE_LINUX_VM_SOCKETS_H 1
#define HAVE_LINUX_CAN_H 1
#define HAVE_LINUX_CAN_BCM_H 1
#define HAVE_LINUX_CAN_J1939_H 1
#define HAVE_LINUX_CAN_RAW_H 1
#define HAVE_CLOCK_T 1
#define HAVE_MAKEDEV 1
#define HAVE_HTOLE64 1
#define _LARGEFILE_SOURCE 1
#define _FILE_OFFSET_BITS 64
#if defined(SCO_DS)
#undef _OFF_T
#endif
#define RETSIGTYPE void
#define HAVE_SSIZE_T 1
#define HAVE___UINT128_T 1
#define HAVE_GCC_UINT128_T 1
#define SIZEOF_INT 4
#define SIZEOF_LONG 8
#define ALIGNOF_LONG 8
#define SIZEOF_LONG_LONG 8
#define SIZEOF_VOID_P 8
#define SIZEOF_SHORT 2
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define SIZEOF_FPOS_T 16
#define SIZEOF_SIZE_T 8
#define ALIGNOF_SIZE_T 8
#define SIZEOF_PID_T 4
#define SIZEOF_UINTPTR_T 8
#define ALIGNOF_MAX_ALIGN_T 16
#define HAVE_LONG_DOUBLE 1
#define SIZEOF_LONG_DOUBLE 16
#define SIZEOF__BOOL 1
#define SIZEOF_OFF_T 8
#define SIZEOF_TIME_T 8
#define SIZEOF_PTHREAD_T 8
#define SIZEOF_PTHREAD_KEY_T 4
#define PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT 1
#define PY_HAVE_PERF_TRAMPOLINE 1
#define HAVE_LIBDL 1
#define HAVE_EXECINFO_H 1
#define HAVE_BACKTRACE 1
#define HAVE_DLADDR1 1
#define HAVE_LINK_H 1
#define HAVE_BACKTRACE 1
#define HAVE_DLADDR1 1
#define HAVE_DLFCN_H 1
#define HAVE_BACKTRACE 1
#define HAVE_DLADDR1 1
#define HAVE_UUID_H 1
#define HAVE_UUID_GENERATE_TIME_SAFE 1
#define HAVE_FFI_PREP_CIF_VAR 1
#define HAVE_FFI_PREP_CLOSURE_LOC 1
#define HAVE_FFI_CLOSURE_ALLOC 1
#define Py_FFI_SUPPORT_C_COMPLEX 1
#define WITH_DECIMAL_CONTEXTVAR 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define HAVE_LIBSQLITE3 1
#define PY_SQLITE_HAVE_SERIALIZE 1
#define HAVE_GDBM_H 1
#define HAVE_NDBM_H 1
#define _REENTRANT 1
#define PTHREAD_SYSTEM_SCHED_SUPPORTED 1
#define HAVE_PTHREAD_SIGMASK 1
#define HAVE_PTHREAD_GETCPUCLOCKID 1
#define ENABLE_IPV6 1
#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1
#define HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1
#define WITH_DOC_STRINGS 1
#define HAVE_STD_ATOMIC 1
#define HAVE_BUILTIN_ATOMIC 1
#define WITH_MIMALLOC 1
#define WITH_PYMALLOC 1
#define PY_COERCE_C_LOCALE 1
#define HAVE_DLOPEN 1
#define HAVE_DYNAMIC_LOADING 1
#define HAVE_ACCEPT4 1
#define HAVE_ALARM 1
#define HAVE_BIND_TEXTDOMAIN_CODESET 1
#define HAVE_CHMOD 1
#define HAVE_CHOWN 1
#define HAVE_CLOCK 1
#define HAVE_CLOSEFROM 1
#define HAVE_CLOSE_RANGE 1
#define HAVE_CONFSTR 1
#define HAVE_COPY_FILE_RANGE 1
#define HAVE_CTERMID 1
#define HAVE_DLADDR 1
#define HAVE_DUP 1
#define HAVE_DUP3 1
#define HAVE_EXECV 1
#define HAVE_EXPLICIT_BZERO 1
#define HAVE_FACCESSAT 1
#define HAVE_FCHMOD 1
#define HAVE_FCHMODAT 1
#define HAVE_FCHOWN 1
#define HAVE_FCHOWNAT 1
#define HAVE_FDOPENDIR 1
#define HAVE_FEXECVE 1
#define HAVE_FORK 1
Loading
0