def test_post_required(): f = lambda r: mock.sentinel.response g = decorators.post_required(f) request = mock.Mock() request.method = 'GET' assert isinstance(g(request), http.HttpResponseNotAllowed) request.method = 'POST' eq_(g(request), mock.sentinel.response)