Changeset 5737 for main/waeup.sirp/trunk
- Timestamp:
- 12 Feb 2011, 15:20:06 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_helpers.py
r5735 r5737 20 20 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 21 ## 22 import os 23 import shutil 24 import tempfile 22 25 import unittest 23 26 import doctest … … 30 33 class FakeObject(object): 31 34 implements(IFakeObject) 35 36 class CopyFileSystemTreeTestCase(unittest.TestCase): 37 # Test edge cases of copyFileSystemTree(). 38 # 39 # This is a typical case of tests not written as doctest as it is 40 # normally not interesting for developers and we only want to make 41 # sure everything works as expected. 42 def setUp(self): 43 self.existing_src = tempfile.mkdtemp() 44 self.filepath = os.path.join(self.existing_src, 'somefile') 45 open(self.filepath, 'wb').write('Hi!') 46 self.existing_dst = tempfile.mkdtemp() 47 self.not_existing_dir = tempfile.mkdtemp() 48 shutil.rmtree(self.not_existing_dir) 49 50 pass 51 52 def tearDown(self): 53 shutil.rmtree(self.existing_src) 54 shutil.rmtree(self.existing_dst) 55 pass 56 57 def test_source_and_dst_existing(self): 58 helpers.copyFileSystemTree(self.existing_src, self.existing_dst) 59 self.assertTrue( 60 os.path.exists( 61 os.path.join(self.existing_dst, 'somefile') 62 ) 63 ) 64 return 65 66 def test_source_not_existing(self): 67 self.assertRaises( 68 ValueError, 69 helpers.copyFileSystemTree, 70 self.not_existing_dir, 71 self.existing_dst 72 ) 73 return 74 75 def test_dest_not_existing(self): 76 self.assertRaises( 77 ValueError, 78 helpers.copyFileSystemTree, 79 self.existing_src, 80 self.not_existing_dir 81 ) 82 return 83 84 def test_src_not_a_dir(self): 85 self.assertRaises( 86 ValueError, 87 helpers.copyFileSystemTree, 88 self.filepath, 89 self.existing_dst 90 ) 91 return 92 93 def test_dst_not_a_dir(self): 94 self.assertRaises( 95 ValueError, 96 helpers.copyFileSystemTree, 97 self.existing_src, 98 self.filepath 99 ) 100 return 101 32 102 33 103 class FactoryBaseTestCase(unittest.TestCase): … … 44 114 suite = unittest.TestSuite() 45 115 # Register local test cases... 46 for testcase in [FactoryBaseTestCase, ]: 116 for testcase in [ 117 FactoryBaseTestCase, 118 CopyFileSystemTreeTestCase, 119 ]: 47 120 suite.addTests( 48 121 unittest.TestLoader().loadTestsFromTestCase(testcase)
Note: See TracChangeset for help on using the changeset viewer.