def testOpenBytesFilename(self):
    str_filename = self.filename
    try:
        bytes_filename = str_filename.encode('ascii')
    except UnicodeEncodeError:
        self.skipTest('Temporary file name needs to be ASCII')
    with BZ2File(bytes_filename, 'wb') as f:
        f.write(self.DATA)
    with BZ2File(bytes_filename, 'rb') as f:
        self.assertEqual(f.read(), self.DATA)
    with BZ2File(str_filename, 'rb') as f:
        self.assertEqual(f.read(), self.DATA)
def testOpenBytesFilename(self):
    str_filename = self.filename
    try:
        bytes_filename = str_filename.encode('ascii')
    except UnicodeEncodeError:
        self.skipTest('Temporary file name needs to be ASCII')
    with BZ2File(bytes_filename, 'wb') as f:
        f.write(self.DATA)
    with BZ2File(bytes_filename, 'rb') as f:
        self.assertEqual(f.read(), self.DATA)
    with BZ2File(str_filename, 'rb') as f:
        self.assertEqual(f.read(), self.DATA)