

def test_cached_property():
    team1 = Team.objects.create(name='Team1')
    team2 = Team.objects.create(name='Team2')
    tools.assert_equal(team1.get_counter(), 1)
    tools.assert_equal(team1.get_counter(), 2)
    tools.assert_equal(team1.get_counter(), 3)
    tools.assert_equal(team1.cached_counter, 4)
    tools.assert_equal(team1.cached_counter, 4)
    tools.assert_equal(team1.cached_counter, 4)
    team1_new = Team.objects.get(pk=team1.pk)
    tools.assert_equal(team1_new.cached_counter, 4)
    tools.assert_equal(team1_new.cached_counter, 4)
    team2.get_counter()
    tools.assert_equal(team2.cached_counter, 2)
    tools.assert_equal(team2.cached_counter, 2)
    del team1_new.cached_counter
    tools.assert_equal(team1.cached_counter, 5)
    tools.assert_equal(team1_new.cached_counter, 5)
    del team1_new.cached_counter
    tools.assert_equal(team1_new.cached_counter, 1)
    tools.assert_equal(team2.cached_counter, 2)

dataset/ETHPy150Open rewardz/django_model_helpers/tests/test_cached_property.py test_cached_property/original