Issue #7295: Do not use a hardcoded file name in test_tarfile.
[python.git] / Lib / test / test_binhex.py
blob2f89703b44a242aff8cf8a1bb0db3773cb60efb5
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 unittest
10 from test import test_support
13 class BinHexTestCase(unittest.TestCase):
15 def setUp(self):
16 self.fname1 = test_support.TESTFN + "1"
17 self.fname2 = test_support.TESTFN + "2"
19 def tearDown(self):
20 try: os.unlink(self.fname1)
21 except OSError: pass
23 try: os.unlink(self.fname2)
24 except OSError: pass
26 DATA = 'Jack is my hero'
28 def test_binhex(self):
29 f = open(self.fname1, 'w')
30 f.write(self.DATA)
31 f.close()
33 binhex.binhex(self.fname1, self.fname2)
35 binhex.hexbin(self.fname2, self.fname1)
37 f = open(self.fname1, 'r')
38 finish = f.readline()
39 f.close()
41 self.assertEqual(self.DATA, finish)
44 def test_main():
45 test_support.run_unittest(BinHexTestCase)
48 if __name__ == "__main__":
49 test_main()