Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
test.test_shutil.TestMove Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_move_file
def test_move_file_to_dir
def test_move_file_other_fs
def test_move_file_to_dir_other_fs
def test_move_dir
def test_move_dir_other_fs
def test_move_dir_to_dir
def test_move_dir_to_dir_other_fs
def test_existing_file_inside_dest_dir
def test_dont_move_dir_in_itself
def test_destinsrc_false_negative
def test_destinsrc_false_positive

Public Attributes

 src_dir
 dst_dir
 src_file
 dst_file

Private Member Functions

def _check_move_file
def _check_move_dir

Detailed Description

Definition at line 738 of file test_shutil.py.


Member Function Documentation

def test.test_shutil.TestMove._check_move_dir (   self,
  src,
  dst,
  real_dst 
) [private]

Definition at line 765 of file test_shutil.py.

00765 
00766     def _check_move_dir(self, src, dst, real_dst):
00767         contents = sorted(os.listdir(src))
00768         shutil.move(src, dst)
00769         self.assertEqual(contents, sorted(os.listdir(real_dst)))
00770         self.assertFalse(os.path.exists(src))

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_shutil.TestMove._check_move_file (   self,
  src,
  dst,
  real_dst 
) [private]

Definition at line 757 of file test_shutil.py.

00757 
00758     def _check_move_file(self, src, dst, real_dst):
00759         with open(src, "rb") as f:
00760             contents = f.read()
00761         shutil.move(src, dst)
00762         with open(real_dst, "rb") as f:
00763             self.assertEqual(contents, f.read())
00764         self.assertFalse(os.path.exists(src))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 740 of file test_shutil.py.

00740 
00741     def setUp(self):
00742         filename = "foo"
00743         self.src_dir = tempfile.mkdtemp()
00744         self.dst_dir = tempfile.mkdtemp()
00745         self.src_file = os.path.join(self.src_dir, filename)
00746         self.dst_file = os.path.join(self.dst_dir, filename)
00747         with open(self.src_file, "wb") as f:
00748             f.write(b"spam")

Here is the caller graph for this function:

Definition at line 749 of file test_shutil.py.

00749 
00750     def tearDown(self):
00751         for d in (self.src_dir, self.dst_dir):
00752             try:
00753                 if d:
00754                     shutil.rmtree(d)
00755             except:
00756                 pass

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 826 of file test_shutil.py.

00826 
00827     def test_destinsrc_false_negative(self):
00828         os.mkdir(TESTFN)
00829         try:
00830             for src, dst in [('srcdir', 'srcdir/dest')]:
00831                 src = os.path.join(TESTFN, src)
00832                 dst = os.path.join(TESTFN, dst)
00833                 self.assertTrue(shutil._destinsrc(src, dst),
00834                              msg='_destinsrc() wrongly concluded that '
00835                              'dst (%s) is not in src (%s)' % (dst, src))
00836         finally:
00837             shutil.rmtree(TESTFN, ignore_errors=True)

Here is the call graph for this function:

Definition at line 838 of file test_shutil.py.

00838 
00839     def test_destinsrc_false_positive(self):
00840         os.mkdir(TESTFN)
00841         try:
00842             for src, dst in [('srcdir', 'src/dest'), ('srcdir', 'srcdir.new')]:
00843                 src = os.path.join(TESTFN, src)
00844                 dst = os.path.join(TESTFN, dst)
00845                 self.assertFalse(shutil._destinsrc(src, dst),
00846                             msg='_destinsrc() wrongly concluded that '
00847                             'dst (%s) is in src (%s)' % (dst, src))
00848         finally:
00849             shutil.rmtree(TESTFN, ignore_errors=True)
00850 

Here is the call graph for this function:

Definition at line 821 of file test_shutil.py.

00821 
00822     def test_dont_move_dir_in_itself(self):
00823         # Moving a dir inside itself raises an Error.
00824         dst = os.path.join(self.src_dir, "bar")
00825         self.assertRaises(shutil.Error, shutil.move, self.src_dir, dst)

Here is the call graph for this function:

Definition at line 815 of file test_shutil.py.

00815 
00816     def test_existing_file_inside_dest_dir(self):
00817         # A file with the same name inside the destination dir already exists.
00818         with open(self.dst_file, "wb"):
00819             pass
00820         self.assertRaises(shutil.Error, shutil.move, self.src_file, self.dst_dir)

Here is the call graph for this function:

Definition at line 789 of file test_shutil.py.

00789 
00790     def test_move_dir(self):
00791         # Move a dir to another location on the same filesystem.
00792         dst_dir = tempfile.mktemp()
00793         try:
00794             self._check_move_dir(self.src_dir, dst_dir, dst_dir)
00795         finally:
00796             try:
00797                 shutil.rmtree(dst_dir)
00798             except:
00799                 pass

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 801 of file test_shutil.py.

00801 
00802     def test_move_dir_other_fs(self):
00803         # Move a dir to another location on another filesystem.
00804         self.test_move_dir()

Here is the call graph for this function:

Definition at line 805 of file test_shutil.py.

00805 
00806     def test_move_dir_to_dir(self):
00807         # Move a dir inside an existing dir on the same filesystem.
00808         self._check_move_dir(self.src_dir, self.dst_dir,
00809             os.path.join(self.dst_dir, os.path.basename(self.src_dir)))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 811 of file test_shutil.py.

00811 
00812     def test_move_dir_to_dir_other_fs(self):
00813         # Move a dir inside an existing dir on another filesystem.
00814         self.test_move_dir_to_dir()

Here is the call graph for this function:

Definition at line 771 of file test_shutil.py.

00771 
00772     def test_move_file(self):
00773         # Move a file to another location on the same filesystem.
00774         self._check_move_file(self.src_file, self.dst_file, self.dst_file)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 780 of file test_shutil.py.

00780 
00781     def test_move_file_other_fs(self):
00782         # Move a file to an existing dir on another filesystem.
00783         self.test_move_file()

Here is the call graph for this function:

Definition at line 775 of file test_shutil.py.

00775 
00776     def test_move_file_to_dir(self):
00777         # Move a file inside an existing dir on the same filesystem.
00778         self._check_move_file(self.src_file, self.dst_dir, self.dst_file)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 785 of file test_shutil.py.

00785 
00786     def test_move_file_to_dir_other_fs(self):
00787         # Move a file to another location on another filesystem.
00788         self.test_move_file_to_dir()

Here is the call graph for this function:


Member Data Documentation

Definition at line 743 of file test_shutil.py.

Definition at line 745 of file test_shutil.py.

Definition at line 742 of file test_shutil.py.

Definition at line 744 of file test_shutil.py.


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