Files for 2.1b1 distribution.
[python/dscho.git] / Lib / test / test_binhex.py
bloba2b2a2c56be9291fb6c55ae4035f1524bb1138e6
1 #! /usr/bin/env python
2 """Test script for the binhex C module
4 Uses the mechanism of the python binhex module
5 Roger E. Masse
6 """
7 import binhex
8 import tempfile
9 from test_support import verbose, TestSkipped
11 def test():
13 try:
14 fname1 = tempfile.mktemp()
15 fname2 = tempfile.mktemp()
16 f = open(fname1, 'w')
17 except:
18 raise TestSkipped, "Cannot test binhex without a temp file"
20 start = 'Jack is my hero'
21 f.write(start)
22 f.close()
24 binhex.binhex(fname1, fname2)
25 if verbose:
26 print 'binhex'
28 binhex.hexbin(fname2, fname1)
29 if verbose:
30 print 'hexbin'
32 f = open(fname1, 'r')
33 finish = f.readline()
34 f.close() # on Windows an open file cannot be unlinked
36 if start != finish:
37 print 'Error: binhex != hexbin'
38 elif verbose:
39 print 'binhex == hexbin'
41 try:
42 import os
43 os.unlink(fname1)
44 os.unlink(fname2)
45 except:
46 pass
47 test()