Commit 718ec498 authored by Łukasz Nowak's avatar Łukasz Nowak

Again use local references to global modules.

Thanks to this blackbox testing is much easier.
parent c854a012
...@@ -430,6 +430,8 @@ class User: ...@@ -430,6 +430,8 @@ class User:
""" """
self.name = str(user_name) self.name = str(user_name)
self.additional_group_list = additional_group_list self.additional_group_list = additional_group_list
self._getpwnam = getpwnam
self._grp = grp
def __getinitargs__(self): def __getinitargs__(self):
return (self.name,) return (self.name,)
...@@ -449,7 +451,7 @@ class User: ...@@ -449,7 +451,7 @@ class User:
# This method shall check if all is correctly done # This method shall check if all is correctly done
# This method shall not reset groups, just add them # This method shall not reset groups, just add them
try: try:
grp.getgrnam(self.name) self._grp.getgrnam(self.name)
except KeyError: except KeyError:
callAndRead(['groupadd', self.name]) callAndRead(['groupadd', self.name])
...@@ -458,7 +460,7 @@ class User: ...@@ -458,7 +460,7 @@ class User:
user_parameter_list.extend(['-G', ','.join(self.additional_group_list)]) user_parameter_list.extend(['-G', ','.join(self.additional_group_list)])
user_parameter_list.append(self.name) user_parameter_list.append(self.name)
try: try:
getpwnam(self.name) self._getpwnam(self.name)
except KeyError: except KeyError:
callAndRead(['useradd'] + user_parameter_list) callAndRead(['useradd'] + user_parameter_list)
else: else:
...@@ -476,7 +478,7 @@ class User: ...@@ -476,7 +478,7 @@ class User:
""" """
try: try:
getpwnam(self.name) self._getpwnam(self.name)
return True return True
except KeyError: except KeyError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment