Commits

Mariano Mara  committed 1a6b46d Merge

Merging webob latests changes

  • Participants
  • Parent commits c8a8079, a5d7753

Comments (0)

Files changed (3)

File _test_mlk.py

-import sys, subprocess, site, os
+import sys, site, os
+from os.path import *
 
 def create_suite():
     from mext.test_suite import TestSuite
         suite.add_nosetest(test)
     return suite
 
+testenv_dir = join(os.environ['TEMP'], 'webob-testenv')
+if not exists(testenv_dir):
+    os.makedirs(testenv_dir)
+    from setuptools.command.easy_install import main
+    site.USER_SITE = testenv_dir
+    libs = 'nose dtopt webtest mext.test>=0.4.2 coverage'.split()
+    main(['-x', '-N', '-d', testenv_dir] + libs)
 
-if not os.path.exists('testenv'):
-    subprocess.check_call("pip install -q -E testenv nose dtopt webtest mext.test>=0.4.2 coverage")
-site.addsitedir('testenv/Lib/site-packages')
+site.addsitedir(testenv_dir)
 suite = create_suite()
 
 if __name__ == '__main__':

File tests/test_request.py

-from webob import Request
-from webob.request import NoDefault, BaseRequest, AdhocAttrMixin
+from webob import Request, BaseRequest
+from webob.request import NoDefault, AdhocAttrMixin
 from webtest import TestApp
 from nose.tools import eq_, ok_, assert_raises
 from cStringIO import StringIO
     req.make_body_seekable()
     assert req.body_file is old_body_file
 
+def test_set_body():
+    req = BaseRequest.blank('/', body='foo')
+    eq_(req.body, 'foo')
+    eq_(req.content_length, 3)
+    del req.body
+    eq_(req.body, '')
+    eq_(req.content_length, 0)
+
+
 def test_broken_clen_header():
     # if the UA sends "content_length: ..' header (the name is wrong)
     # it should not break the req.headers.items()
     req.environ['HTTP_CONTENT_LENGTH'] = '0'
     req.headers.items()
 
+
 def test_nonstr_keys():
     # non-string env keys shouldn't break req.headers
     req = Request.blank('/')
     ]:
         eq_(parse_auth_params(s), d)
 
+
 def test_from_file():
     req = Request.blank('http://example.com:8000/test.html?params')
     equal_req(req)
     assert_raises(TypeError, setattr, r, 'body', unicode('hello world'))
     r.body = None
     eq_(r.body, '')
-
-def test_str_post():
-    """
-    Testing srt_POST property
-    """
-    pass
-

File webob/request.py

         input = self.body_file
         if hasattr(input, 'seek'):
             # Just in case someone has read parts of the body already
-            ## FIXME: Should we use .tell() to try to put the body
-            ## back to its previous position?
             input.seek(0)
         if length in (-1, None):
             body = self.body
             env['HTTP_CACHE_CONTROL'] = str(value)
             env['webob._cache_control'] = (None, None)
 
-    def _cache_control__del(self, value):
+    def _cache_control__del(self):
         env = self.environ
         if 'HTTP_CACHE_CONTROL' in env:
             del env['HTTP_CACHE_CONTROL']