Scrapy, a fast high-level web crawling & scraping framework for Python.
fixed import error (thanks Shane) and added some basic tests for ScrapedItem
Pablo Hoffman987ceb540e58
diff --git a/scrapy/trunk/scrapy/item/models.py b/scrapy/trunk/scrapy/item/models.pyindex 69b4cf1f6..ed374f919 100644--- a/scrapy/trunk/scrapy/item/models.py+++ b/scrapy/trunk/scrapy/item/models.py@@ -14,7 +14,7 @@ class ScrapedItem(object):for attr, value in data.iteritems():setattr(self, attr, value)elif data is not None:- raise UsageError("Initialize with dict, not %s" % data.__class__.__name__)+ raise TypeError("Initialize with dict, not %s" % data.__class__.__name__)def __repr__(self):"""diff --git a/scrapy/trunk/scrapy/tests/test_item.py b/scrapy/trunk/scrapy/tests/test_item.pynew file mode 100644index 000000000..902bda2cf--- /dev/null+++ b/scrapy/trunk/scrapy/tests/test_item.py@@ -0,0 +1,21 @@+import unittest++from scrapy.item import ScrapedItem++class ItemTestCase(unittest.TestCase):++ def test_item(self):++ class MyItem(ScrapedItem):+ pass++ item = MyItem()+ self.assertEqual(repr(item), 'MyItem({})')++ item = ScrapedItem({'key': 'value'})+ self.assertEqual(item.key, 'value')++ self.assertRaises(TypeError, ScrapedItem, 10)++if __name__ == "__main__":+ unittest.main()