diff --git a/os_apply_config/renderers.py b/os_apply_config/renderers.py index 07b6cf2..bea6d05 100644 --- a/os_apply_config/renderers.py +++ b/os_apply_config/renderers.py @@ -38,4 +38,6 @@ class JsonRenderer(pystache.Renderer): partials, missing_tags) def str_coerce(self, val): + if val is None: + return b'' return json.dumps(val) diff --git a/os_apply_config/tests/test_apply_config.py b/os_apply_config/tests/test_apply_config.py index 76db3d9..8e921d4 100644 --- a/os_apply_config/tests/test_apply_config.py +++ b/os_apply_config/tests/test_apply_config.py @@ -337,6 +337,11 @@ class OSConfigApplierTestCase(testtools.TestCase): def test_render_moustache_bad_key(self): self.assertEqual(u'', apply_config.render_moustache("{{badkey}}", {})) + def test_render_moustache_none(self): + self.assertEqual('foo: ', + apply_config.render_moustache("foo: {{foo}}", + {'foo': None})) + def test_render_executable(self): params = {"x": "foo"} self.assertEqual("foo\n", apply_config.render_executable(