def test_caching(self): r1 = HtmlResponse('http://www.example.com', body=b'<html><head></head><body></body></html>') r2 = r1.copy() doc1 = LxmlDocument(r1) doc2 = LxmlDocument(r1) doc3 = LxmlDocument(r2) # make sure it's cached assert doc1 is doc2 assert doc1 is not doc3
def test_caching(self): r1 = HtmlResponse('http://www.example.com', body='<html><head></head><body></body></html>') r2 = r1.copy() doc1 = LxmlDocument(r1) doc2 = LxmlDocument(r1) doc3 = LxmlDocument(r2) # make sure it's cached assert doc1 is doc2 assert doc1 is not doc3
def test_caching(self): r1 = HtmlResponse('http://www.example.com', body='<html><head></head><body></body></html>') r2 = r1.copy() doc1 = LxmlDocument(r1) doc2 = LxmlDocument(r1) doc3 = LxmlDocument(r2) # make sure it's cached assert doc1 is doc2 assert doc1 is not doc3 # don't leave documents in memory to avoid wrong libxml2 leaks reports del doc1, doc2, doc3
def test_response_libxml2_caching(self): r1 = HtmlResponse("http://www.example.com", body="<html><head></head><body></body></html>") r2 = r1.copy() doc1 = Libxml2Document(r1) doc2 = Libxml2Document(r1) doc3 = Libxml2Document(r2) # make sure it's cached assert doc1 is doc2 assert doc1.xmlDoc is doc2.xmlDoc assert doc1 is not doc3 assert doc1.xmlDoc is not doc3.xmlDoc # don't leave libxml2 documents in memory to avoid wrong libxml2 leaks reports del doc1, doc2, doc3