I have a mock object for following class
class Book(object):
def __init__(self):
self._counter = 1
@property
def counter(self):
_, self._counter = self._counter, self._counter + 1
return _
the class Book have following Mock object
book = Mock(spec = Book, self._counter = 1)
if counter is not a property I could have written test as such
def test_counter(self):
book.counter = partial(Book.counter, book)
self.assertNotEquals(book.counter(), book.counter())
however since it is a property, the above strategy won't work, can you suggest a good way to write test for the property given I have to use Mock object for Book class.