def testSetResponseData(self): from ClientCookie import response_seek_wrapper r = TestUnSeekableResponse(self.text, {'blah': 'yawn'}) rsw = response_seek_wrapper(r) rsw.set_data("""\ A Seeming somwhat more than View; That doth instruct the Mind In Things that ly behind, """) self.assertEqual(rsw.read(9), "A Seeming") self.assertEqual(rsw.read(13), " somwhat more") rsw.seek(0) self.assertEqual(rsw.read(9), "A Seeming") self.assertEqual(rsw.readline(), " somwhat more than View;\n") rsw.seek(0) self.assertEqual(rsw.readline(), "A Seeming somwhat more than View;\n") rsw.seek(-1, 1) self.assertEqual(rsw.read(7), "\n That") r = TestUnSeekableResponse(self.text, {'blah': 'yawn'}) rsw = response_seek_wrapper(r) rsw.set_data(self.text) self._test2(rsw) rsw.seek(0) self._test4(rsw)
def testResponseSeekWrapper(self): from ClientCookie import response_seek_wrapper hdrs = {"Content-type": "text/html"} r = TestUnSeekableResponse(self.text, hdrs) rsw = response_seek_wrapper(r) rsw2 = self._testCopy(rsw) self.assert_(rsw is not rsw2) self.assertEqual(rsw.info(), rsw2.info()) self.assert_(rsw.info() is not rsw2.info()) # should be able to close already-closed object rsw2.close() rsw2.close()