1997-01-16 12:44:09 -04:00
|
|
|
#! /usr/bin/env python
|
1999-10-19 14:48:54 -03:00
|
|
|
"""Test script for the binhex C module
|
1997-01-16 12:44:09 -04:00
|
|
|
|
|
|
|
Uses the mechanism of the python binhex module
|
|
|
|
Roger E. Masse
|
|
|
|
"""
|
|
|
|
import binhex
|
|
|
|
import tempfile
|
2001-01-17 17:51:36 -04:00
|
|
|
from test_support import verbose, TestSkipped
|
1997-01-16 12:44:09 -04:00
|
|
|
|
|
|
|
def test():
|
|
|
|
|
|
|
|
try:
|
1998-03-26 15:42:58 -04:00
|
|
|
fname1 = tempfile.mktemp()
|
|
|
|
fname2 = tempfile.mktemp()
|
|
|
|
f = open(fname1, 'w')
|
1997-01-16 12:44:09 -04:00
|
|
|
except:
|
2000-08-04 10:34:43 -03:00
|
|
|
raise TestSkipped, "Cannot test binhex without a temp file"
|
1997-01-16 12:44:09 -04:00
|
|
|
|
|
|
|
start = 'Jack is my hero'
|
|
|
|
f.write(start)
|
|
|
|
f.close()
|
2000-10-23 14:22:08 -03:00
|
|
|
|
1997-01-16 12:44:09 -04:00
|
|
|
binhex.binhex(fname1, fname2)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'binhex'
|
1997-01-16 12:44:09 -04:00
|
|
|
|
|
|
|
binhex.hexbin(fname2, fname1)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'hexbin'
|
1997-01-16 12:44:09 -04:00
|
|
|
|
|
|
|
f = open(fname1, 'r')
|
|
|
|
finish = f.readline()
|
2001-01-17 14:59:46 -04:00
|
|
|
f.close() # on Windows an open file cannot be unlinked
|
1997-01-16 12:44:09 -04:00
|
|
|
|
2000-12-12 19:11:42 -04:00
|
|
|
if start != finish:
|
|
|
|
print 'Error: binhex != hexbin'
|
1997-01-16 12:44:09 -04:00
|
|
|
elif verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'binhex == hexbin'
|
1997-01-16 12:44:09 -04:00
|
|
|
|
1997-01-16 14:53:01 -04:00
|
|
|
try:
|
1998-03-26 15:42:58 -04:00
|
|
|
import os
|
|
|
|
os.unlink(fname1)
|
|
|
|
os.unlink(fname2)
|
1997-01-16 14:53:01 -04:00
|
|
|
except:
|
1998-03-26 15:42:58 -04:00
|
|
|
pass
|
1997-01-16 12:44:09 -04:00
|
|
|
test()
|