def test_pipedgzipreader_readinto(): # Test whether PipedGzipReader.readinto works content = CONTENT.encode('utf-8') with PipedGzipReader("tests/file.txt.gz", "rb") as f: b = bytearray(len(content) + 100) length = f.readinto(b) assert length == len(content) assert b[:length] == content
def test_read_piped_gzip(): with PipedGzipReader('tests/hello.gz', 'rt') as f: assert f.read() == 'hello'
def test_pipedgzipreader_close(large_gzip, mode): with PipedGzipReader(large_gzip, mode=mode) as f: f.readline() time.sleep(0.2)
def test_pipedgzipreader_iter_without_with(): it = iter(PipedGzipReader("tests/file.txt.gz")) assert CONTENT_LINES[0] == next(it)
def test_pipedgzipreader_iter(threads): with PipedGzipReader("tests/file.txt.gz", mode="r", threads=threads) as f: lines = list(f) assert lines[0] == CONTENT_LINES[0]
def test_readline_text_pipedgzipreader(): with PipedGzipReader("tests/file.txt.gz", "r") as f: assert f.readline() == CONTENT_LINES[0]
def test_readline_pipedgzipreader(): first_line = CONTENT_LINES[0].encode('utf-8') with PipedGzipReader("tests/file.txt.gz", "rb") as f: assert f.readline() == first_line
def test_pipedgzipreader_textiowrapper(): with PipedGzipReader("tests/file.txt.gz", "rb") as f: wrapped = io.TextIOWrapper(f) assert wrapped.read() == CONTENT