Skip to content

Augment functools.cached_property tests for set/delete #142252

Description

@gsakkis

cached_property supports set and delete but this is not currently tested.

Minimal test extending TestCachedProperty.test_cached:

class TestCachedProperty(unittest.TestCase):
    def test_cached(self):
        item = CachedCostItem()
        self.assertEqual(item.cost, 2)
        self.assertEqual(item.cost, 2) # not 3

        item.cost = 42
        self.assertEqual(item.cost, 42)

        del item.cost
        self.assertEqual(item.cost, 3)
        self.assertEqual(item.cost, 3) # not 4

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions