Skip to content

Commit

Permalink
tests: properly test for directory existence using os.path.isdir
Browse files Browse the repository at this point in the history
  • Loading branch information
rpodgorny committed Dec 29, 2024
1 parent 5dd6d28 commit c03ca3a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,21 @@ def test_rename_common_dir(self):

os.rename('union/common_dir', 'union/common_dir_renamed')

self.assertFalse(os.path.exists('union/common_dir'))
self.assertFalse(os.path.isdir('union/common_dir'))
self.assertTrue(os.path.isdir('union/common_dir_renamed'))
self.assertEqual(set(os.listdir('union/common_dir_renamed')), set(common_dir_contents))
self.assertEqual(read_from_file('union/common_dir_renamed/ro_common_file'), 'ro1')
self.assertEqual(read_from_file('union/common_dir_renamed/common_file'), 'rw1')

self.assertTrue(os.path.isdir('ro2/common_dir'))
self.assertFalse(os.path.exists('ro2/common_dir_renamed'))
self.assertFalse(os.path.isdir('ro2/common_dir_renamed'))
self.assertEqual(set(os.listdir('ro2/common_dir')), set(['ro2_file', 'ro_common_file', 'common_file']))

self.assertTrue(os.path.isdir('ro1/common_dir'))
self.assertFalse(os.path.exists('ro1/common_dir_renamed'))
self.assertFalse(os.path.isdir('ro1/common_dir_renamed'))
self.assertEqual(set(os.listdir('ro1/common_dir')), set(['ro1_file', 'ro_common_file', 'common_file']))

self.assertFalse(os.path.exists('rw1/common_dir'))
self.assertFalse(os.path.isdir('rw1/common_dir'))
self.assertTrue(os.path.isdir('rw1/common_dir_renamed'))
self.assertEqual(set(os.listdir('rw1/common_dir_renamed')), set(common_dir_contents))
self.assertEqual(read_from_file('rw1/common_dir_renamed/ro_common_file'), 'ro1')
Expand Down Expand Up @@ -354,7 +354,7 @@ def test_rename_file_masking_directory(self):
os.rename('union/common_empty_dir', 'union/common_empty_dir_renamed')

self.assertEqual(read_from_file('union/common_empty_dir_renamed'), 'this is a file')
self.assertFalse(os.path.exists('union/common_empty_dir'))
self.assertFalse(os.path.isdir('union/common_empty_dir'))

def test_rename_onto_lower(self):
os.rename('union/rw1_file', 'union/ro1_file')
Expand Down Expand Up @@ -420,11 +420,11 @@ def test_rmdir(self):

os.remove('union/rw1_dir/rw1_file')
os.rmdir('union/rw1_dir')
self.assertFalse(os.path.exists('union/rw1_dir'))
self.assertFalse(os.path.exists('rw1/rw1_dir'))
self.assertFalse(os.path.isdir('union/rw1_dir'))
self.assertFalse(os.path.isdir('rw1/rw1_dir'))

os.rmdir('union/common_empty_dir')
self.assertFalse(os.path.exists('union/common_empty_dir'))
self.assertFalse(os.path.isdir('union/common_empty_dir'))

os.remove('union/common_dir/common_file')
os.remove('union/common_dir/ro_common_file')
Expand All @@ -433,7 +433,7 @@ def test_rmdir(self):
os.remove('union/common_dir/ro1_file')
os.remove('union/common_dir/rw1_file')
os.rmdir('union/common_dir')
self.assertFalse(os.path.exists('union/common_dir'))
self.assertFalse(os.path.isdir('union/common_dir'))


class UnionFS_RO_RW_TestCase(Common, unittest.TestCase):
Expand Down

0 comments on commit c03ca3a

Please sign in to comment.