How to use the pyscaffold.shell.ShellCommand function in PyScaffold

To help you get started, we’ve selected a few PyScaffold examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyscaffold / pyscaffold / tests / test_shell.py View on Github external
def test_pretend_command(caplog):
    caplog.set_level(logging.INFO)
    # When command runs under pretend flag,
    name = uniqstr()
    touch = shell.ShellCommand("touch")
    touch(name, pretend=True)
    # then nothing should be executed
    assert not path_exists(name)
    # but log should be displayed
    logs = caplog.text
    assert re.search(r"run.*touch\s" + name, logs)
github pyscaffold / pyscaffold / tests / test_shell.py View on Github external
def test_ShellCommand(tmpfolder):
    echo = shell.ShellCommand("echo")
    output = echo("Hello Echo!!!")
    assert next(output).strip('"') == "Hello Echo!!!"
    python = shell.ShellCommand("python")
    output = python("-c", 'print("Hello World")')
    assert list(output)[-1] == "Hello World"
    touch = shell.ShellCommand("touch")
    touch("my-file.txt")
    assert path_exists("my-file.txt")
github pyscaffold / pyscaffold / tests / test_shell.py View on Github external
def func(_):
        shell.ShellCommand("non_existing_cmd")("--wrong-args")
github pyscaffold / pyscaffold / tests / test_shell.py View on Github external
def test_ShellCommand(tmpfolder):
    echo = shell.ShellCommand("echo")
    output = echo("Hello Echo!!!")
    assert next(output).strip('"') == "Hello Echo!!!"
    python = shell.ShellCommand("python")
    output = python("-c", 'print("Hello World")')
    assert list(output)[-1] == "Hello World"
    touch = shell.ShellCommand("touch")
    touch("my-file.txt")
    assert path_exists("my-file.txt")
github pyscaffold / pyscaffold / tests / test_install.py View on Github external
import pytest

from pyscaffold import shell
from pyscaffold.cli import main as putup
from pyscaffold.shell import command_exists, git
from pyscaffold.utils import chdir

__location__ = path_join(
    os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
)


pytestmark = pytest.mark.slow


untar = shell.ShellCommand(("gtar" if command_exists("gtar") else "tar") + " xvzkf")
# ^ BSD tar differs in options from GNU tar,
#   so make sure to use the correct one...
#   https://xkcd.com/1168/


@pytest.fixture
def demoapp(tmpfolder, venv):
    return DemoApp(tmpfolder, venv)


@pytest.fixture
def demoapp_data(tmpfolder, venv):
    return DemoApp(tmpfolder, venv, data=True)


class DemoApp(object):
github pyscaffold / pyscaffold / tests / test_shell.py View on Github external
def test_ShellCommand(tmpfolder):
    echo = shell.ShellCommand("echo")
    output = echo("Hello Echo!!!")
    assert next(output).strip('"') == "Hello Echo!!!"
    python = shell.ShellCommand("python")
    output = python("-c", 'print("Hello World")')
    assert list(output)[-1] == "Hello World"
    touch = shell.ShellCommand("touch")
    touch("my-file.txt")
    assert path_exists("my-file.txt")