make sure Request.method is always str

This commit is contained in:
Pablo Hoffman 2011-05-02 01:11:19 -03:00
parent afa23688c6
commit bac46ba438
2 changed files with 5 additions and 1 deletions

View File

@ -25,7 +25,7 @@ class Request(object_ref):
dont_filter=False, errback=None):
self._encoding = encoding # this one has to be set first
self.method = method.upper()
self.method = str(method).upper()
self._set_url(url)
self._set_body(body)
self.priority = priority

View File

@ -162,6 +162,10 @@ class RequestTest(unittest.TestCase):
self.assertEqual(r4.meta, {})
assert r4.dont_filter is False
def test_method_always_str(self):
r = self.request_class("http://www.example.com", method=u"POST")
assert isinstance(r.method, str)
def test_weakref_slots(self):
"""Check that classes are using slots and are weak-referenceable"""
x = self.request_class('http://www.example.com')