def test_find_content_blocks(self): porno = u'порно ' * 100 redis = u'редис ' * 100 html = ('<div>%s</div><p>%s' % (porno, redis)) tree = fromstring(html) blocks = list(find_content_blocks(tree)) #print '>>>' #print blocks[0] #print '<<<' #print ')))' #print porno.strip() #print '(((' self.assertEqual(blocks[0], porno.strip())
def test_find_content_blocks(self): # TODO: move to separate file from grab.tools.content import find_content_blocks porno = u'порно ' * 100 redis = u'редис ' * 100 SERVER.RESPONSE['get'] = ('<div>%s</div><p>%s' % (porno, redis)).encode('utf-8') g = Grab(transport=GRAB_TRANSPORT) g.go(SERVER.BASE_URL) blocks = list(find_content_blocks(g.tree)) print '>>>' print blocks[0] print '<<<' print ')))' print porno.strip() print '(((' self.assertEqual(blocks[0], porno.strip())