]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/system/tests/: fix Python linter issues
authorIker Pedrosa <ipedrosa@redhat.com>
Mon, 1 Sep 2025 13:12:14 +0000 (15:12 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 10 Sep 2025 07:56:36 +0000 (09:56 +0200)
Fix issues reported by flake8, pycodestyle, isort, black and mypy.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
tests/system/tests/test_chage.py
tests/system/tests/test_groupadd.py
tests/system/tests/test_groupdel.py
tests/system/tests/test_groupmod.py
tests/system/tests/test_useradd.py
tests/system/tests/test_userdel.py
tests/system/tests/test_usermod.py

index 062c380ee3f27e465d294799da45988eacedaa81..f6f1c5801d5555faa3e704265c233c08ccf2fbfb 100644 (file)
@@ -5,8 +5,8 @@ Test chage
 from __future__ import annotations
 
 import pytest
-
 from pytest_mh.conn import ProcessError
+
 from framework.misc import days_since_epoch
 from framework.roles.shadow import Shadow
 from framework.topology import KnownTopology
index 5e4bea53270f48fc1fbf2ede45bc86e91fd5b5fb..a979919de4ede4e69e898d177064adafdb16574b 100644 (file)
@@ -26,13 +26,13 @@ def test_groupadd__add_group(shadow: Shadow):
     """
     shadow.groupadd("tgroup")
 
-    result = shadow.tools.getent.group("tgroup")
-    assert result is not None, "Group should be found"
-    assert result.name == "tgroup", "Incorrect groupname"
-    assert result.gid == 1000, "Incorrect GID"
+    group_entry = shadow.tools.getent.group("tgroup")
+    assert group_entry is not None, "Group should be found"
+    assert group_entry.name == "tgroup", "Incorrect groupname"
+    assert group_entry.gid == 1000, "Incorrect GID"
 
     if shadow.host.features["gshadow"]:
-        result = shadow.tools.getent.gshadow("tgroup")
-        assert result is not None, "Group should be found"
-        assert result.name == "tgroup", "Incorrect groupname"
-        assert result.password == "!", "Incorrect password"
+        gshadow_entry = shadow.tools.getent.gshadow("tgroup")
+        assert gshadow_entry is not None, "Group should be found"
+        assert gshadow_entry.name == "tgroup", "Incorrect groupname"
+        assert gshadow_entry.password == "!", "Incorrect password"
index c2ac2a2ccc8992f821d2672b6a1c1f91a349c721..a020df00c7dc01623f2efc7a904ef8ecd665a8b2 100644 (file)
@@ -28,8 +28,8 @@ def test_groupdel__delete_group(shadow: Shadow):
     shadow.groupadd("tgroup")
     shadow.groupdel("tgroup")
 
-    result = shadow.tools.getent.group("tgroup")
-    assert result is None, "Group should not be found"
+    group_entry = shadow.tools.getent.group("tgroup")
+    assert group_entry is None, "Group should not be found"
 
-    result = shadow.tools.getent.gshadow("tgroup")
-    assert result is None, "Group should not be found"
+    gshadow_entry = shadow.tools.getent.gshadow("tgroup")
+    assert gshadow_entry is None, "Group should not be found"
index 37f334f589007ae0433abba8b9d5a3d09c2c0df6..999ddc0cbfdb4f51489df5884f412d8ddadd87bf 100644 (file)
@@ -28,13 +28,13 @@ def test_groupmod__change_gid(shadow: Shadow):
     shadow.groupadd("tgroup")
     shadow.groupmod("-g 1001 tgroup")
 
-    result = shadow.tools.getent.group("tgroup")
-    assert result is not None, "Group should be found"
-    assert result.name == "tgroup", "Incorrect groupname"
-    assert result.gid == 1001, "Incorrect GID"
+    group_entry = shadow.tools.getent.group("tgroup")
+    assert group_entry is not None, "Group should be found"
+    assert group_entry.name == "tgroup", "Incorrect groupname"
+    assert group_entry.gid == 1001, "Incorrect GID"
 
     if shadow.host.features["gshadow"]:
-        result = shadow.tools.getent.gshadow("tgroup")
-        assert result is not None, "Group should be found"
-        assert result.name == "tgroup", "Incorrect groupname"
-        assert result.password == "!", "Incorrect password"
+        gshadow_entry = shadow.tools.getent.gshadow("tgroup")
+        assert gshadow_entry is not None, "Group should be found"
+        assert gshadow_entry.name == "tgroup", "Incorrect groupname"
+        assert gshadow_entry.password == "!", "Incorrect password"
index 14c714419225020d7f8bf85c89c859ef7a6b2138..82f8cc65fb339af25e0c627a722e7dbc74e3baff 100644 (file)
@@ -5,9 +5,9 @@ Test useradd
 from __future__ import annotations
 
 import pytest
+from pytest_mh.conn import ProcessError
 
 from framework.misc import days_since_epoch
-from pytest_mh.conn import ProcessError
 from framework.roles.shadow import Shadow
 from framework.topology import KnownTopology
 
@@ -34,37 +34,37 @@ def test_useradd__add_user(shadow: Shadow):
     """
     shadow.useradd("tuser")
 
-    result = shadow.tools.getent.passwd("tuser")
-    assert result is not None, "User should be found"
-    assert result.name == "tuser", "Incorrect username"
-    assert result.password == "x", "Incorrect password"
-    assert result.uid == 1000, "Incorrect UID"
-    assert result.gid == 1000, "Incorrect GID"
-    assert result.home == "/home/tuser", "Incorrect home"
+    passwd_entry = shadow.tools.getent.passwd("tuser")
+    assert passwd_entry is not None, "User should be found"
+    assert passwd_entry.name == "tuser", "Incorrect username"
+    assert passwd_entry.password == "x", "Incorrect password"
+    assert passwd_entry.uid == 1000, "Incorrect UID"
+    assert passwd_entry.gid == 1000, "Incorrect GID"
+    assert passwd_entry.home == "/home/tuser", "Incorrect home"
     if "Debian" in shadow.host.distro_name:
-        assert result.shell == "/bin/sh", "Incorrect shell"
+        assert passwd_entry.shell == "/bin/sh", "Incorrect shell"
     else:
-        assert result.shell == "/bin/bash", "Incorrect shell"
-
-    result = shadow.tools.getent.shadow("tuser")
-    assert result is not None, "User should be found"
-    assert result.name == "tuser", "Incorrect username"
-    assert result.password == "!", "Incorrect password"
-    assert result.last_changed == days_since_epoch(), "Incorrect last changed"
-    assert result.min_days == 0, "Incorrect min days"
-    assert result.max_days == 99999, "Incorrect max days"
-    assert result.warn_days == 7, "Incorrect warn days"
-
-    result = shadow.tools.getent.group("tuser")
-    assert result is not None, "Group should be found"
-    assert result.name == "tuser", "Incorrect groupname"
-    assert result.gid == 1000, "Incorrect GID"
+        assert passwd_entry.shell == "/bin/bash", "Incorrect shell"
+
+    shadow_entry = shadow.tools.getent.shadow("tuser")
+    assert shadow_entry is not None, "User should be found"
+    assert shadow_entry.name == "tuser", "Incorrect username"
+    assert shadow_entry.password == "!", "Incorrect password"
+    assert shadow_entry.last_changed == days_since_epoch(), "Incorrect last changed"
+    assert shadow_entry.min_days == 0, "Incorrect min days"
+    assert shadow_entry.max_days == 99999, "Incorrect max days"
+    assert shadow_entry.warn_days == 7, "Incorrect warn days"
+
+    group_entry = shadow.tools.getent.group("tuser")
+    assert group_entry is not None, "Group should be found"
+    assert group_entry.name == "tuser", "Incorrect groupname"
+    assert group_entry.gid == 1000, "Incorrect GID"
 
     if shadow.host.features["gshadow"]:
-        result = shadow.tools.getent.gshadow("tuser")
-        assert result is not None, "User should be found"
-        assert result.name == "tuser", "Incorrect username"
-        assert result.password == "!", "Incorrect password"
+        gshadow_entry = shadow.tools.getent.gshadow("tuser")
+        assert gshadow_entry is not None, "User should be found"
+        assert gshadow_entry.name == "tuser", "Incorrect username"
+        assert gshadow_entry.password == "!", "Incorrect password"
 
     assert shadow.fs.exists("/home/tuser"), "Home folder should be found"
 
@@ -91,15 +91,15 @@ def test_useradd__recreate_deleted_user(shadow: Shadow):
     shadow.userdel("tuser")
     shadow.useradd("tuser")
 
-    result = shadow.tools.id("tuser")
-    assert result is not None, "User should be found"
-    assert result.user.name == "tuser", "Incorrect username"
-    assert result.user.id == 1000, "Incorrect UID"
+    id_entry = shadow.tools.id("tuser")
+    assert id_entry is not None, "User should be found"
+    assert id_entry.user.name == "tuser", "Incorrect username"
+    assert id_entry.user.id == 1000, "Incorrect UID"
 
-    result = shadow.tools.getent.group("tuser")
-    assert result is not None, "Group should be found"
-    assert result.name == "tuser", "Incorrect groupname"
-    assert result.gid == 1000, "Incorrect GID"
+    group_entry = shadow.tools.getent.group("tuser")
+    assert group_entry is not None, "Group should be found"
+    assert group_entry.name == "tuser", "Incorrect groupname"
+    assert group_entry.gid == 1000, "Incorrect GID"
 
     assert shadow.fs.exists("/home/tuser"), "Home folder should be found"
 
index 78c6bb361c5ed0b732516aff1fc21c324eb1e5b5..f9af13a7c82877d6aa6a1bc249dc9696718f2c9b 100644 (file)
@@ -34,16 +34,16 @@ def test_userdel__homedir_removed(shadow: Shadow):
     shadow.useradd("tuser")
     shadow.userdel("-r tuser")
 
-    result = shadow.tools.getent.passwd("tuser")
-    assert result is None, "User should not be found"
+    passwd_entry = shadow.tools.getent.passwd("tuser")
+    assert passwd_entry is None, "User should not be found"
 
-    result = shadow.tools.getent.shadow("tuser")
-    assert result is None, "User should not be found"
+    shadow_entry = shadow.tools.getent.shadow("tuser")
+    assert shadow_entry is None, "User should not be found"
 
-    result = shadow.tools.getent.group("tuser")
-    assert result is None, "Group should not be found"
+    group_entry = shadow.tools.getent.group("tuser")
+    assert group_entry is None, "Group should not be found"
 
-    result = shadow.tools.getent.gshadow("tuser1")
-    assert result is None, "User should not be found"
+    gshadow_entry = shadow.tools.getent.gshadow("tuser1")
+    assert gshadow_entry is None, "User should not be found"
 
     assert not shadow.fs.exists("/home/tuser"), "Home folder should not exist"
index fa757a053d2e343d213353374d824c7b7991f8d6..b7cf2e3e57f8f580c3d32b9b7d00f50b9069c7d0 100644 (file)
@@ -5,8 +5,8 @@ Test usermod
 from __future__ import annotations
 
 import pytest
-
 from pytest_mh.conn import ProcessError
+
 from framework.roles.shadow import Shadow
 from framework.topology import KnownTopology
 
@@ -35,24 +35,24 @@ def test_usermod__rename_user(shadow: Shadow):
     shadow.useradd("tuser1")
     shadow.usermod("-l tuser2 tuser1")
 
-    result = shadow.tools.getent.passwd("tuser2")
-    assert result is not None, "User should be found"
-    assert result.name == "tuser2", "Incorrect username"
-    assert result.uid == 1000, "Incorrect UID"
+    passwd_entry = shadow.tools.getent.passwd("tuser2")
+    assert passwd_entry is not None, "User should be found"
+    assert passwd_entry.name == "tuser2", "Incorrect username"
+    assert passwd_entry.uid == 1000, "Incorrect UID"
 
-    result = shadow.tools.getent.shadow("tuser2")
-    assert result is not None, "User should be found"
-    assert result.name == "tuser2", "Incorrect username"
+    shadow_entry = shadow.tools.getent.shadow("tuser2")
+    assert shadow_entry is not None, "User should be found"
+    assert shadow_entry.name == "tuser2", "Incorrect username"
 
-    result = shadow.tools.getent.group("tuser1")
-    assert result is not None, "Group should be found"
-    assert result.name == "tuser1", "Incorrect groupname"
-    assert result.gid == 1000, "Incorrect GID"
+    group_entry = shadow.tools.getent.group("tuser1")
+    assert group_entry is not None, "Group should be found"
+    assert group_entry.name == "tuser1", "Incorrect groupname"
+    assert group_entry.gid == 1000, "Incorrect GID"
 
     if shadow.host.features["gshadow"]:
-        result = shadow.tools.getent.gshadow("tuser1")
-        assert result is not None, "User should be found"
-        assert result.name == "tuser1", "Incorrect username"
+        gshadow_entry = shadow.tools.getent.gshadow("tuser1")
+        assert gshadow_entry is not None, "User should be found"
+        assert gshadow_entry.name == "tuser1", "Incorrect username"
 
     assert shadow.fs.exists("/home/tuser1"), "Home folder should be found"