• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Test script for the binhex C module
2
3   Uses the mechanism of the python binhex module
4   Based on an original test by Roger E. Masse.
5"""
6import binhex
7import os
8import unittest
9from test import test_support
10
11
12class BinHexTestCase(unittest.TestCase):
13
14    def setUp(self):
15        self.fname1 = test_support.TESTFN + "1"
16        self.fname2 = test_support.TESTFN + "2"
17
18    def tearDown(self):
19        try: os.unlink(self.fname1)
20        except OSError: pass
21
22        try: os.unlink(self.fname2)
23        except OSError: pass
24
25    DATA = 'Jack is my hero'
26
27    def test_binhex(self):
28        f = open(self.fname1, 'w')
29        f.write(self.DATA)
30        f.close()
31
32        binhex.binhex(self.fname1, self.fname2)
33
34        binhex.hexbin(self.fname2, self.fname1)
35
36        f = open(self.fname1, 'r')
37        finish = f.readline()
38        f.close()
39
40        self.assertEqual(self.DATA, finish)
41
42
43def test_main():
44    test_support.run_unittest(BinHexTestCase)
45
46
47if __name__ == "__main__":
48    test_main()
49