1
#! /usr/bin/env python3
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.
10
from test import support
13
class BinHexTestCase(unittest.TestCase):
16
self.fname1 = support.TESTFN + "1"
17
self.fname2 = support.TESTFN + "2"
18
self.fname3 = support.TESTFN + "very_long_filename__very_long_filename__very_long_filename__very_long_filename__"
21
support.unlink(self.fname1)
22
support.unlink(self.fname2)
23
support.unlink(self.fname3)
25
DATA = b'Jack is my hero'
27
def test_binhex(self):
28
f = open(self.fname1, 'wb')
32
binhex.binhex(self.fname1, self.fname2)
34
binhex.hexbin(self.fname2, self.fname1)
36
f = open(self.fname1, 'rb')
40
self.assertEqual(self.DATA, finish)
42
def test_binhex_error_on_long_filename(self):
44
The testcase fails if no exception is raised when a filename parameter provided to binhex.binhex()
45
is too long, or if the exception raised in binhex.binhex() is not an instance of binhex.Error.
47
f3 = open(self.fname3, 'wb')
50
self.assertRaises(binhex.Error, binhex.binhex, self.fname3, self.fname2)
53
support.run_unittest(BinHexTestCase)
56
if __name__ == "__main__":