| Line | |
|---|
| 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 | """
|
|---|
| 7 | import binhex
|
|---|
| 8 | import os
|
|---|
| 9 | import unittest
|
|---|
| 10 | from test import test_support
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | class 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 |
|
|---|
| 44 | def test_main():
|
|---|
| 45 | test_support.run_unittest(BinHexTestCase)
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | if __name__ == "__main__":
|
|---|
| 49 | test_main()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.