Back to index

python3.2  3.2.2
Classes | Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes
test.test_shutil.TestCopyFile Class Reference

List of all members.

Classes

class  Faux

Public Member Functions

def tearDown
def test_w_source_open_fails
def test_w_dest_open_fails
def test_w_dest_close_fails
def test_w_source_close_fails
def test_move_dir_caseinsensitive

Public Attributes

 src_dir

Private Member Functions

def _set_shutil_open

Static Private Attributes

 _delete = False

Detailed Description

Definition at line 851 of file test_shutil.py.


Member Function Documentation

def test.test_shutil.TestCopyFile._set_shutil_open (   self,
  func 
) [private]

Definition at line 877 of file test_shutil.py.

00877 
00878     def _set_shutil_open(self, func):
00879         shutil.open = func
00880         self._delete = True

Here is the caller graph for this function:

Definition at line 873 of file test_shutil.py.

00873 
00874     def tearDown(self):
00875         if self._delete:
00876             del shutil.open

Here is the caller graph for this function:

Definition at line 954 of file test_shutil.py.

00954 
00955     def test_move_dir_caseinsensitive(self):
00956         # Renames a folder to the same name
00957         # but a different case.
00958 
00959         self.src_dir = tempfile.mkdtemp()
00960         dst_dir = os.path.join(
00961                 os.path.dirname(self.src_dir),
00962                 os.path.basename(self.src_dir).upper())
00963         self.assertNotEqual(self.src_dir, dst_dir)
00964 
00965         try:
00966             shutil.move(self.src_dir, dst_dir)
00967             self.assertTrue(os.path.isdir(dst_dir))
00968         finally:
00969             if os.path.exists(dst_dir):
00970                 os.rmdir(dst_dir)
00971 
00972 

Definition at line 910 of file test_shutil.py.

00910 
00911     def test_w_dest_close_fails(self):
00912 
00913         srcfile = self.Faux()
00914         destfile = self.Faux(True)
00915 
00916         def _open(filename, mode='r'):
00917             if filename == 'srcfile':
00918                 return srcfile
00919             if filename == 'destfile':
00920                 return destfile
00921             assert 0  # shouldn't reach here.
00922 
00923         self._set_shutil_open(_open)
00924 
00925         shutil.copyfile('srcfile', 'destfile')
00926         self.assertTrue(srcfile._entered)
00927         self.assertTrue(destfile._entered)
00928         self.assertTrue(destfile._raised)
00929         self.assertTrue(srcfile._exited_with[0] is IOError)
00930         self.assertEqual(srcfile._exited_with[1].args,
00931                          ('Cannot close',))

Here is the call graph for this function:

Definition at line 891 of file test_shutil.py.

00891 
00892     def test_w_dest_open_fails(self):
00893 
00894         srcfile = self.Faux()
00895 
00896         def _open(filename, mode='r'):
00897             if filename == 'srcfile':
00898                 return srcfile
00899             if filename == 'destfile':
00900                 raise IOError('Cannot open "destfile"')
00901             assert 0  # shouldn't reach here.
00902 
00903         self._set_shutil_open(_open)
00904 
00905         shutil.copyfile('srcfile', 'destfile')
00906         self.assertTrue(srcfile._entered)
00907         self.assertTrue(srcfile._exited_with[0] is IOError)
00908         self.assertEqual(srcfile._exited_with[1].args,
00909                          ('Cannot open "destfile"',))

Here is the call graph for this function:

Definition at line 932 of file test_shutil.py.

00932 
00933     def test_w_source_close_fails(self):
00934 
00935         srcfile = self.Faux(True)
00936         destfile = self.Faux()
00937 
00938         def _open(filename, mode='r'):
00939             if filename == 'srcfile':
00940                 return srcfile
00941             if filename == 'destfile':
00942                 return destfile
00943             assert 0  # shouldn't reach here.
00944 
00945         self._set_shutil_open(_open)
00946 
00947         self.assertRaises(IOError,
00948                           shutil.copyfile, 'srcfile', 'destfile')
00949         self.assertTrue(srcfile._entered)
00950         self.assertTrue(destfile._entered)
00951         self.assertFalse(destfile._raised)
00952         self.assertTrue(srcfile._exited_with[0] is None)
00953         self.assertTrue(srcfile._raised)

Here is the call graph for this function:

Definition at line 881 of file test_shutil.py.

00881 
00882     def test_w_source_open_fails(self):
00883         def _open(filename, mode='r'):
00884             if filename == 'srcfile':
00885                 raise IOError('Cannot open "srcfile"')
00886             assert 0  # shouldn't reach here.
00887 
00888         self._set_shutil_open(_open)
00889 
00890         self.assertRaises(IOError, shutil.copyfile, 'srcfile', 'destfile')

Here is the call graph for this function:


Member Data Documentation

test.test_shutil.TestCopyFile._delete = False [static, private]

Definition at line 853 of file test_shutil.py.

Definition at line 958 of file test_shutil.py.


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