pecan/pecan — Issue #35: RestController and 404's
Author: cleverdevil
Created: 2011-12-30 22:49:34+00:00
State: open

If you have a RestController, you cannot return a 404 without resulting in a unit testing error where the content length doesn't match. Code to reproduce:

# root.py

```python
from pecan import expose, abort
from pecan.rest import RestController

class RootController(RestController):

@expose('json')
def get_one(self, objectID):
if int(objectID) == 1:
return dict(result='success')
else:
abort(404)
```

# test_root.py

```python
from unittest import TestCase
from webtest import TestApp

import py.test

class TestRootController(TestCase):

def setUp(self):
self.app = TestApp(py.test.wsgi_app)

def test_get(self):
response = self.app.get('/1')
assert response.status_int == 200

def test_get_not_found(self):
response = self.app.get('/2')
assert response.status_int == 404
```