Skip to content

Commit

Permalink
tests: incorporate well behaved tests into others
Browse files Browse the repository at this point in the history
  • Loading branch information
michalc committed Nov 13, 2023
1 parent afe1b72 commit 42317e3
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions test_to_file_like_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ def test_basic():
bytes_iter = (b'ab', b'cd', b'ef')
f = to_file_like_obj(bytes_iter)

assert b''.join(iter(lambda: f.read(1), b'')) == b''.join(bytes_iter)
assert [f.read(1) for _ in range(0, 7)] == [b'a', b'b', b'c', b'd', b'e', b'f', b'']


def test_basic_bytes_base():
bytes_iter = (b'ab', b'cd', b'ef')
f = to_file_like_obj(bytes_iter, base=bytes)

assert b''.join(iter(lambda: f.read(1), b'')) == b''.join(bytes_iter)
assert [f.read(1) for _ in range(0, 7)] == [b'a', b'b', b'c', b'd', b'e', b'f', b'']


def test_basic_str_base():
bytes_iter = ('ab', 'cd', 'ef')
f = to_file_like_obj(bytes_iter, base=str)

assert ''.join(iter(lambda: f.read(1), '')) == ''.join(bytes_iter)
assert [f.read(1) for _ in range(0, 7)] == ['a', 'b', 'c', 'd', 'e', 'f', '']


def test_read_crossing_chunk_boundaries():
Expand All @@ -33,13 +33,6 @@ def test_read_crossing_chunk_boundaries():
assert [f.read(3), f.read(2), f.read(2), f.read(2)] == [b'abc', b'de', b'f', b'']


def test_well_behaved():
bytes_iter = (b'ab', b'cd', b'ef')
f = to_file_like_obj(bytes_iter)

assert list(iter(lambda: len(f.read(1)), 0)) == [1, 1, 1, 1, 1, 1]


def test_lazy_iteration():
bytes_iter = (b'ab', b'cd', b'ef')

Expand Down

0 comments on commit 42317e3

Please sign in to comment.