Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.test_popen.PopenTest Class Reference

List of all members.

Public Member Functions

def test_popen
def test_return_code
def test_contextmanager
def test_iterating

Private Member Functions

def _do_test_commandline

Detailed Description

Definition at line 20 of file test_popen.py.


Member Function Documentation

def test.test_popen.PopenTest._do_test_commandline (   self,
  cmdline,
  expected 
) [private]

Definition at line 22 of file test_popen.py.

00022 
00023     def _do_test_commandline(self, cmdline, expected):
00024         cmd = '%s -c "import sys; print(sys.argv)" %s'
00025         cmd = cmd % (python, cmdline)
00026         with os.popen(cmd) as p:
00027             data = p.read()
00028         got = eval(data)[1:] # strip off argv[0]
00029         self.assertEqual(got, expected)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file test_popen.py.

00053 
00054     def test_contextmanager(self):
00055         with os.popen("echo hello") as f:
00056             self.assertEqual(f.read(), "hello\n")

Here is the call graph for this function:

Definition at line 57 of file test_popen.py.

00057 
00058     def test_iterating(self):
00059         with os.popen("echo hello") as f:
00060             self.assertEqual(list(f), ["hello\n"])

Here is the call graph for this function:

Definition at line 30 of file test_popen.py.

00030 
00031     def test_popen(self):
00032         self.assertRaises(TypeError, os.popen)
00033         self._do_test_commandline(
00034             "foo bar",
00035             ["foo", "bar"]
00036         )
00037         self._do_test_commandline(
00038             'foo "spam and eggs" "silly walk"',
00039             ["foo", "spam and eggs", "silly walk"]
00040         )
00041         self._do_test_commandline(
00042             'foo "a \\"quoted\\" arg" bar',
00043             ["foo", 'a "quoted" arg', "bar"]
00044         )
00045         support.reap_children()

Here is the call graph for this function:

Definition at line 46 of file test_popen.py.

00046 
00047     def test_return_code(self):
00048         self.assertEqual(os.popen("exit 0").close(), None)
00049         if os.name == 'nt':
00050             self.assertEqual(os.popen("exit 42").close(), 42)
00051         else:
00052             self.assertEqual(os.popen("exit 42").close(), 42 << 8)

Here is the call graph for this function:


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