@@ -86,8 +86,16 @@ def pytest_addoption(parser):
86
86
87
87
group .addoption ('--current-env' , action = 'store_true' ,
88
88
help = 'Force test execution to use a python kernel in '
89
- 'the same enviornment that py.test was '
90
- 'launched from.' )
89
+ 'the same environment that py.test was '
90
+ 'launched from. Without this flag, the kernel stored '
91
+ 'in the notebook is used by default. '
92
+ 'See also: --kernel-name' )
93
+
94
+ group .addoption ('--kernel-name' , action = 'store' , default = None ,
95
+ help = 'Force test execution to use the named kernel. '
96
+ 'If a kernel is not named, the kernel stored in the '
97
+ 'notebook is used by default. '
98
+ 'See also: --current-env' )
91
99
92
100
group .addoption ('--nbval-cell-timeout' , action = 'store' , default = 2000 ,
93
101
type = float ,
@@ -224,9 +232,12 @@ def setup(self):
224
232
Called by pytest to setup the collector cells in .
225
233
Here we start a kernel and setup the sanitize patterns.
226
234
"""
227
-
235
+ if self .parent .config .option .kernel_name and self .parent .config .option .current_env :
236
+ raise ValueError ("--current-env and --kernel-name are mutually exclusive." )
228
237
if self .parent .config .option .current_env :
229
238
kernel_name = CURRENT_ENV_KERNEL_NAME
239
+ elif self .parent .config .option .kernel_name :
240
+ kernel_name = self .parent .config .option .kernel_name
230
241
else :
231
242
kernel_name = self .nb .metadata .get (
232
243
'kernelspec' , {}).get ('name' , 'python' )
0 commit comments