Merged release21-maint changes.
[python/dscho.git] / Lib / test / test_binhex.py
blobc774200fd81c7ef5a13b7c8be24fa2d763abb04f
1 #! /usr/bin/env python
2 """Test script for the binhex C module
4 Uses the mechanism of the python binhex module
5 Based on an original test by Roger E. Masse.
6 """
7 import binhex
8 import os
9 import tempfile
10 import test_support
11 import unittest
14 class BinHexTestCase(unittest.TestCase):
16 def setUp(self):
17 self.fname1 = tempfile.mktemp()
18 self.fname2 = tempfile.mktemp()
20 def tearDown(self):
21 try: os.unlink(self.fname1)
22 except OSError: pass
24 try: os.unlink(self.fname2)
25 except OSError: pass
27 DATA = 'Jack is my hero'
29 def test_binhex(self):
30 f = open(self.fname1, 'w')
31 f.write(self.DATA)
32 f.close()
34 binhex.binhex(self.fname1, self.fname2)
36 binhex.hexbin(self.fname2, self.fname1)
38 f = open(self.fname1, 'r')
39 finish = f.readline()
40 f.close()
42 self.assertEqual(self.DATA, finish)
45 test_support.run_unittest(BinHexTestCase)