def test_invoke_with_curdoc() -> None: reported_curdoc = None d = Document() def f() -> None: nonlocal reported_curdoc reported_curdoc = curdoc() bdc.invoke_with_curdoc(d, f) assert reported_curdoc == d
def test_invoke_with_curdoc_nolock() -> None: reported_curdoc = None d = Document() def f() -> None: nonlocal reported_curdoc reported_curdoc = curdoc() f.nolock = True # type: ignore [attr-defined] bdc.invoke_with_curdoc(d, f) assert isinstance(reported_curdoc, UnlockedDocumentProxy) assert reported_curdoc._doc == d