Changeset 4961
- Timestamp:
- Jan 21, 2008, 10:24:47 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/test_system_tools.py
r4956 r4961 34 34 35 35 import zlib 36 from tempfile import NamedTemporaryFile, mk stemp, mktemp36 from tempfile import NamedTemporaryFile, mktemp 37 37 38 38 # Generate a text file 39 fid = open(mktemp(suffix='.tmp', 40 dir='.'), 'w') 39 fid = NamedTemporaryFile(mode='w', 40 suffix='.tmp', 41 dir='.') 41 42 string = 'My temp file with textual content. AAAABBBBCCCC1234' 42 43 fid.write(string) 43 fid. close()44 fid.flush() 44 45 45 46 … … 49 50 assert checksum == ref_crc 50 51 51 os.remove(fid.name) 52 # Close and remove temporary file 53 fid.close() 54 55 52 56 53 57 # Binary file 54 fid = open(mktemp(suffix='.tmp', 55 dir='.'), 'wb') 56 string = 'My temp file with textual content. AAAABBBBCCCC1234' 58 fid = NamedTemporaryFile(mode='w+b', 59 suffix='.tmp', 60 dir='.') 61 string = 'My temp file with binary content. AAAABBBBCCCC1234' 57 62 fid.write(string) 58 fid.close() 63 fid.flush() 64 59 65 60 66 ref_crc = zlib.crc32(string) … … 62 68 63 69 assert checksum == ref_crc 64 os.remove(fid.name) 70 71 # Close and remove temporary file 72 fid.close() 65 73 66 # Binary NetCDF File X 2 74 75 # Binary NetCDF File X 2 (use mktemp's name) 67 76 68 77 test_array = array([[7.0, 3.14], [-31.333, 0.0]])
Note: See TracChangeset
for help on using the changeset viewer.