From e440d2e8af7dbf1a558c576ce541db42c8e241da Mon Sep 17 00:00:00 2001 From: rallytime Date: Thu, 13 Apr 2017 13:39:11 -0600 Subject: [PATCH] Use self.setGrains as context manager in grains test --- tests/unit/states/test_grains.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/unit/states/test_grains.py b/tests/unit/states/test_grains.py index 086c9aa65a..5e217d99bb 100644 --- a/tests/unit/states/test_grains.py +++ b/tests/unit/states/test_grains.py @@ -841,18 +841,18 @@ class GrainsTestCase(TestCase, LoaderModuleMockMixin): def test_append_convert_to_list_empty(self): # Append to an existing list - self.setGrains({'foo': None}) - ret = grains.append(name='foo', - value='baz', - convert=True) - self.assertEqual(ret['result'], True) - self.assertEqual(ret['comment'], 'Value baz was added to grain foo') - self.assertEqual(ret['changes'], {'added': 'baz'}) - self.assertEqual( - grains.__grains__, - {'foo': ['baz']}) - self.assertGrainFileContent("foo:\n" - + "- baz\n") + with self.setGrains({'foo': None}): + ret = grains.append(name='foo', + value='baz', + convert=True) + self.assertEqual(ret['result'], True) + self.assertEqual(ret['comment'], 'Value baz was added to grain foo') + self.assertEqual(ret['changes'], {'added': 'baz'}) + self.assertEqual( + grains.__grains__, + {'foo': ['baz']}) + self.assertGrainFileContent("foo:\n" + + "- baz\n") # 'list_present' function tests: 7