{"action":"created","issue":{"url":"https://api.github.com/repos/kaste/mockito-python/issues/15","repository_url":"https://api.github.com/repos/kaste/mockito-python","labels_url":"https://api.github.com/repos/kaste/mockito-python/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/kaste/mockito-python/issues/15/comments","events_url":"https://api.github.com/repos/kaste/mockito-python/issues/15/events","html_url":"https://github.com/kaste/mockito-python/issues/15","id":282809387,"number":15,"title":"How to mock @property ","user":{"login":"aaltat","id":2665023,"avatar_url":"https://avatars0.githubusercontent.com/u/2665023?v=4","gravatar_id":"","url":"https://api.github.com/users/aaltat","html_url":"https://github.com/aaltat","followers_url":"https://api.github.com/users/aaltat/followers","following_url":"https://api.github.com/users/aaltat/following{/other_user}","gists_url":"https://api.github.com/users/aaltat/gists{/gist_id}","starred_url":"https://api.github.com/users/aaltat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaltat/subscriptions","organizations_url":"https://api.github.com/users/aaltat/orgs","repos_url":"https://api.github.com/users/aaltat/repos","events_url":"https://api.github.com/users/aaltat/events{/privacy}","received_events_url":"https://api.github.com/users/aaltat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-18T09:13:43Z","updated_at":"2017-12-18T09:34:44Z","closed_at":null,"author_association":"NONE","body":"When I have this: \r\n```\r\nimport unittest\r\n\r\nfrom mockito import unstub\r\n\r\n\r\nclass ClassName(object):\r\n\r\n    @property\r\n    def value(self):\r\n        return 42\r\n\r\n    def is_value(self):\r\n        if self.value == 42:\r\n            return 'is 42'\r\n        raise ValueError()\r\n\r\n\r\nclass TestClassName(unittest.TestCase):\r\n\r\n    def test_foo(self):\r\n        x = ClassName()\r\n        with self.assertRaises(ValueError):\r\n            x.is_value()\r\n        unstub()\r\n\r\n\r\nif __name__ == '__main__':\r\n    unittest.main()\r\n```\r\nIs there an easy to way to mock what `value` property returns? "},"comment":{"url":"https://api.github.com/repos/kaste/mockito-python/issues/comments/352372899","html_url":"https://github.com/kaste/mockito-python/issues/15#issuecomment-352372899","issue_url":"https://api.github.com/repos/kaste/mockito-python/issues/15","id":352372899,"user":{"login":"kaste","id":8558,"avatar_url":"https://avatars1.githubusercontent.com/u/8558?v=4","gravatar_id":"","url":"https://api.github.com/users/kaste","html_url":"https://github.com/kaste","followers_url":"https://api.github.com/users/kaste/followers","following_url":"https://api.github.com/users/kaste/following{/other_user}","gists_url":"https://api.github.com/users/kaste/gists{/gist_id}","starred_url":"https://api.github.com/users/kaste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaste/subscriptions","organizations_url":"https://api.github.com/users/kaste/orgs","repos_url":"https://api.github.com/users/kaste/repos","events_url":"https://api.github.com/users/kaste/events{/privacy}","received_events_url":"https://api.github.com/users/kaste/received_events","type":"User","site_admin":false},"created_at":"2017-12-18T09:34:44Z","updated_at":"2017-12-18T09:34:44Z","author_association":"OWNER","body":"In general you have to mock the class, t.i. `ClassName`\r\n\r\nSo easy-peasy solution here is `setattr(ClassName, 'value', 41)` or even `ClassName.value = 41`"}}
{"actor":{"display_login":"kaste"}}