Skip to content

Commit e60384c

Browse files
frozencemeterysimo5
authored andcommitted
[tests] Fixup virtualenv handling
Fixes an issue where virtualenv's PATH would get lost Signed-off-by: Robbie Harwood <rharwood@redhat.com>
1 parent 367120a commit e60384c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

tests/magtests.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def setup_wrappers(base):
7777
return wenv
7878

7979

80+
def apply_venv(env):
81+
env['PATH'] = os.environ.get('PATH', '')
82+
env['VIRTUAL_ENV'] = os.environ.get('VIRTUAL_ENV', '')
83+
return env
84+
85+
8086
TESTREALM = "MAG.DEV"
8187
KDC_DBNAME = 'db.file'
8288
KDC_STASH = 'stash.file'
@@ -314,7 +320,7 @@ def setup_kdc(testdir, wrapenv):
314320
with open(kdcconf, 'w+') as f:
315321
f.write(text)
316322

317-
kdcenv = {'PATH': '/sbin:/bin:/usr/sbin:/usr/bin',
323+
kdcenv = {'PATH': f'/sbin:/bin:/usr/sbin:/usr/bin:{wrapenv["PATH"]}',
318324
'KRB5_CONFIG': krb5conf,
319325
'KRB5_KDC_PROFILE': kdcconf,
320326
'KRB5_TRACE': os.path.join(testdir, 'krbtrace.log')}
@@ -425,7 +431,7 @@ def setup_http(testdir, so_dir, wrapenv):
425431

426432
shutil.copy('tests/401.html', os.path.join(httpdir, 'html'))
427433

428-
httpenv = {'PATH': '/sbin:/bin:/usr/sbin:/usr/bin',
434+
httpenv = {'PATH': f'/sbin:/bin:/usr/sbin:/usr/bin:{wrapenv["PATH"]}',
429435
'MALLOC_CHECK_': '3',
430436
'MALLOC_PERTURB_': str(random.randint(0, 32767) % 255 + 1)}
431437
httpenv.update(wrapenv)
@@ -755,8 +761,7 @@ def faketime_setup(testenv):
755761

756762

757763
def http_restart(testdir, so_dir, testenv):
758-
759-
httpenv = {'PATH': '/sbin:/bin:/usr/sbin:/usr/bin',
764+
httpenv = {'PATH': f'/sbin:/bin:/usr/sbin:/usr/bin:{testenv["PATH"]}',
760765
'MALLOC_CHECK_': '3',
761766
'MALLOC_PERTURB_': str(random.randint(0, 32767) % 255 + 1)}
762767
httpenv.update(testenv)
@@ -781,7 +786,7 @@ def http_restart(testdir, so_dir, testenv):
781786
logfile = open(os.path.join(testdir, 'tests.log'), 'w')
782787
errs = 0
783788
try:
784-
wrapenv = setup_wrappers(testdir)
789+
wrapenv = apply_venv(setup_wrappers(testdir))
785790

786791
kdcproc, kdcenv = setup_kdc(testdir, wrapenv)
787792
processes['KDC(%d)' % kdcproc.pid] = kdcproc
@@ -792,10 +797,6 @@ def http_restart(testdir, so_dir, testenv):
792797
keysenv = setup_keys(testdir, kdcenv)
793798
testenv = kinit_user(testdir, kdcenv)
794799

795-
# support virtualenv
796-
testenv['PATH'] = os.environ.get('PATH', '')
797-
testenv['VIRTUAL_ENV'] = os.environ.get('VIRTUAL_ENV', '')
798-
799800
testenv['DELEGCCACHE'] = os.path.join(testdir, 'httpd',
800801
USR_NAME + '@' + TESTREALM)
801802
errs += test_spnego_auth(testdir, testenv, logfile)
@@ -826,8 +827,6 @@ def http_restart(testdir, so_dir, testenv):
826827
'MAG_USER_NAME_2': USR_NAME_2,
827828
'MAG_USER_PASSWORD_2': USR_PWD_2}
828829
testenv.update(kdcenv)
829-
testenv['PATH'] = os.environ.get('PATH', '')
830-
testenv['VIRTUAL_ENV'] = os.environ.get('VIRTUAL_ENV', '')
831830

832831
errs += test_basic_auth_krb5(testdir, testenv, logfile)
833832

0 commit comments

Comments
 (0)