Unit testing HasProducts

The test method for the products property, testproducts, has to account for the read only nature of the property—remember that the products property is set up to prevent, or at least minimize, the possibility of casual manipulation of the underlying list value. Apart from the changes to the tests of setter and deleter method assignment, it's pretty much the same as previous property test methods, though:

def testproducts(self): # Tests the products property of the HasProducts class # - Assert that the getter is correct: self.assertEqual( HasProducts.products.fget, HasProducts._get_products, 'HasProducts.products is expected to use the ' '_get_products method as its getter-method' ) # - Assert that the setter is correct: ...

Get Hands-On Software Engineering with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.