Example #1
0
 def test_shell_call(self):
     out, err = shell.call(["echo", "This works"])
     self.assertEqual(out, "This works\n")
     self.assertEqual(err, '')
     out2, err2 = shell.call("echo 'This works'")
     self.assertEqual(out, out2)
     self.assertEqual(err, err2)
     self.assertRaises(OSError, shell.call, ['this-command-doesnt-exist'])
     self.assertRaises(subprocess.CalledProcessError, shell.call,
                       'this-command-doesnt-exist')
     self.assertRaises(subprocess.CalledProcessError, shell.call, 'false')
     with pytest.warns(UserWarning):
         shell.call('false', on_error='warn')
Example #2
0
 def test_shell_call(self):
     out, err = shell.call(["echo", "This works"])
     self.assertEqual(out, "This works\n")
     self.assertEqual(err, '')
     out2, err2 = shell.call("echo 'This works'")
     self.assertEqual(out, out2)
     self.assertEqual(err, err2)
     self.assertRaises(OSError, shell.call, ['this-command-doesnt-exist'])
     self.assertRaises(subprocess.CalledProcessError, shell.call,
                       'this-command-doesnt-exist')
     self.assertRaises(subprocess.CalledProcessError, shell.call, 'false')
     with pytest.warns(UserWarning):
         shell.call('false', on_error='warn')
Example #3
0
def test_which():
    try:
        result, _ = shell.call('which true')
    except Exception as e:
        pytest.skip(str(e))
    else:
        result = result.rstrip('\n')
    assert shell.which('true') == result
Example #4
0
def test_shell_call():
    out, err = shell.call(["echo", "This works"])
    assert out == 'This works\n'
    assert err == ''

    out2, err2 = shell.call("echo 'This works'")
    assert out == out2
    assert err == err2

    with pytest.raises(OSError):
        shell.call(['this-command-doesnt-exist'])
    with pytest.raises(subprocess.CalledProcessError):
        shell.call('this-command-doesnt-exist')
    with pytest.raises(subprocess.CalledProcessError):
        shell.call('false')
    with pytest.warns(UserWarning):
        shell.call('false', on_error='warn')
Example #5
0
 def test_which(self):
     try:
         result, _ = shell.call('which true')
     except Exception as e:
         self.skipTest(str(e))
     else:
         result = result.rstrip('\n')
     self.assertEqual(shell.which('true'), result)
Example #6
0
 def test_which(self):
     try:
         result, _ = shell.call('which true')
     except Exception as e:
         self.skipTest(str(e))
     else:
         result = result.rstrip('\n')
     self.assertEqual(shell.which('true'), result)
Example #7
0
def test_which():
    try:
        result, _ = shell.call('which true')
    except Exception as e:
        pytest.skip(str(e))
    else:
        result = result.rstrip('\n')
    assert shell.which('true') == result
Example #8
0
def test_shell_call():
    out, err = shell.call(["echo", "This works"])
    assert out == 'This works\n'
    assert err == ''

    out2, err2 = shell.call("echo 'This works'")
    assert out == out2
    assert err == err2

    with pytest.raises(OSError):
        shell.call(['this-command-doesnt-exist'])
    with pytest.raises(subprocess.CalledProcessError):
        shell.call('this-command-doesnt-exist')
    with pytest.raises(subprocess.CalledProcessError):
        shell.call('false')
    with pytest.warns(UserWarning):
        shell.call('false', on_error='warn')