mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Issue #28225: bz2 module now supports pathlib
Initial patch by Ethan Furman.
This commit is contained in:
parent
03020cfa97
commit
8bdd4480c4
4 changed files with 25 additions and 7 deletions
|
@ -6,6 +6,7 @@ from io import BytesIO, DEFAULT_BUFFER_SIZE
|
|||
import os
|
||||
import pickle
|
||||
import glob
|
||||
import pathlib
|
||||
import random
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -560,6 +561,13 @@ class BZ2FileTest(BaseTest):
|
|||
with BZ2File(str_filename, "rb") as f:
|
||||
self.assertEqual(f.read(), self.DATA)
|
||||
|
||||
def testOpenPathLikeFilename(self):
|
||||
filename = pathlib.Path(self.filename)
|
||||
with BZ2File(filename, "wb") as f:
|
||||
f.write(self.DATA)
|
||||
with BZ2File(filename, "rb") as f:
|
||||
self.assertEqual(f.read(), self.DATA)
|
||||
|
||||
def testDecompressLimited(self):
|
||||
"""Decompressed data buffering should be limited"""
|
||||
bomb = bz2.compress(b'\0' * int(2e6), compresslevel=9)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue