PyXR

c:\python24\lib \ test \ test_binhex.py



0001 #! /usr/bin/env python
0002 """Test script for the binhex C module
0003 
0004    Uses the mechanism of the python binhex module
0005    Based on an original test by Roger E. Masse.
0006 """
0007 import binhex
0008 import os
0009 import unittest
0010 from test import test_support
0011 
0012 
0013 class BinHexTestCase(unittest.TestCase):
0014 
0015     def setUp(self):
0016         self.fname1 = test_support.TESTFN + "1"
0017         self.fname2 = test_support.TESTFN + "2"
0018 
0019     def tearDown(self):
0020         try: os.unlink(self.fname1)
0021         except OSError: pass
0022 
0023         try: os.unlink(self.fname2)
0024         except OSError: pass
0025 
0026     DATA = 'Jack is my hero'
0027 
0028     def test_binhex(self):
0029         f = open(self.fname1, 'w')
0030         f.write(self.DATA)
0031         f.close()
0032 
0033         binhex.binhex(self.fname1, self.fname2)
0034 
0035         binhex.hexbin(self.fname2, self.fname1)
0036 
0037         f = open(self.fname1, 'r')
0038         finish = f.readline()
0039         f.close()
0040 
0041         self.assertEqual(self.DATA, finish)
0042 
0043 
0044 def test_main():
0045     test_support.run_unittest(BinHexTestCase)
0046 
0047 
0048 if __name__ == "__main__":
0049     test_main()
0050 

Generated by PyXR 0.9.4
SourceForge.net Logo