def test_ShellCommand(): 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'
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")
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')
def test_pretend_command(caplog): # When command runs under pretend flag, touch = shell.ShellCommand('touch') touch('my-file.txt', pretend=True) # then nothing should be executed assert not path_exists('my-file.txt') # but log should be displayed match = match_last_report(caplog) assert match['activity'] == 'run' assert match['content'] == 'touch my-file.txt'
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('run.*touch\s'+name, logs)
def func(_): shell.ShellCommand('non_existing_cmd')('--wrong-args')
from pyscaffold.repo import add_tag from pyscaffold.runner import main as putup from pyscaffold.shell import git from pyscaffold.utils import chdir from .fixtures import tmpdir # noqa __author__ = "Florian Wilhelm" __copyright__ = "Blue Yonder" __license__ = "new BSD" __location__ = os.path.join(os.getcwd(), os.path.dirname( inspect.getfile(inspect.currentframe()))) pip = shell.ShellCommand("pip") setup_py = shell.ShellCommand("python setup.py") demoapp = shell.ShellCommand("demoapp") demoapp_data = shell.ShellCommand("demoapp_data") untar = shell.ShellCommand("tar xvfzk") def is_inside_venv(): return hasattr(sys, 'real_prefix') def create_demoapp(data=False): if data: demoapp = 'demoapp_data' else: demoapp = 'demoapp'
from os.path import join as path_join from shutil import copyfile 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)
def func(_): shell.ShellCommand("non_existing_cmd")("--wrong-args")
def venv_cmd(cmd, *args): """Create a callable from a command inside a virtualenv.""" return shell.ShellCommand(' '.join([cmd_path(cmd)] + list(args)))