Back to index

python-cliapp  1.20120630
Public Member Functions
cliapp.runcmd_tests.ApplicationTests Class Reference

List of all members.

Public Member Functions

def test_runcmd_executes_true
def test_runcmd_raises_error_on_failure
def test_runcmd_returns_stdout_of_command
def test_runcmd_returns_stderr_of_command
def test_runcmd_pipes_stdin_through_command
def test_runcmd_pipes_stdin_through_two_commands
def test_runcmd_pipes_stdin_through_command_with_lots_of_data
def test_runcmd_ignores_failures_on_request
def test_runcmd_obeys_cwd
def test_runcmd_unchecked_returns_values_on_success
def test_runcmd_unchecked_returns_values_on_failure
def test_runcmd_unchecked_runs_simple_pipeline
def test_runcmd_unchecked_runs_longer_pipeline
def test_runcmd_redirects_stdin_from_file
def test_runcmd_redirects_stdout_to_file
def test_runcmd_redirects_stderr_to_file

Detailed Description

Definition at line 32 of file runcmd_tests.py.


Member Function Documentation

Definition at line 34 of file runcmd_tests.py.

00034 
00035     def test_runcmd_executes_true(self):
00036         self.assertEqual(cliapp.runcmd(['true']), '')
    

Definition at line 63 of file runcmd_tests.py.

00063 
00064     def test_runcmd_ignores_failures_on_request(self):
00065         self.assertEqual(cliapp.runcmd(['false'], ignore_fail=True), '')

Definition at line 66 of file runcmd_tests.py.

00066 
00067     def test_runcmd_obeys_cwd(self):
00068         self.assertEqual(cliapp.runcmd(['pwd'], cwd='/'), '/\n')

Definition at line 50 of file runcmd_tests.py.

00050 
00051     def test_runcmd_pipes_stdin_through_command(self):
00052         self.assertEqual(cliapp.runcmd(['cat'], feed_stdin='hello, world'),
00053                          'hello, world')

Definition at line 59 of file runcmd_tests.py.

00059 
00060     def test_runcmd_pipes_stdin_through_command_with_lots_of_data(self):
00061         data = 'x' * (1024**2)
00062         self.assertEqual(cliapp.runcmd(['cat'], feed_stdin=data), data)

Definition at line 54 of file runcmd_tests.py.

00054 
00055     def test_runcmd_pipes_stdin_through_two_commands(self):
00056         self.assertEqual(cliapp.runcmd(
00057                             ['cat'], ['cat'], feed_stdin='hello, world'),
00058                          'hello, world')

Definition at line 37 of file runcmd_tests.py.

00037 
00038     def test_runcmd_raises_error_on_failure(self):
00039         self.assertRaises(cliapp.AppException, cliapp.runcmd, ['false'])
    

Definition at line 105 of file runcmd_tests.py.

00105 
00106     def test_runcmd_redirects_stderr_to_file(self):
00107         fd, filename = tempfile.mkstemp()
00108         exit, out, err = cliapp.runcmd_unchecked(['ls', 'notexist'], stderr=fd)
00109         os.close(fd)
00110         with open(filename) as f:
00111             data = f.read()
00112         self.assertNotEqual(exit, 0)
00113         self.assertNotEqual(data, '')
00114 
00115 

Definition at line 88 of file runcmd_tests.py.

00088 
00089     def test_runcmd_redirects_stdin_from_file(self):
00090         fd, filename = tempfile.mkstemp()
00091         os.write(fd, 'foobar')
00092         os.lseek(fd, 0, os.SEEK_SET)
00093         self.assertEqual(cliapp.runcmd_unchecked(['cat'], stdin=fd),
00094                          (0, 'foobar', ''))
00095         os.close(fd)
                            

Definition at line 96 of file runcmd_tests.py.

00096 
00097     def test_runcmd_redirects_stdout_to_file(self):
00098         fd, filename = tempfile.mkstemp()
00099         exit, out, err = cliapp.runcmd_unchecked(['echo', 'foo'], stdout=fd)
00100         os.close(fd)
00101         with open(filename) as f:
00102             data = f.read()
00103         self.assertEqual(exit, 0)
00104         self.assertEqual(data, 'foo\n')
                            

Definition at line 44 of file runcmd_tests.py.

00044 
00045     def test_runcmd_returns_stderr_of_command(self):
00046         exit, out, err = cliapp.runcmd_unchecked(['ls', 'notexist'])
00047         self.assertNotEqual(exit, 0)
00048         self.assertEqual(out, '')
00049         self.assertNotEqual(err, '')

Definition at line 40 of file runcmd_tests.py.

00040 
00041     def test_runcmd_returns_stdout_of_command(self):
00042         self.assertEqual(cliapp.runcmd(['echo', 'hello', 'world']),
00043                          'hello world\n')
    

Definition at line 73 of file runcmd_tests.py.

00073 
00074     def test_runcmd_unchecked_returns_values_on_failure(self):
00075         self.assertEqual(cliapp.runcmd_unchecked(['false']), 
00076                          (1, '', ''))

Definition at line 69 of file runcmd_tests.py.

00069 
00070     def test_runcmd_unchecked_returns_values_on_success(self):
00071         self.assertEqual(cliapp.runcmd_unchecked(['echo', 'foo']), 
00072                          (0, 'foo\n', ''))

Definition at line 82 of file runcmd_tests.py.

00082 
00083     def test_runcmd_unchecked_runs_longer_pipeline(self):
00084         self.assertEqual(cliapp.runcmd_unchecked(['echo', 'foo'], 
00085                                                  ['cat'],
00086                                                  ['wc', '-c']),
00087                          (0, '4\n', ''))

Definition at line 77 of file runcmd_tests.py.

00077 
00078     def test_runcmd_unchecked_runs_simple_pipeline(self):
00079         self.assertEqual(cliapp.runcmd_unchecked(
00080                             ['echo', 'foo'], ['wc', '-c']),
00081                          (0, '4\n', ''))


The documentation for this class was generated from the following file: