Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Add tests for meta and cb_kwargs not being available

Adrián Chaves43b43654a1da
diff --git a/tests/test_http_response.py b/tests/test_http_response.py
index 39f5fe750..5a19f9d54 100644
--- a/tests/test_http_response.py
+++ b/tests/test_http_response.py
@@ -78,6 +78,16 @@ class BaseResponseTest(unittest.TestCase):
r1 = self.response_class("http://www.example.com", body=b"Some body", request=req)
assert r1.cb_kwargs is req.cb_kwargs
+ def test_unavailable_meta(self):
+ r1 = self.response_class("http://www.example.com", body=b"Some body")
+ with self.assertRaisesRegex(AttributeError, r'Response\.meta not available'):
+ r1.meta
+
+ def test_unavailable_cb_kwargs(self):
+ r1 = self.response_class("http://www.example.com", body=b"Some body")
+ with self.assertRaisesRegex(AttributeError, r'Response\.cb_kwargs not available'):
+ r1.cb_kwargs
+
def test_copy_inherited_classes(self):
"""Test Response children copies preserve their class"""