Skip to content

Commit 15b1623

Browse files
committed
fixes #1567
1 parent 5d60496 commit 15b1623

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

nbdev/test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def test_nb(fn, # file name of notebook to test
2828
force_flags=None, # list of flags marking cells to always run
2929
do_print=False, # print completion?
3030
showerr=True, # print errors to stderr?
31-
basepath=None): # path to add to sys.path
31+
basepath=None, # path to add to sys.path
32+
verbose=False): # stream stdout/stderr from cells to console?
3233
"Execute tests in notebook in `fn` except those with `skip_flags`"
3334
if basepath: sys.path.insert(0, str(basepath))
3435
if not IN_NOTEBOOK: os.environ["IN_TEST"] = '1'
@@ -49,7 +50,7 @@ def _no_eval(cell):
4950
if do_print: print(f'Starting {fn}')
5051
try:
5152
with working_directory(fn.parent):
52-
k.run_all(nb, exc_stop=True, preproc=_no_eval)
53+
k.run_all(nb, exc_stop=True, preproc=_no_eval, verbose=verbose)
5354
res = True
5455
except:
5556
if showerr: sys.stderr.write(k.prettytb(fname=fn)+'\n')
@@ -76,6 +77,7 @@ def nbdev_test(
7677
do_print:bool=False, # Print start and end of each notebook
7778
pause:float=0.01, # Pause time (in seconds) between notebooks to avoid race conditions
7879
ignore_fname:str='.notest', # Filename that will result in siblings being ignored
80+
verbose:bool=False, # Print stdout/stderr from notebook cells?
7981
**kwargs):
8082
"Test in parallel notebooks matching `path`, passing along `flags`"
8183
skip_flags = get_config().tst_flags
@@ -90,7 +92,7 @@ def nbdev_test(
9092
wd_pth = get_config().nbs_path
9193
with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):
9294
results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers,
93-
basepath=get_config().config_path, pause=pause, do_print=do_print, **kw)
95+
basepath=get_config().config_path, pause=pause, do_print=do_print, verbose=verbose, **kw)
9496
passed,times = zip(*results)
9597
if all(passed): print("Success.")
9698
else:

nbs/api/12_test.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
" force_flags=None, # list of flags marking cells to always run\n",
5959
" do_print=False, # print completion?\n",
6060
" showerr=True, # print errors to stderr?\n",
61-
" basepath=None): # path to add to sys.path\n",
61+
" basepath=None, # path to add to sys.path\n",
62+
" verbose=False): # stream stdout/stderr from cells to console?\n",
6263
" \"Execute tests in notebook in `fn` except those with `skip_flags`\"\n",
6364
" if basepath: sys.path.insert(0, str(basepath))\n",
6465
" if not IN_NOTEBOOK: os.environ[\"IN_TEST\"] = '1'\n",
@@ -79,7 +80,7 @@
7980
" if do_print: print(f'Starting {fn}')\n",
8081
" try:\n",
8182
" with working_directory(fn.parent):\n",
82-
" k.run_all(nb, exc_stop=True, preproc=_no_eval)\n",
83+
" k.run_all(nb, exc_stop=True, preproc=_no_eval, verbose=verbose)\n",
8384
" res = True\n",
8485
" except: \n",
8586
" if showerr: sys.stderr.write(k.prettytb(fname=fn)+'\\n')\n",
@@ -170,6 +171,7 @@
170171
" do_print:bool=False, # Print start and end of each notebook\n",
171172
" pause:float=0.01, # Pause time (in seconds) between notebooks to avoid race conditions\n",
172173
" ignore_fname:str='.notest', # Filename that will result in siblings being ignored\n",
174+
" verbose:bool=False, # Print stdout/stderr from notebook cells?\n",
173175
" **kwargs):\n",
174176
" \"Test in parallel notebooks matching `path`, passing along `flags`\"\n",
175177
" skip_flags = get_config().tst_flags\n",
@@ -184,7 +186,7 @@
184186
" wd_pth = get_config().nbs_path\n",
185187
" with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):\n",
186188
" results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers,\n",
187-
" basepath=get_config().config_path, pause=pause, do_print=do_print, **kw)\n",
189+
" basepath=get_config().config_path, pause=pause, do_print=do_print, verbose=verbose, **kw)\n",
188190
" passed,times = zip(*results)\n",
189191
" if all(passed): print(\"Success.\")\n",
190192
" else: \n",

0 commit comments

Comments
 (0)