@patch("sys.stdout")
    def test_clt_fetch_dlo(self, mock_stdout):
        clt = self.client
        mgr = clt._manager
        cont = self.container
        ctype = "text/fake"
        num_objs = random.randint(1, 3)
        objs = [StorageObject(cont.object_manager,
                {"name": "obj%s" % num, "content_type": ctype, "bytes": 42})
                for num in range(num_objs)]
        clt.get_container_objects = Mock(return_value=objs)
        name = utils.random_unicode()
        clt.method_get = Mock(side_effect=[(None, "aaa"), (None, "bbb"),
                (None, "ccc"), (None, "")] * num_objs)

        def fake_get(obj_name):
            return [obj for obj in objs
                    if obj.name == obj_name][0]

        cont.object_manager.get = Mock(side_effect=fake_get)
        job = clt.fetch_dlo(cont, name, chunk_size=None)
        self.assertTrue(isinstance(job, list))
        self.assertEqual(len(job), num_objs)
        for name, chunker in job:
            txt = ""
            chunker.interval = 2
            chunker.verbose = True
            while True:
                try:
                    txt += chunker.read()
                except __HOLE__:
                    break
            self.assertEqual(txt, "aaabbbccc")
dataset/ETHPy150Open rackspace/pyrax/tests/unit/test_object_storage.py/ObjectStorageTest.test_clt_fetch_dlo