// аргументы конструктора MyController
$constructorArgs = [
'id',
Yii::$app,
];
// заменяемые методы и свойства MyController
$methods = [
// метод, который тестируем
// подойдет любой тип callable
'methodToTest' => function() {
$args = func_get_args();
... тестируем аргументы
},
];
$controllerMock = \Codeception\Util\Stub::construct(
'\namespace\controllers\MyController',
$constructorArgs,
$methods
);
$controllerMock->run('action', []);
screen -ls | tail -n +2 | head -n -2 | awk '{print $1}'| xargs -I{} screen -S {} -X quit
sh (previously pbs) is a full-fledged subprocess interface for Python that allows you to call any program as if it were a functionamoffat.github.io/sh/#piping
Plumbum is a small yet feature-rich library for shell script-like programs in Pythonhttps://plumbum.readthedocs.org/en/latest/#cheat-sheet
subprocess.call('ls -la | grep i', shell=True)
>>> p = subprocess.Popen('ls -la|grep i', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>>> p
<subprocess.Popen object at 0x2173790>
>>> p.stdout
<_io.FileIO name=3 mode='rb'>
>>> p.stdout.read()
>>> p.stderr.read()
output=`dmesg | grep hda`
# becomes
p1 = Popen(["dmesg"], stdout=PIPE)
p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
output = p2.communicate()[0]