Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.test_os.ExecTests Class Reference

List of all members.

Public Member Functions

def test_execvpe_with_bad_program
def test_execvpe_with_bad_arglist
def test_internal_execvpe_str

Private Member Functions

def _test_internal_execvpe

Detailed Description

Definition at line 637 of file test_os.py.


Member Function Documentation

def test.test_os.ExecTests._test_internal_execvpe (   self,
  test_type 
) [private]

Definition at line 649 of file test_os.py.

00649 
00650     def _test_internal_execvpe(self, test_type):
00651         program_path = os.sep + 'absolutepath'
00652         if test_type is bytes:
00653             program = b'executable'
00654             fullpath = os.path.join(os.fsencode(program_path), program)
00655             native_fullpath = fullpath
00656             arguments = [b'progname', 'arg1', 'arg2']
00657         else:
00658             program = 'executable'
00659             arguments = ['progname', 'arg1', 'arg2']
00660             fullpath = os.path.join(program_path, program)
00661             if os.name != "nt":
00662                 native_fullpath = os.fsencode(fullpath)
00663             else:
00664                 native_fullpath = fullpath
00665         env = {'spam': 'beans'}
00666 
00667         # test os._execvpe() with an absolute path
00668         with _execvpe_mockup() as calls:
00669             self.assertRaises(RuntimeError,
00670                 os._execvpe, fullpath, arguments)
00671             self.assertEqual(len(calls), 1)
00672             self.assertEqual(calls[0], ('execv', fullpath, (arguments,)))
00673 
00674         # test os._execvpe() with a relative path:
00675         # os.get_exec_path() returns defpath
00676         with _execvpe_mockup(defpath=program_path) as calls:
00677             self.assertRaises(OSError,
00678                 os._execvpe, program, arguments, env=env)
00679             self.assertEqual(len(calls), 1)
00680             self.assertSequenceEqual(calls[0],
00681                 ('execve', native_fullpath, (arguments, env)))
00682 
00683         # test os._execvpe() with a relative path:
00684         # os.get_exec_path() reads the 'PATH' variable
00685         with _execvpe_mockup() as calls:
00686             env_path = env.copy()
00687             if test_type is bytes:
00688                 env_path[b'PATH'] = program_path
00689             else:
00690                 env_path['PATH'] = program_path
00691             self.assertRaises(OSError,
00692                 os._execvpe, program, arguments, env=env_path)
00693             self.assertEqual(len(calls), 1)
00694             self.assertSequenceEqual(calls[0],
00695                 ('execve', native_fullpath, (arguments, env_path)))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 644 of file test_os.py.

00644 
00645     def test_execvpe_with_bad_arglist(self):
00646         self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)

Here is the call graph for this function:

Definition at line 640 of file test_os.py.

00640 
00641     def test_execvpe_with_bad_program(self):
00642         self.assertRaises(OSError, os.execvpe, 'no such app-',
00643                           ['no such app-'], None)

Here is the call graph for this function:

Definition at line 696 of file test_os.py.

00696 
00697     def test_internal_execvpe_str(self):
00698         self._test_internal_execvpe(str)
00699         if os.name != "nt":
00700             self._test_internal_execvpe(bytes)
00701 

Here is the call graph for this function:


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