# %% test_fail(lambda: test_is([1], [1])) a = [1] test_is(a, a) # %% #export def test_stdout(f, exp, regex=False): s = io.StringIO() with redirect_stdout(s): f() if regex: assert re.search(exp, s.getvalue()) is not None else: test_eq(s.getvalue(), f'{exp}\n' if len(exp) > 0 else '') # %% test_stdout(lambda: print('hi'), 'hi') test_fail(lambda: test_stdout(lambda: print('hi'), 'ho')) test_stdout(lambda: 1 + 1, '') test_stdout(lambda: print('hi there!'), r'^hi.*!$', regex=True) # %% markdown # ## Export - # %% #hide from local.notebook.export import notebook2script notebook2script(all_fs=True) # %%
def main(fname: Param("A notebook name to convert", str) = None, all_fs: Param("Use True for all notebooks or a glob pattern") = None, up_to: Param("Use to limit the conversion", str) = None): if fname is None and all_fs is None: all_fs = True notebook2script(fname=fname, all_fs=all_fs, up_to=up_to)