Exemple #1
0
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
Exemple #2
0
def test_read_piped_gzip():
	with PipedGzipReader('tests/hello.gz', 'rt') as f:
		assert f.read() == 'hello'
Exemple #3
0
def test_pipedgzipreader_close(large_gzip, mode):
    with PipedGzipReader(large_gzip, mode=mode) as f:
        f.readline()
        time.sleep(0.2)
Exemple #4
0
def test_pipedgzipreader_iter_without_with():
    it = iter(PipedGzipReader("tests/file.txt.gz"))
    assert CONTENT_LINES[0] == next(it)
Exemple #5
0
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]
Exemple #6
0
def test_readline_text_pipedgzipreader():
    with PipedGzipReader("tests/file.txt.gz", "r") as f:
        assert f.readline() == CONTENT_LINES[0]
Exemple #7
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
Exemple #8
0
def test_pipedgzipreader_textiowrapper():
    with PipedGzipReader("tests/file.txt.gz", "rb") as f:
        wrapped = io.TextIOWrapper(f)
        assert wrapped.read() == CONTENT