[virt-tools-list] [virt-bootstrap 3/4] pylint: Fix unsubscriptable-object

Radostin Stoyanov rstoyanov1 at gmail.com
Sun Aug 4 18:06:02 UTC 2019


Value 'root_password' is unsubscriptable (unsubscriptable-object)

Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
 tests/__init__.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tests/__init__.py b/tests/__init__.py
index ce0d5fa..f5a9613 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -334,15 +334,14 @@ class ImageAccessor(unittest.TestCase):
         Note: For simplicity we assume that the first line of /etc/shadow
         contains the root entry.
         """
-        root_password = self.root_password
-        if root_password and root_password.startswith('file:'):
-            root_password_file = root_password[len('file:'):]
-            with open(root_password_file) as pwdfile:
-                root_password = pwdfile.readline().rstrip("\n\r")
+
+        if self.root_password.startswith('file:'):
+            with open(self.root_password[len('file:'):]) as pwdfile:
+                self.root_password = pwdfile.readline().rstrip("\n\r")
 
         self.assertTrue(
             passlib.hosts.linux_context.verify(
-                root_password,
+                self.root_password,
                 shadow_content[0].split(':')[1]
             ),
             "Invalid root password hash."
-- 
2.21.0




More information about the virt-tools-list mailing list