Commit a73d70f TESTS: Move get_call_output() to util.py

2 files Authored by fidencio 5 months ago , Committed by jhrozek 5 months ago ,
TESTS: Move get_call_output() to util.py

This function will be reused outside of test_sssctl.py.

Related:
https://pagure.io/SSSD/sssd/issue/3658

Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>

Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>

    
 1 @@ -28,7 +28,7 @@
 2   import ds_openldap
 3   import ldap_ent
 4   import config
 5 - from util import unindent
 6 + from util import unindent, get_call_output
 7   import sssd_netgroup
 8   
 9   LDAP_BASE_DN = "dc=example,dc=com"
10 @@ -203,13 +203,6 @@
11       return None
12   
13   
14 - def get_call_output(cmd):
15 -     process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
16 -                                stderr=subprocess.PIPE)
17 -     output, ret = process.communicate()
18 -     return output.decode('utf-8')
19 - 
20 - 
21   def test_user_show_basic_sanity(ldap_conn, sanity_rfc2307, portable_LC_ALL):
22       # Fill the cache first
23       ent.assert_passwd_by_name(
 1 @@ -78,3 +78,10 @@
 2       path = os.environ[name]
 3       backup_path = path + ".bak"
 4       os.rename(backup_path, path)
 5 + 
 6 + 
 7 + def get_call_output(cmd):
 8 +     process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
 9 +                                stderr=subprocess.PIPE)
10 +     output, ret = process.communicate()
11 +     return output.decode('utf-8')