Scrapy, a fast high-level web crawling & scraping framework for Python.
Add a test to cover searching for a missing node name
Adrián Chaves2f28cee3ce48
diff --git a/tests/test_utils_iterators.py b/tests/test_utils_iterators.pyindex ae64e36cf..2adccebb8 100644--- a/tests/test_utils_iterators.py+++ b/tests/test_utils_iterators.py@@ -175,6 +175,30 @@ class XmliterTestCase(unittest.TestCase):node.register_namespace('g', 'http://base.google.com/ns/1.0')self.assertEqual(node.xpath('text()').extract(), ['http://www.mydummycompany.com/images/item1.jpg'])+ def test_xmliter_namespaced_nodename_missing(self):+ body = b"""+ <?xml version="1.0" encoding="UTF-8"?>+ <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">+ <channel>+ <title>My Dummy Company</title>+ <link>http://www.mydummycompany.com</link>+ <description>This is a dummy company. We do nothing.</description>+ <item>+ <title>Item 1</title>+ <description>This is item 1</description>+ <link>http://www.mydummycompany.com/items/1</link>+ <g:image_link>http://www.mydummycompany.com/images/item1.jpg</g:image_link>+ <g:id>ITEM_1</g:id>+ <g:price>400</g:price>+ </item>+ </channel>+ </rss>+ """+ response = XmlResponse(url='http://mydummycompany.com', body=body)+ my_iter = self.xmliter(response, 'g:link_image')+ with self.assertRaises(StopIteration):+ next(my_iter)+def test_xmliter_exception(self):body = ('<?xml version="1.0" encoding="UTF-8"?>'