403Webshell
Server IP : 199.250.200.62  /  Your IP : 216.73.217.61
Web Server : Apache
System : Linux vps37394.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User : jasonp18 ( 1000)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2/cwd/proc/3/task/3/cwd/opt/imh-python/lib/python3.9/site-packages/traitlets/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/2/cwd/proc/3/task/3/cwd/opt/imh-python/lib/python3.9/site-packages/traitlets/tests/utils.py
from __future__ import annotations

import sys
from subprocess import PIPE, Popen
from typing import Any, Sequence


def get_output_error_code(cmd: str | Sequence[str]) -> tuple[str, str, Any]:
    """Get stdout, stderr, and exit code from running a command"""
    p = Popen(cmd, stdout=PIPE, stderr=PIPE)  # noqa: S603
    out, err = p.communicate()
    out_str = out.decode("utf8", "replace")
    err_str = err.decode("utf8", "replace")
    return out_str, err_str, p.returncode


def check_help_output(pkg: str, subcommand: Sequence[str] | None = None) -> tuple[str, str]:
    """test that `python -m PKG [subcommand] -h` works"""
    cmd = [sys.executable, "-m", pkg]
    if subcommand:
        cmd.extend(subcommand)
    cmd.append("-h")
    out, err, rc = get_output_error_code(cmd)
    assert rc == 0, err
    assert "Traceback" not in err
    assert "Options" in out
    assert "--help-all" in out
    return out, err


def check_help_all_output(pkg: str, subcommand: Sequence[str] | None = None) -> tuple[str, str]:
    """test that `python -m PKG --help-all` works"""
    cmd = [sys.executable, "-m", pkg]
    if subcommand:
        cmd.extend(subcommand)
    cmd.append("--help-all")
    out, err, rc = get_output_error_code(cmd)
    assert rc == 0, err
    assert "Traceback" not in err
    assert "Options" in out
    assert "Class options" in out
    return out, err

Youez - 2016 - github.com/yon3zu
LinuXploit