def test_write_fail(write_fail_mock): buf = bytes(bytearray(1000000)) try: with memory_writer(buf, 'gnutar', 'xz') as archive: archive.add_files('libarchive/') raise TypeError except TypeError: pass assert write_fail_mock.called
def test_write_not_fail(write_fail_mock): buf = bytes(bytearray(1000000)) with memory_writer(buf, 'gnutar', 'xz') as archive: archive.add_files('libarchive/') assert not write_fail_mock.called