From daf303ec78681370b30764e3c810d00904c0a02f Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Sat, 30 Jun 2012 00:16:28 -0400 Subject: [PATCH] Minor tinman.application cleanups --- tests/application_test.py | 12 ++---------- tinman/application.py | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/tests/application_test.py b/tests/application_test.py index 28b37e6..e52e65e 100644 --- a/tests/application_test.py +++ b/tests/application_test.py @@ -13,24 +13,16 @@ class ApplicationTests(unittest.TestCase): def setUp(self): - self._mock_obj = mock.Mock(spec=application.TinmanApplication) - def test_load_translations(self): - with mock.patch('tornado.locale.load_translations') as mock_load: - - path = '/foo' - print application.TinmanApplication._load_translations(self._mock_obj, path) + application.TinmanApplication._load_translations(self._mock_obj, + path) mock_load.assert_called_once_with(path) - - - - class AttributeTests(unittest.TestCase): def test_add_attribute_exists(self): diff --git a/tinman/application.py b/tinman/application.py index cf4f538..73cfe6e 100644 --- a/tinman/application.py +++ b/tinman/application.py @@ -120,26 +120,21 @@ def _prepare_paths(self): def _replace_path(self, path_name, name, value): """Replace the name with the value for the given path_name name. - :param path_name: The path_name name - :type path_name: str - :param name: The string to replace in original string - :type name: str - :param value: The string value replacement value for name - :type value: str + :param str path_name: The path_name name + :param str name: The string to replace in original string + :param str value: The string value replacement value for name """ # If we have a base path_name, replace it if needed - if self._settings[path_name]: + if path_name in self._settings: self._settings[path_name] = self._settings[path_name].replace(name, value) def _set_path(self, path_name, path_value): """Set the specified path setting with the given value - :param path_name: The path to set - :type path_name: str - :param path_value: Path to set it to - :type path_value: str + :param str path_name: The path to set + :param str path_value: Path to set it to """ self._settings[path_name] = path_value @@ -148,9 +143,9 @@ def _prepare_route(self, attributes): """Take a given inbound list for a route and parse it creating the route and importing the class it belongs to. - :param attributes: Route attributes - :type attributes: list or tuple - :rtype: list of prepared route + :param list attributes: Route attributes + :rtype: list + """ # Validate it's a list or set if type(attributes) not in (list, tuple):