mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Close #11577: Improve binhex test coverage and fix ResourceWarning
This commit is contained in:
parent
4e4326829f
commit
b3c728fd89
4 changed files with 40 additions and 18 deletions
|
@ -15,10 +15,12 @@ class BinHexTestCase(unittest.TestCase):
|
|||
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)
|
||||
support.unlink(self.fname2)
|
||||
support.unlink(self.fname3)
|
||||
|
||||
DATA = b'Jack is my hero'
|
||||
|
||||
|
@ -37,6 +39,15 @@ class BinHexTestCase(unittest.TestCase):
|
|||
|
||||
self.assertEqual(self.DATA, finish)
|
||||
|
||||
def test_binhex_error_on_long_filename(self):
|
||||
"""
|
||||
The testcase fails if no exception is raised when a filename parameter provided to binhex.binhex()
|
||||
is too long, or if the exception raised in binhex.binhex() is not an instance of binhex.Error.
|
||||
"""
|
||||
f3 = open(self.fname3, 'wb')
|
||||
f3.close()
|
||||
|
||||
self.assertRaises(binhex.Error, binhex.binhex, self.fname3, self.fname2)
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(BinHexTestCase)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue