File fix-unit-test-for-grains-core.patch of Package salt

From 192bac1ae2f20b098384264c8802034a340cd124 Mon Sep 17 00:00:00 2001
From: Bo Maryniuk <bo@suse.de>
Date: Thu, 11 Oct 2018 16:20:40 +0200
Subject: [PATCH] Fix unit test for grains core

---
 tests/unit/grains/test_core.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py
index 34aaa4f5bc..7dbf34deac 100644
--- a/tests/unit/grains/test_core.py
+++ b/tests/unit/grains/test_core.py
@@ -59,10 +59,11 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
         with salt.utils.files.fopen(
             os.path.join(OS_RELEASE_DIR, "ubuntu-17.10")
         ) as os_release_file:
-            os_release_content = os_release_file.read()
-        with patch("salt.utils.files.fopen", mock_open(read_data=os_release_content)):
+            os_release_content = os_release_file.readlines()
+        with patch("salt.utils.files.fopen", mock_open()) as os_release_file:
+            os_release_file.return_value.__iter__.return_value = os_release_content
             os_release = core._parse_os_release(
-                "/etc/os-release", "/usr/lib/os-release"
+                ["/etc/os-release", "/usr/lib/os-release"]
             )
         self.assertEqual(
             os_release,
@@ -172,7 +173,7 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
     def test_missing_os_release(self):
         with patch("salt.utils.files.fopen", mock_open(read_data={})):
             os_release = core._parse_os_release(
-                "/etc/os-release", "/usr/lib/os-release"
+                ["/etc/os-release", "/usr/lib/os-release"]
             )
         self.assertEqual(os_release, {})
 
-- 
2.29.2
openSUSE Build Service is sponsored by