@@ -74,12 +74,12 @@ def pytest_addoption(parser):
7474 help = "Run Jupyter notebooks, only validating output on "
7575 "cells marked with # NBVAL_CHECK_OUTPUT" )
7676
77- group .addoption ('--sanitize-with' ,
77+ group .addoption ('--nbval- sanitize-with' ,
7878 help = 'File with regex expressions to sanitize '
7979 'the outputs. This option only works when '
8080 'the --nbval flag is passed to py.test' )
8181
82- group .addoption ('--current-env' , action = 'store_true' ,
82+ group .addoption ('--nbval- current-env' , action = 'store_true' ,
8383 help = 'Force test execution to use a python kernel in '
8484 'the same environment that py.test was '
8585 'launched from. Without this flag, the kernel stored '
@@ -100,6 +100,12 @@ def pytest_addoption(parser):
100100 type = float ,
101101 help = 'Timeout for kernel startup, in seconds.' )
102102
103+ group .addoption ('--sanitize-with' ,
104+ help = '(deprecated) Alias of --nbval-sanitize-with' )
105+
106+ group .addoption ('--current-env' , action = 'store_true' ,
107+ help = '(deprecated) Alias of --nbval-current-env' )
108+
103109 term_group = parser .getgroup ("terminal reporting" )
104110 term_group ._addoption (
105111 '--nbdime' , action = 'store_true' ,
@@ -111,6 +117,16 @@ def pytest_configure(config):
111117 from .nbdime_reporter import NbdimeReporter
112118 reporter = NbdimeReporter (config , sys .stdout )
113119 config .pluginmanager .register (reporter , 'nbdimereporter' )
120+ if config .option .sanitize_with :
121+ warnings .warn ("--sanitize-with has been renamed to --nbval-sanitize-with" , DeprecationWarning )
122+ if config .option .nbval_sanitize_with :
123+ raise ValueError ("--sanitize-with and --nbval-sanitize-with were both supplied." )
124+ config .option .nbval_sanitize_with = config .option .sanitize_with
125+ if config .option .current_env :
126+ warnings .warn ("--current-env has been renamed to --nbval-current-env" , DeprecationWarning )
127+ if config .option .nbval_current_env :
128+ raise ValueError ("--current-env and --nbval-current-env were both supplied." )
129+ config .option .nbval_current_env = config .option .current_env
114130 if config .option .nbval or config .option .nbval_lax :
115131 if config .option .nbval_kernel_name and config .option .current_env :
116132 raise ValueError ("--current-env and --nbval-kernel-name are mutually exclusive." )
@@ -239,9 +255,9 @@ def setup(self):
239255 Called by pytest to setup the collector cells in .
240256 Here we start a kernel and setup the sanitize patterns.
241257 """
242- # we've already checked that --current-env and
258+ # we've already checked that --nbval- current-env and
243259 # --nbval-kernel-name were not both supplied
244- if self .parent .config .option .current_env :
260+ if self .parent .config .option .nbval_current_env :
245261 kernel_name = CURRENT_ENV_KERNEL_NAME
246262 elif self .parent .config .option .nbval_kernel_name :
247263 kernel_name = self .parent .config .option .nbval_kernel_name
@@ -276,8 +292,8 @@ def get_sanitize_files(self):
276292 this is likely to change in the future
277293
278294 """
279- if self .parent .config .option .sanitize_with is not None :
280- return [self .parent .config .option .sanitize_with ]
295+ if self .parent .config .option .nbval_sanitize_with is not None :
296+ return [self .parent .config .option .nbval_sanitize_with ]
281297 else :
282298 return []
283299
0 commit comments