Ticket #371: pythonpaste_371_head.patch

File pythonpaste_371_head.patch, 2.0 KB (added by greut, 3 years ago)

providing a .head method

  • tests/test_testing.py

    diff --git a/tests/test_testing.py b/tests/test_testing.py
    index 7947150..df80b02 100644
    a b  
    2121    assert res.status_int == 200 
    2222    assert res.headers['content-type'] == 'text/plain' 
    2323    assert res.content_type == 'text/plain' 
     24    res = app.head('/') 
     25    assert res.status_int == 200 
     26    assert res.headers['content-type'] == 'text/plain' 
     27    assert res.headers['content-length'] <> '0' 
     28    assert res.body == '' 
    2429    raises(Exception, app.get, '/?error=t') 
    2530    raises(webtest.AppError, app.get, '/?status=404%20Not%20Found') 
    2631    app.get('/?status=404%20Not%20Found', status=404) 
  • webtest/__init__.py

    diff --git a/webtest/__init__.py b/webtest/__init__.py
    index 66c150a..9687d91 100644
    a b  
    235235        return self._gen_request('DELETE', url, headers=headers, 
    236236                                 extra_environ=extra_environ,status=status, 
    237237                                 upload_files=None, expect_errors=expect_errors) 
     238     
     239    def head(self, url, headers=None, extra_environ=None, 
     240               status=None, expect_errors=False): 
     241        """ 
     242        Do a HEAD request.  Very like the ``.get()`` method. 
     243 
     244        Returns a ``webob.Response`` object. 
     245        """ 
     246        return self._gen_request('HEAD', url, headers=headers, 
     247                                 extra_environ=extra_environ,status=status, 
     248                                 upload_files=None, expect_errors=expect_errors) 
    238249 
    239250    def encode_multipart(self, params, files): 
    240251        """ 
  • webtest/debugapp.py

    diff --git a/webtest/debugapp.py b/webtest/debugapp.py
    index 885f137..ad46610 100644
    a b  
    2929            header_name = name[len('header-'):] 
    3030            headers.append((header_name, value)) 
    3131    start_response(status, headers) 
    32     return [body] 
     32    return [body] if req.method <> "HEAD" else [""] 
    3333 
    3434def make_debug_app(global_conf): 
    3535    """