Ignore:
Timestamp:
Apr 22, 2009, 11:19:26 AM (14 years ago)
Author:
rwilson
Message:

Made copy_code_files() copy any number of files, plus testcase.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r6752 r6873  
    1515from struct import pack, unpack
    1616from sets import ImmutableSet
     17import shutil
    1718
    1819from anuga.shallow_water import *
     
    1162711628
    1162811629           
     11630    def test_copy_code_files(self):
     11631        '''test that the copy_code_files() function is sane.'''
     11632
     11633        def create_file(f):
     11634            fd = open(f, 'w')
     11635            fd.write('%s\n' % f)
     11636            fd.close()
     11637
     11638        # create working directories and test files
     11639        work_dir = tempfile.mkdtemp()
     11640        dst_dir = tempfile.mkdtemp(dir=work_dir)
     11641        src_dir = tempfile.mkdtemp(dir=work_dir)
     11642
     11643        f1 = 'file1'       
     11644        filename1 = os.path.join(src_dir, f1)
     11645        create_file(filename1)
     11646        f2 = 'file2'       
     11647        filename2 = os.path.join(src_dir, f2)
     11648        create_file(filename2)
     11649        f3 = 'file3'       
     11650        filename3 = os.path.join(src_dir, f3)
     11651        create_file(filename3)
     11652        f4 = 'file4'       
     11653        filename4 = os.path.join(src_dir, f4)
     11654        create_file(filename4)
     11655        f5 = 'file5'       
     11656        filename5 = os.path.join(src_dir, f5)
     11657        create_file(filename5)
     11658
     11659        # exercise the copy function
     11660        copy_code_files(dst_dir, filename1)
     11661        copy_code_files(dst_dir, filename1, filename2)
     11662        copy_code_files(dst_dir, (filename4, filename5, filename3))
     11663
     11664        # test that files were actually copied
     11665        self.failUnless(access(os.path.join(dst_dir, f1), F_OK))
     11666        self.failUnless(access(os.path.join(dst_dir, f2), F_OK))
     11667        self.failUnless(access(os.path.join(dst_dir, f3), F_OK))
     11668        self.failUnless(access(os.path.join(dst_dir, f4), F_OK))
     11669        self.failUnless(access(os.path.join(dst_dir, f5), F_OK))
     11670
     11671        # clean up
     11672        shutil.rmtree(work_dir)
    1162911673           
    1163011674#-------------------------------------------------------------
     
    1163211676
    1163311677    suite = unittest.makeSuite(Test_Data_Manager,'test')
    11634     #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_sts')
    11635     #suite = unittest.makeSuite(Test_Data_Manager,'test_get_flow_through_cross_section_with_geo')
    11636     #suite = unittest.makeSuite(Test_Data_Manager,'covered_')
    11637     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_individual_sources')
    11638     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_ordering_different_sources')
    11639 
    11640     #suite = unittest.makeSuite(Test_Data_Manager,'test_read_mux_platform_problem3')
    11641     #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsIV')
    11642 
    1164311678   
    1164411679    if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
Note: See TracChangeset for help on using the changeset viewer.