示例工程 06-functions-closures

06-functions-closures/02-late-binding-loop/test_late_binding_loop.py

python · 0.3 KB

"""test_late_binding_loop.py"""
 
from __future__ import annotations
 
from late_binding_loop import make_bad, make_good
 
 
def test_bad_captures_final_value() -> None:
    assert [fn() for fn in make_bad()] == [2, 2, 2]
 
 
def test_good_binds_each_value() -> None:
    assert [fn() for fn in make_good()] == [0, 1, 2]