예제 #1
0
def test_auto_delete_scoping_local():
    scop = Scoping()
    s = scop.as_local_scoping()
    s.append(1)
    del s
    with scop.as_local_scoping() as s:
        assert s[0] == 1
예제 #2
0
def test_as_local_scoping2():
    scop = Scoping()
    with scop.as_local_scoping() as loc:
        loc.location = "Nodal"
        loc.ids = range(1, 101)
        for i in range(0, 100):
            assert loc.id(i) == i + 1
            assert loc.index(i + 1) == i
        assert hasattr(loc, "_is_set") is True
        assert loc._is_set is True
    assert scop.ids == list(range(1, 101))
    assert scop.location == "Nodal"
    with scop.as_local_scoping() as loc:
        assert loc.location == "Nodal"
        for i in range(0, 100):
            assert loc.id(i) == i + 1
            assert loc.index(i + 1) == i
        assert hasattr(loc, "_is_set") is False