diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2013-01-11 12:47:47 -0500 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2013-01-11 12:47:47 -0500 |
commit | fb6a5713af30a9ba945ef83dd408fe84ce924447 (patch) | |
tree | 025e52d26e60d504c15e65a6926c2d0c8e1e9486 | |
parent | 66707c4082381f8037b9113a6bfb4678cb22c5f4 (diff) | |
download | pecan-fb6a5713af30a9ba945ef83dd408fe84ce924447.tar.gz |
Fix a routing-related bug in RestController. fixes #156
-rw-r--r-- | pecan/core.py | 2 | ||||
-rw-r--r-- | pecan/tests/test_rest.py | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/pecan/core.py b/pecan/core.py index fb741a9..fda40b7 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -307,7 +307,7 @@ class Pecan(object): valid_args = valid_args[len(args):] # handle wildcard arguments - if remainder: + if filter(None, remainder): if not argspec[1]: abort(404) args.extend(remainder) diff --git a/pecan/tests/test_rest.py b/pecan/tests/test_rest.py index 4935c00..1bad77f 100644 --- a/pecan/tests/test_rest.py +++ b/pecan/tests/test_rest.py @@ -863,3 +863,27 @@ class TestRestController(TestCase): r = app.get('/foos/bars/bazs/final/named') assert r.status_int == 200 assert r.body == 'NAMED' + + def test_post_with_kwargs_only(self): + + class RootController(RestController): + + @expose() + def get_all(self): + return 'INDEX' + + @expose('json') + def post(self, **kw): + return kw + + # create the app + app = TestApp(make_app(RootController())) + + r = app.get('/') + assert r.status_int == 200 + assert r.body == 'INDEX' + + kwargs = {'foo': 'bar', 'spam': 'eggs'} + r = app.post('/', kwargs) + assert r.status_int == 200 + assert r.body == dumps(kwargs) |