Changeset 6902 for branches/numpy/anuga/shallow_water/test_data_manager.py
 Timestamp:
 Apr 24, 2009, 5:22:14 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/numpy/anuga/shallow_water/test_data_manager.py
r6689 r6902 15 15 from struct import pack, unpack 16 16 from sets import ImmutableSet 17 import shutil 17 18 18 19 from anuga.shallow_water import * … … 47 48 48 49 self.verbose = Test_Data_Manager.verbose 49 # Create basic mesh50 # Create basic mesh 50 51 points, vertices, boundary = rectangular(2, 2) 51 52 52 # Create shallow water domain53 # Create shallow water domain 53 54 domain = Domain(points, vertices, boundary) 54 55 domain.default_order = 2 55 56 56 # Set some field values57 # Set some field values 57 58 domain.set_quantity('elevation', lambda x,y: x) 58 59 domain.set_quantity('friction', 0.03) … … 252 253 253 254 # Get the variables 254 #range = fid.variables['stage_range'][:]255 range = fid.variables['stage_range'][:] 255 256 #print range 256 #assert num.allclose(range,[0.93519, 0.15]) or\257 #num.allclose(range,[0.9352743, 0.15]) or\258 #num.allclose(range,[0.93522203, 0.15000001]) # Old slope limiters259 260 #range = fid.variables['xmomentum_range'][:]257 assert num.allclose(range,[0.93519, 0.15]) or\ 258 num.allclose(range,[0.9352743, 0.15]) or\ 259 num.allclose(range,[0.93522203, 0.15000001]) # Old slope limiters 260 261 range = fid.variables['xmomentum_range'][:] 261 262 ##print range 262 #assert num.allclose(range,[0,0.4695096]) or \263 #num.allclose(range,[0,0.47790655]) or\264 #num.allclose(range,[0,0.46941957]) or\265 #num.allclose(range,[0,0.47769409])266 267 268 #range = fid.variables['ymomentum_range'][:]263 assert num.allclose(range,[0,0.4695096]) or \ 264 num.allclose(range,[0,0.47790655]) or\ 265 num.allclose(range,[0,0.46941957]) or\ 266 num.allclose(range,[0,0.47769409]) 267 268 269 range = fid.variables['ymomentum_range'][:] 269 270 ##print range 270 #assert num.allclose(range,[0,0.02174380]) or\271 #num.allclose(range,[0,0.02174439]) or\272 #num.allclose(range,[0,0.02283983]) or\273 #num.allclose(range,[0,0.0217342]) or\274 #num.allclose(range,[0,0.0227564]) # Old slope limiters271 assert num.allclose(range,[0,0.02174380]) or\ 272 num.allclose(range,[0,0.02174439]) or\ 273 num.allclose(range,[0,0.02283983]) or\ 274 num.allclose(range,[0,0.0217342]) or\ 275 num.allclose(range,[0,0.0227564]) # Old slope limiters 275 276 276 277 fid.close() … … 1232 1233 from Scientific.IO.NetCDF import NetCDFFile 1233 1234 1234 # Setup1235 # Setup 1235 1236 self.domain.set_name('datatest') 1236 1237 … … 1245 1246 self.domain.set_quantity('stage', 1.0) 1246 1247 1247 self.domain.geo_reference = Geo_reference(56, 308500,6189000)1248 self.domain.geo_reference = Geo_reference(56, 308500, 6189000) 1248 1249 1249 1250 sww = get_dataobject(self.domain) … … 5563 5564 quantities_init[0].append(this_ha) # HA 5564 5565 quantities_init[1].append(this_ua) # UA 5565 quantities_init[2].append(this_va) # VA 5566 quantities_init[2].append(this_va) # VA 5566 5567 5567 5568 file_handle, base_name = tempfile.mkstemp("") … … 6104 6105 #print 'writing', time, point_i, q_time[time, point_i] 6105 6106 f.write(pack('f', q_time[time, point_i])) 6106 6107 6107 f.close() 6108 6108 … … 6215 6215 6216 6216 msg='Incorrect gauge depths returned' 6217 assert num.allclose(elevation, depth),msg6217 assert num.allclose(elevation, depth),msg 6218 6218 msg='incorrect gauge height time series returned' 6219 assert num.allclose(stage, ha)6219 assert num.allclose(stage, ha) 6220 6220 msg='incorrect gauge ua time series returned' 6221 assert num.allclose(xvelocity, ua)6221 assert num.allclose(xvelocity, ua) 6222 6222 msg='incorrect gauge va time series returned' 6223 6223 assert num.allclose(yvelocity, va) # South is positive in MUX … … 6397 6397 if j == 2: assert num.allclose(data[i][:parameters_index], va0[permutation[i], :]) 6398 6398 6399 self.delete_mux(filesI) 6399 6400 6400 6401 … … 6407 6408 wrong values Win32 6408 6409 6409 This test does not pass on Windows but test_read_mux_platform_problem1 does 6410 This test does not pass on Windows but test_read_mux_platform_problem1 6411 does 6410 6412 """ 6411 6413 … … 6422 6424 times_ref = num.arange(0, time_step_count*time_step, time_step) 6423 6425 6424 lat_long_points = [(21.5,114.5), (21,114.5), (21.5,115), (21.,115.), (22., 117.)] 6426 lat_long_points = [(21.5,114.5), (21,114.5), (21.5,115), 6427 (21.,115.), (22., 117.)] 6425 6428 n = len(lat_long_points) 6426 6429 … … 6466 6469 for j in range(0, first_tstep[i]1) + range(last_tstep[i], time_step_count): 6467 6470 # For timesteps before and after recording range 6468 ha1[i][j] = ua1[i][j] = va1[i][j] = 0.0 6471 ha1[i][j] = ua1[i][j] = va1[i][j] = 0.0 6469 6472 6470 6473 … … 6474 6477 #print 'va', va1[0,:] 6475 6478 6476 # Write second mux file to be combined by urs2sts 6479 # Write second mux file to be combined by urs2sts 6477 6480 base_nameII, filesII = self.write_mux2(lat_long_points, 6478 6481 time_step_count, time_step, … … 6605 6608 6606 6609 f.close() 6607 6608 6609 6610 6611 6612 6613 6614 6610 6615 6611 # Create ordering file 6616 6612 permutation = ensure_numeric([4,0,2]) 6617 6613 6618 _, ordering_filename = tempfile.mkstemp('') 6619 order_fid = open(ordering_filename, 'w') 6620 order_fid.write('index, longitude, latitude\n') 6621 for index in permutation: 6622 order_fid.write('%d, %f, %f\n' %(index, 6623 lat_long_points[index][1], 6624 lat_long_points[index][0])) 6625 order_fid.close() 6626 6627 6628 6614 # _, ordering_filename = tempfile.mkstemp('') 6615 # order_fid = open(ordering_filename, 'w') 6616 # order_fid.write('index, longitude, latitude\n') 6617 # for index in permutation: 6618 # order_fid.write('%d, %f, %f\n' %(index, 6619 # lat_long_points[index][1], 6620 # lat_long_points[index][0])) 6621 # order_fid.close() 6622 6629 6623 #  6630 6624 # Now read files back and check values … … 6638 6632 for j, file in enumerate(filesII): 6639 6633 # Read stage, u, v enumerated as j 6640 6641 6642 6634 #print 'Reading', j, file 6643 6635 data = read_mux2(1, [file], weights, file_params, permutation, verbose) … … 6645 6637 #print 'Data received by Python' 6646 6638 #print data[1][8] 6647 6648 6649 6639 number_of_selected_stations = data.shape[0] 6650 6640 … … 6659 6649 #print i, parameters_index 6660 6650 #print quantity[i][:] 6661 6662 6663 6651 if j == 0: assert num.allclose(data[i][:parameters_index], ha1[permutation[i], :]) 6664 6652 if j == 1: assert num.allclose(data[i][:parameters_index], ua1[permutation[i], :]) … … 6669 6657 #print j, i 6670 6658 #print 'Input' 6671 #print 'u', ua1[permutation[i], 8] 6659 #print 'u', ua1[permutation[i], 8] 6672 6660 #print 'v', va1[permutation[i], 8] 6673 6661 6674 6662 #print 'Output' 6675 #print 'v ', data[i][:parameters_index][8] 6663 #print 'v ', data[i][:parameters_index][8] 6664 6665 # South is positive in MUX 6666 #print "data[i][:parameters_index]", data[i][:parameters_index] 6667 #print "va1[permutation[i], :]", va1[permutation[i], :] 6668 assert num.allclose(data[i][:parameters_index], va1[permutation[i], :]) 6669 6670 self.delete_mux(filesII) 6671 6672 def test_read_mux_platform_problem3(self): 6673 6674 # This is to test a situation where read_mux returned 6675 # wrong values Win32 6676 6677 6678 from urs_ext import read_mux2 6679 6680 from anuga.config import single_precision as epsilon 6681 6682 verbose = False 6676 6683 6677 # South is positive in MUX 6684 tide = 1.5 6685 time_step_count = 10 6686 time_step = 0.02 6687 6688 ''' 6689 Win results 6690 time_step = 0.2000001 6691 This is OK 6692 ''' 6693 6694 ''' 6695 Win results 6696 time_step = 0.20000001 6697 6698 ====================================================================== 6699 ERROR: test_read_mux_platform_problem3 (__main__.Test_Data_Manager) 6700  6701 Traceback (most recent call last): 6702 File "test_data_manager.py", line 6718, in test_read_mux_platform_problem3 6703 ha1[0]=num.sin(times_ref) 6704 ValueError: matrices are not aligned for copy 6705 6706 ''' 6707 6708 ''' 6709 Win results 6710 time_step = 0.200000001 6711 FAIL 6712 assert num.allclose(data[i][:parameters_index], 6713 va1[permutation[i], :]) 6714 ''' 6715 times_ref = num.arange(0, time_step_count*time_step, time_step) 6716 #print "times_ref", times_ref 6717 6718 lat_long_points = [(21.5,114.5), (21,114.5), (21.5,115), 6719 (21.,115.), (22., 117.)] 6720 stations = len(lat_long_points) 6721 6722 # Create different timeseries starting and ending at different times 6723 first_tstep=num.ones(stations, num.int) 6724 first_tstep[0]+=2 # Point 0 starts at 2 6725 first_tstep[1]+=4 # Point 1 starts at 4 6726 first_tstep[2]+=3 # Point 2 starts at 3 6727 6728 last_tstep=(time_step_count)*num.ones(stations, num.int) 6729 last_tstep[0]=1 # Point 0 ends 1 step early 6730 last_tstep[1]=2 # Point 1 ends 2 steps early 6731 last_tstep[4]=3 # Point 4 ends 3 steps early 6732 6733 # Create varying elevation data (positive values for seafloor) 6734 gauge_depth=20*num.ones(stations, num.float) 6735 for i in range(stations): 6736 gauge_depth[i] += i**2 6737 6738 # Create data to be written to second mux file 6739 ha1=num.ones((stations,time_step_count), num.float) 6740 ha1[0]=num.sin(times_ref) 6741 ha1[1]=2*num.sin(times_ref  3) 6742 ha1[2]=5*num.sin(4*times_ref) 6743 ha1[3]=num.sin(times_ref) 6744 ha1[4]=num.sin(2*times_ref0.7) 6745 6746 ua1=num.zeros((stations,time_step_count),num.float) 6747 ua1[0]=3*num.cos(times_ref) 6748 ua1[1]=2*num.sin(times_ref0.7) 6749 ua1[2]=num.arange(3*time_step_count,4*time_step_count) 6750 ua1[4]=2*num.ones(time_step_count) 6751 6752 va1=num.zeros((stations,time_step_count),num.float) 6753 va1[0]=2*num.cos(times_ref0.87) 6754 va1[1]=3*num.ones(time_step_count) 6755 va1[3]=2*num.sin(times_ref0.71) 6756 #print "va1[0]", va1[0] # The 8th element is what will go bad. 6757 # Ensure data used to write mux file to be zero when gauges are 6758 # not recording 6759 for i in range(stations): 6760 # For each point 6761 for j in range(0, first_tstep[i]1) + range(last_tstep[i], 6762 time_step_count): 6763 # For timesteps before and after recording range 6764 ha1[i][j] = ua1[i][j] = va1[i][j] = 0.0 6765 6766 6767 #print 'Second station to be written to MUX' 6768 #print 'ha', ha1[0,:] 6769 #print 'ua', ua1[0,:] 6770 #print 'va', va1[0,:] 6771 6772 # Write second mux file to be combined by urs2sts 6773 base_nameII, filesII = self.write_mux2(lat_long_points, 6774 time_step_count, time_step, 6775 first_tstep, last_tstep, 6776 depth=gauge_depth, 6777 ha=ha1, 6778 ua=ua1, 6779 va=va1) 6780 #print "filesII", filesII 6781 6782 6783 6784 6785 # Read mux file back and verify it's correcness 6786 6787 #################################################### 6788 # FIXME (Ole): This is where the test should 6789 # verify that the MUX files are correct. 6790 6791 #JJ: It appears as though 6792 #that certain quantities are not being stored with enough precision 6793 #inn muxfile or more likely that they are being cast into a 6794 #lower precision when read in using read_mux2 Time step and q_time 6795 # are equal but only to approx 1e7 6796 #################################################### 6797 6798 #define information as it should be stored in mus2 files 6799 points_num=len(lat_long_points) 6800 depth=gauge_depth 6801 ha=ha1 6802 ua=ua1 6803 va=va1 6804 6805 quantities = ['HA','UA','VA'] 6806 mux_names = [WAVEHEIGHT_MUX2_LABEL, 6807 EAST_VELOCITY_MUX2_LABEL, 6808 NORTH_VELOCITY_MUX2_LABEL] 6809 quantities_init = [[],[],[]] 6810 latlondeps = [] 6811 #irrelevant header information 6812 ig=ilon=ilat=0 6813 mcolat=mcolon=centerlat=centerlon=offset=az=baz=id=0.0 6814 # urs binary is latitude fastest 6815 for i,point in enumerate(lat_long_points): 6816 lat = point[0] 6817 lon = point[1] 6818 _ , e, n = redfearn(lat, lon) 6819 if depth is None: 6820 this_depth = n 6821 else: 6822 this_depth = depth[i] 6823 latlondeps.append([lat, lon, this_depth]) 6824 6825 if ha is None: 6826 this_ha = e 6827 quantities_init[0].append(num.ones(time_step_count, 6828 num.float)*this_ha) # HA 6829 else: 6830 quantities_init[0].append(ha[i]) 6831 if ua is None: 6832 this_ua = n 6833 quantities_init[1].append(num.ones(time_step_count, 6834 num.float)*this_ua) # UA 6835 else: 6836 quantities_init[1].append(ua[i]) 6837 if va is None: 6838 this_va = e 6839 quantities_init[2].append(num.ones(time_step_count, 6840 num.float)*this_va) # 6841 else: 6842 quantities_init[2].append(va[i]) 6843 6844 for i, q in enumerate(quantities): 6845 #print 6846 #print i, q 6847 6848 q_time = num.zeros((time_step_count, points_num), num.float) 6849 quantities_init[i] = ensure_numeric(quantities_init[i]) 6850 for time in range(time_step_count): 6851 #print i, q, time, quantities_init[i][:,time] 6852 q_time[time,:] = quantities_init[i][:,time] 6853 #print i, q, time, q_time[time, :] 6854 6855 6856 filename = base_nameII + mux_names[i] 6857 f = open(filename, 'rb') 6858 if self.verbose: print 'Reading' + filename 6859 assert abs(points_numunpack('i',f.read(4))[0])<epsilon 6860 #write mux 2 header 6861 for latlondep in latlondeps: 6862 assert abs(latlondep[0]unpack('f',f.read(4))[0])<epsilon 6863 assert abs(latlondep[1]unpack('f',f.read(4))[0])<epsilon 6864 assert abs(mcolatunpack('f',f.read(4))[0])<epsilon 6865 assert abs(mcolonunpack('f',f.read(4))[0])<epsilon 6866 assert abs(igunpack('i',f.read(4))[0])<epsilon 6867 assert abs(ilonunpack('i',f.read(4))[0])<epsilon 6868 assert abs(ilatunpack('i',f.read(4))[0])<epsilon 6869 assert abs(latlondep[2]unpack('f',f.read(4))[0])<epsilon 6870 assert abs(centerlatunpack('f',f.read(4))[0])<epsilon 6871 assert abs(centerlonunpack('f',f.read(4))[0])<epsilon 6872 assert abs(offsetunpack('f',f.read(4))[0])<epsilon 6873 assert abs(azunpack('f',f.read(4))[0])<epsilon 6874 assert abs(bazunpack('f',f.read(4))[0])<epsilon 6875 6876 x = unpack('f', f.read(4))[0] 6877 #print time_step 6878 #print x 6879 assert abs(time_stepx)<epsilon 6880 assert abs(time_step_countunpack('i',f.read(4))[0])<epsilon 6881 for j in range(4): # identifier 6882 assert abs(idunpack('i',f.read(4))[0])<epsilon 6883 6884 #first_tstep=1 6885 #last_tstep=time_step_count 6886 for i,latlondep in enumerate(latlondeps): 6887 assert abs(first_tstep[i]unpack('i',f.read(4))[0])<epsilon 6888 for i,latlondep in enumerate(latlondeps): 6889 assert abs(last_tstep[i]unpack('i',f.read(4))[0])<epsilon 6890 6891 # Find when first station starts recording 6892 min_tstep = min(first_tstep) 6893 # Find when all stations have stopped recording 6894 max_tstep = max(last_tstep) 6895 6896 #for time in range(time_step_count): 6897 for time in range(min_tstep1,max_tstep): 6898 assert abs(time*time_stepunpack('f',f.read(4))[0])<epsilon 6899 for point_i in range(points_num): 6900 if time+1>=first_tstep[point_i] and time+1<=last_tstep[point_i]: 6901 x = unpack('f',f.read(4))[0] 6902 #print time, x, q_time[time, point_i] 6903 if q == 'VA': x = x # South is positive in MUX 6904 #print q+" q_time[%d, %d] = %f" %(time, point_i, 6905 #q_time[time, point_i]) 6906 assert abs(q_time[time, point_i]x)<epsilon 6907 6908 f.close() 6909 6910 permutation = ensure_numeric([4,0,2]) 6911 6912 # Create ordering file 6913 # _, ordering_filename = tempfile.mkstemp('') 6914 # order_fid = open(ordering_filename, 'w') 6915 # order_fid.write('index, longitude, latitude\n') 6916 # for index in permutation: 6917 # order_fid.write('%d, %f, %f\n' %(index, 6918 # lat_long_points[index][1], 6919 # lat_long_points[index][0])) 6920 # order_fid.close() 6921 6922 #  6923 # Now read files back and check values 6924 weights = ensure_numeric([1.0]) 6925 6926 # For each quantity read the associated list of source mux2 file with 6927 # extention associated with that quantity 6928 file_params=1*num.ones(3,num.float) # [nsta,dt,nt] 6929 OFFSET = 5 6930 6931 for j, file in enumerate(filesII): 6932 # Read stage, u, v enumerated as j 6933 #print 'Reading', j, file 6934 #print "file", file 6935 data = read_mux2(1, [file], weights, file_params, 6936 permutation, verbose) 6937 #print str(j) + "data", data 6938 6939 #print 'Data received by Python' 6940 #print data[1][8] 6941 number_of_selected_stations = data.shape[0] 6942 #print "number_of_selected_stations", number_of_selected_stations 6943 #print "stations", stations 6944 6945 # Index where data ends and parameters begin 6946 parameters_index = data.shape[1]OFFSET 6947 6948 for i in range(number_of_selected_stations): 6949 6950 #print i, parameters_index 6951 if j == 0: 6952 assert num.allclose(data[i][:parameters_index], 6953 ha1[permutation[i], :]) 6954 6955 if j == 1: assert num.allclose(data[i][:parameters_index], ua1[permutation[i], :]) 6956 if j == 2: 6678 6957 assert num.allclose(data[i][:parameters_index], va1[permutation[i], :]) 6679 6958 6959 self.delete_mux(filesII) 6680 6960 6681 6961 def test_urs2sts0(self): … … 6819 7099 6820 7100 base_name, files = self.write_mux2(lat_long_points, 6821 time_step_count, time_step,6822 first_tstep, last_tstep,6823 depth=gauge_depth,6824 ha=ha,6825 ua=ua,6826 va=va)7101 time_step_count, time_step, 7102 first_tstep, last_tstep, 7103 depth=gauge_depth, 7104 ha=ha, 7105 ua=ua, 7106 va=va) 6827 7107 6828 7108 urs2sts(base_name, … … 6850 7130 y = points[:,1] 6851 7131 6852 # Check that all coordinate are correctly represented6853 # Using the non standard projection (50)7132 # Check that all coordinate are correctly represented 7133 # Using the non standard projection (50) 6854 7134 for i in range(4): 6855 7135 zone, e, n = redfearn(lat_long_points[i][0], … … 6858 7138 assert num.allclose([x[i],y[i]], [e,n]) 6859 7139 assert zone==1 7140 7141 self.delete_mux(files) 6860 7142 6861 7143 … … 6915 7197 y = points[:,1] 6916 7198 6917 # Check that all coordinate are correctly represented6918 # Using the non standard projection (50)7199 # Check that all coordinate are correctly represented 7200 # Using the non standard projection (50) 6919 7201 for i in range(4): 6920 7202 zone, e, n = redfearn(lat_long_points[i][0], lat_long_points[i][1], … … 6922 7204 assert num.allclose([x[i],y[i]], [e,n]) 6923 7205 assert zone==geo_reference.zone 7206 7207 self.delete_mux(files) 6924 7208 6925 7209 … … 7652 7936 raise Exception, msg 7653 7937 7938 7939 self.delete_mux(filesI) 7940 self.delete_mux(filesII) 7654 7941 7655 7942 … … 8034 8321 os.remove(sts_file) 8035 8322 8036 8037 8038 8323 # 8039 8324 # Then read the mux files together and test … … 8148 8433 os.remove(sts_file) 8149 8434 8150 8151 8152 8435 # 8153 8436 # "Manually" add the timeseries up with weights and test … … 8157 8440 stage_man = weights[0]*(stage0tide) + weights[1]*(stage1tide) + tide 8158 8441 assert num.allclose(stage_man, stage) 8159 8160 8161 8162 8163 8164 8442 8165 8443 … … 8288 8566 8289 8567 assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values, 8290 domain_drchlt.quantities['xmomentum'].vertex_values) 8568 domain_drchlt.quantities['xmomentum'].vertex_values) 8291 8569 8292 8570 assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values, 8293 domain_drchlt.quantities['ymomentum'].vertex_values) 8571 domain_drchlt.quantities['ymomentum'].vertex_values) 8294 8572 8295 8573 8296 8574 os.remove(sts_file+'.sts') 8297 8575 os.remove(meshname) 8298 8299 8300 8301 8576 8302 8577 … … 8419 8694 8420 8695 8421 8422 8423 8424 8425 8426 8427 8428 8696 domain_drchlt = Domain(meshname) 8429 8697 domain_drchlt.set_quantity('stage', tide) … … 8447 8715 8448 8716 assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values, 8449 domain_drchlt.quantities['xmomentum'].vertex_values) 8717 domain_drchlt.quantities['xmomentum'].vertex_values) 8450 8718 8451 8719 assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values, 8452 domain_drchlt.quantities['ymomentum'].vertex_values) 8453 8720 domain_drchlt.quantities['ymomentum'].vertex_values) 8454 8721 8455 8722 os.remove(sts_file+'.sts') 8456 8723 os.remove(meshname) 8457 8458 8459 8460 8724 8461 8725 … … 10934 11198 domain.set_quantity('xmomentum', uh) 10935 11199 domain.set_boundary( {'left': Bd, 'right': Bd, 'top': Br, 'bottom': Br}) 11200 10936 11201 for t in domain.evolve(yieldstep=1, finaltime = t_end): 10937 11202 pass … … 11357 11622 11358 11623 11624 def test_copy_code_files(self): 11625 '''test that the copy_code_files() function is sane.''' 11626 11627 def create_file(f): 11628 fd = open(f, 'w') 11629 fd.write('%s\n' % f) 11630 fd.close() 11631 11632 # create working directories and test files 11633 work_dir = tempfile.mkdtemp() 11634 dst_dir = tempfile.mkdtemp(dir=work_dir) 11635 src_dir = tempfile.mkdtemp(dir=work_dir) 11636 11637 f1 = 'file1' 11638 filename1 = os.path.join(src_dir, f1) 11639 create_file(filename1) 11640 f2 = 'file2' 11641 filename2 = os.path.join(src_dir, f2) 11642 create_file(filename2) 11643 f3 = 'file3' 11644 filename3 = os.path.join(src_dir, f3) 11645 create_file(filename3) 11646 f4 = 'file4' 11647 filename4 = os.path.join(src_dir, f4) 11648 create_file(filename4) 11649 f5 = 'file5' 11650 filename5 = os.path.join(src_dir, f5) 11651 create_file(filename5) 11652 11653 # exercise the copy function 11654 copy_code_files(dst_dir, filename1) 11655 copy_code_files(dst_dir, filename1, filename2) 11656 copy_code_files(dst_dir, (filename4, filename5, filename3)) 11657 11658 # test that files were actually copied 11659 self.failUnless(access(os.path.join(dst_dir, f1), F_OK)) 11660 self.failUnless(access(os.path.join(dst_dir, f2), F_OK)) 11661 self.failUnless(access(os.path.join(dst_dir, f3), F_OK)) 11662 self.failUnless(access(os.path.join(dst_dir, f4), F_OK)) 11663 self.failUnless(access(os.path.join(dst_dir, f5), F_OK)) 11664 11665 # clean up 11666 shutil.rmtree(work_dir) 11359 11667 11360 11668 # … … 11362 11670 if __name__ == "__main__": 11363 11671 suite = unittest.makeSuite(Test_Data_Manager,'test') 11364 11365 # FIXME (Ole): This is the test that fails under Windows11366 #suite = unittest.makeSuite(Test_Data_Manager,'test_read_mux_platform_problem2')11367 #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsIV')11368 11672 11369 11673 if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
Note: See TracChangeset
for help on using the changeset viewer.