def _assert_shard_manager(self, content, mode, mock_tree, mock_challenges):
with tempfile.NamedTemporaryFile(mode, delete=False) as tmp_file:
tmp_file.write(content)
tmp_file.flush()
nchallenges = 2
sm = ShardManager(
tmp_file.name,
nchallenges=nchallenges)
assert sm.filepath == tmp_file.name
assert len(sm.shards) > 0
mock_challenges.assert_called_once_with(nchallenges)
if isinstance(content, six.binary_type):
mock_tree.assert_called_once_with(
mock_challenges.return_value, content)
else:
mock_tree.assert_called_once_with(
mock_challenges.return_value, bytes(content.encode('utf-8')))
mock_tree.reset_mock()
mock_challenges.reset_mock()
评论列表
文章目录