# HG changeset patch # User arkady.koplyarov # Date 1300303721 14400 # Node ID 43c30a62521ccc2467a913d3c109c55c416efe3b # Parent 5f23a6557e364e00d096eb9b9558db0ca8ecb209 Adding a testcase to test that an exception binhex.Error is raised when the filename provided to the binhex(input, output) function is too long to fit in the filename field. test_binhex_error_on_long_filename diff -r 5f23a6557e36 -r 43c30a62521c Lib/test/test_binhex.py --- a/Lib/test/test_binhex.py Sun Mar 13 16:36:08 2011 -0500 +++ b/Lib/test/test_binhex.py Wed Mar 16 15:28:41 2011 -0400 @@ -15,6 +15,7 @@ def setUp(self): self.fname1 = support.TESTFN + "1" self.fname2 = support.TESTFN + "2" + self.fname3 = support.TESTFN + "very_long_filename__very_long_filename__very_long_filename__very_long_filename__" def tearDown(self): support.unlink(self.fname1) @@ -37,6 +38,16 @@ self.assertEqual(self.DATA, finish) + def test_binhex_error_on_long_filename(self): + f3 = open(self.fname3, 'wb') + f3.close() + try: + binhex.binhex(self.fname3, self.fname2) + except BaseException as ex: + # Fail if the exception raised in binhex.binhex() is not an instance of binhex.Error + self.assertIsInstance(ex, binhex.Error) + else: + self.fail("The exception %s is not raised in binhex.binhex()." % (binhex.Error) ) def test_main(): support.run_unittest(BinHexTestCase)