def test_block_exec(): # This function tricky to test in a multiprocessing world, because we need # some way to communicate back from the subprocesses that the execution # actually happened... instead we just test it in serial # mode. (Fortunately it is a super-trivial function.) z = ZS(test_data_path("letters-none.zs"), parallelism=0) # b/c we're in serial mode, the fn doesn't need to be pickleable class CountBlocks(object): def __init__(self): self.count = 0 def __call__(self, records): self.count += 1 count_blocks = CountBlocks() z.block_exec(count_blocks) assert count_blocks.count > 1 assert count_blocks.count == len(list(z.block_map(identity)))
def test_zs_close(): z = ZS(test_data_path("letters-none.zs")) z.close() for call in [[list, z.search()], [list, z.block_map(_check_raise_helper, AssertionError)], [list, z], [z.dump, BytesIO()], [z.validate], ]: print(repr(call)) assert_raises(ZSError, *call) # But calling .close() twice is fine. z.close() # smoke test for __del__ method ZS(test_data_path("letters-none.zs"))