Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / lib / python2.4 / test / test_binhex.py
CommitLineData
920dae64
AT
1#! /usr/bin/env python
2"""Test script for the binhex C module
3
4 Uses the mechanism of the python binhex module
5 Based on an original test by Roger E. Masse.
6"""
7import binhex
8import os
9import unittest
10from test import test_support
11
12
13class BinHexTestCase(unittest.TestCase):
14
15 def setUp(self):
16 self.fname1 = test_support.TESTFN + "1"
17 self.fname2 = test_support.TESTFN + "2"
18
19 def tearDown(self):
20 try: os.unlink(self.fname1)
21 except OSError: pass
22
23 try: os.unlink(self.fname2)
24 except OSError: pass
25
26 DATA = 'Jack is my hero'
27
28 def test_binhex(self):
29 f = open(self.fname1, 'w')
30 f.write(self.DATA)
31 f.close()
32
33 binhex.binhex(self.fname1, self.fname2)
34
35 binhex.hexbin(self.fname2, self.fname1)
36
37 f = open(self.fname1, 'r')
38 finish = f.readline()
39 f.close()
40
41 self.assertEqual(self.DATA, finish)
42
43
44def test_main():
45 test_support.run_unittest(BinHexTestCase)
46
47
48if __name__ == "__main__":
49 test_main()