Skip to content

Commit 46d05d4

Browse files
committed
remove mock test
1 parent a196c2f commit 46d05d4

File tree

2 files changed

+7
-56
lines changed

2 files changed

+7
-56
lines changed

nbdev/doclinks.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ def nbglob(path=None, skip_folder_re = '^[_.]', file_glob='*.ipynb', skip_file_r
110110
recursive=get_config().recursive
111111
res = globtastic(path, file_glob=file_glob, skip_folder_re=skip_folder_re,
112112
skip_file_re=skip_file_re, recursive=recursive, **kwargs)
113-
res = res.map(Path) if as_path else res
114-
return res
113+
return res.map(Path) if as_path else res
115114

116115
# %% ../nbs/api/doclinks.ipynb 21
117116
def nbglob_cli(
@@ -140,11 +139,11 @@ def nbdev_export(
140139
add_init(get_config().lib_path)
141140
_build_modidx()
142141

143-
# %% ../nbs/api/doclinks.ipynb 26
142+
# %% ../nbs/api/doclinks.ipynb 24
144143
import importlib,ast
145144
from functools import lru_cache
146145

147-
# %% ../nbs/api/doclinks.ipynb 27
146+
# %% ../nbs/api/doclinks.ipynb 25
148147
def _find_mod(mod):
149148
mp,_,mr = mod.partition('/')
150149
spec = importlib.util.find_spec(mp)
@@ -167,7 +166,7 @@ def _get_exps(mod):
167166

168167
def _lineno(sym, fname): return _get_exps(fname).get(sym, None) if fname else None
169168

170-
# %% ../nbs/api/doclinks.ipynb 29
169+
# %% ../nbs/api/doclinks.ipynb 27
171170
def _qual_sym(s, settings):
172171
if not isinstance(s,tuple): return s
173172
nb,py = s
@@ -182,10 +181,10 @@ def _qual_syms(entries):
182181
if 'doc_host' not in settings: return entries
183182
return {'syms': {mod:_qual_mod(d, settings) for mod,d in entries['syms'].items()}, 'settings':settings}
184183

185-
# %% ../nbs/api/doclinks.ipynb 30
184+
# %% ../nbs/api/doclinks.ipynb 28
186185
_re_backticks = re.compile(r'`([^`\s]+)`')
187186

188-
# %% ../nbs/api/doclinks.ipynb 31
187+
# %% ../nbs/api/doclinks.ipynb 29
189188
@lru_cache(None)
190189
class NbdevLookup:
191190
"Mapping from symbol names to docs and source URLs"

nbs/api/doclinks.ipynb

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@
316316
" recursive=get_config().recursive\n",
317317
" res = globtastic(path, file_glob=file_glob, skip_folder_re=skip_folder_re,\n",
318318
" 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"
321320
]
322321
},
323322
{
@@ -361,53 +360,6 @@
361360
" _build_modidx()"
362361
]
363362
},
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-
},
411363
{
412364
"cell_type": "markdown",
413365
"metadata": {},

0 commit comments

Comments
 (0)