|
316 | 316 | " recursive=get_config().recursive\n", |
317 | 317 | " res = globtastic(path, file_glob=file_glob, skip_folder_re=skip_folder_re,\n", |
318 | 318 | " skip_file_re=skip_file_re, recursive=recursive, **kwargs)\n", |
319 | | - " res = res.map(Path) if as_path else res\n", |
320 | | - " return res" |
| 319 | + " return res.map(Path) if as_path else res" |
321 | 320 | ] |
322 | 321 | }, |
323 | 322 | { |
|
361 | 360 | " _build_modidx()" |
362 | 361 | ] |
363 | 362 | }, |
364 | | - { |
365 | | - "cell_type": "markdown", |
366 | | - "metadata": {}, |
367 | | - "source": [ |
368 | | - "When exporting the notebooks, they should be exported in order of the filename to ensure deterministic build behaviour. The below test patches `nbglob` to return a non-ordered list, then checks that `nb_export` is still called on the notebooks in the right order:" |
369 | | - ] |
370 | | - }, |
371 | | - { |
372 | | - "cell_type": "code", |
373 | | - "execution_count": null, |
374 | | - "metadata": {}, |
375 | | - "outputs": [], |
376 | | - "source": [ |
377 | | - "from copy import copy\n", |
378 | | - "\n", |
379 | | - "\n", |
380 | | - "class EscapeException(Exception):\n", |
381 | | - " pass\n", |
382 | | - "\n", |
383 | | - "def nb_export_mock(nb_path: str):\n", |
384 | | - " expected = expected_order.pop()\n", |
385 | | - " assert nb_path==expected, f'Expected {expected}, got {nb_path}'\n", |
386 | | - " \n", |
387 | | - " # escape from the outer function as the tests are done\n", |
388 | | - " if not expected_order:\n", |
389 | | - " raise EscapeException()\n", |
390 | | - " \n", |
391 | | - "# replace those functions by mocks, saving the original objects\n", |
392 | | - "nbglob_save = copy(nbglob)\n", |
393 | | - "nb_export_save = copy(nb_export)\n", |
394 | | - "\n", |
395 | | - "nbglob = lambda *args, **kwargs: L(['../../8.ipynb', 'api/3.ipynb', '4.ipynb']).map(Path)\n", |
396 | | - "\n", |
397 | | - "expected_order = reversed(L(['api/3.ipynb', '4.ipynb', '../../8.ipynb']).map(Path))\n", |
398 | | - "#expected_order.reverse()\n", |
399 | | - "nb_export = nb_export_mock\n", |
400 | | - "\n", |
401 | | - "try:\n", |
402 | | - " nbdev_export()\n", |
403 | | - "except EscapeException:\n", |
404 | | - " pass # this silences the exception used to end nbdev_export early\n", |
405 | | - "\n", |
406 | | - "# restore original objects to make sure the notebook runs as intended\n", |
407 | | - "nbglob = nbglob_save\n", |
408 | | - "nb_export = nb_export_save" |
409 | | - ] |
410 | | - }, |
411 | 363 | { |
412 | 364 | "cell_type": "markdown", |
413 | 365 | "metadata": {}, |
|
0 commit comments