Skip to content

Commit ad1b888

Browse files
committed
tests: split extract replace_conn_file into a new function
1 parent e753a07 commit ad1b888

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test_envkernel.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ def run(d, kern, execvp=lambda _argv0, argv: 0):
5858
clsname = argv[1]
5959
assert argv[2] == 'run'
6060
# Replace connecton file
61-
def replace_conn_file(x):
62-
if x == '{connection_file}': return connection_file
63-
else: return x
64-
argv = [ replace_conn_file(x) for x in argv ]
61+
argv = [ replace_conn_file(x, connection_file) for x in argv ]
6562
# Setup object, override the execvp for the function, run.
6663
ek = getattr(envkernel, clsname)(argv[3:])
6764
ek.execvp = execvp
@@ -73,6 +70,14 @@ def d():
7370
with tempfile.TemporaryDirectory() as dir_:
7471
yield dir_
7572

73+
def replace_conn_file(arg, connection_file):
74+
if isinstance(arg, list):
75+
return [ replace_conn_file(x, connection_file) for x in arg ]
76+
if arg == '{connection_file}':
77+
return connection_file
78+
else:
79+
return arg
80+
7681
def all_modes(modes=None):
7782
if not modes:
7883
modes = ALL_MODULES

0 commit comments

Comments
 (0)