예제 #1
0
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
예제 #2
0
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