From 1a918b5bba6c61510846796e90128d4e72f6aeca Mon Sep 17 00:00:00 2001 From: "arati.mahimane" Date: Wed, 23 Apr 2014 10:39:34 -0500 Subject: [PATCH] Fix error: variable 'kw' referenced before assignment Change-Id: Ife95d74bf645687dc4595b16434c88ee874c2f95 Closes-bug: #1311742 --- tests/rest/test_args.py | 20 ++++++++++++++++++++ wsme/rest/args.py | 1 + 2 files changed, 21 insertions(+) create mode 100644 tests/rest/test_args.py diff --git a/tests/rest/test_args.py b/tests/rest/test_args.py new file mode 100644 index 0000000..4ae3246 --- /dev/null +++ b/tests/rest/test_args.py @@ -0,0 +1,20 @@ +import mock +import unittest + +from wsme import exc +from wsme.rest import args +from wsme.rest import json + + +class TestArgs(unittest.TestCase): + + def test_args_from_body(self): + + funcdef = mock.MagicMock() + body = mock.MagicMock() + mimetype = "application/json" + funcdef.ignore_extra_args = True + json.parse = mock.MagicMock() + json.parse.side_effect = (exc.UnknownArgument("")) + resp = args.args_from_body(funcdef, body, mimetype) + self.assertEqual(resp, ((), {})) diff --git a/wsme/rest/args.py b/wsme/rest/args.py index 9b8f2e1..0c4f6cf 100644 --- a/wsme/rest/args.py +++ b/wsme/rest/args.py @@ -232,6 +232,7 @@ def args_from_body(funcdef, body, mimetype): except UnknownArgument: if not funcdef.ignore_extra_args: raise + kw = {} return (), kw