Automated testing: Difference between revisions

Replaced content with "{{Hacking OpenHatch}} This page is now included in our project package, and is automatically generated by sphinx at openhatch.readthedocs.org: [http://openhatch.readthedo..."
(Gustavo)
imported>Blues chick
(Replaced content with "{{Hacking OpenHatch}} This page is now included in our project package, and is automatically generated by sphinx at openhatch.readthedocs.org: [http://openhatch.readthedo...")
 
(5 intermediate revisions by 2 users not shown)
Line 1:
{{Hacking OpenHatch}}
Better solution:class Product(object): def __init__(self, purcodt_id): self.id = purcodt_iddef make_property(prop): def getter(self): return api_obj.get_product_property(self.id, prop) return property(getter)for prop in ('price', 'attr'): setattr(Product, prop, make_property(prop))Reasons this is better: * You don’t break dir(product): it still shows the properties. * You get the AttributeError for free.If you want to support an arbitrary number of properties, it probably makes more sense to have a .get_property(prop) method, or to use .__getitem__ instead.
 
This page is now included in our project package, and is automatically generated by sphinx at openhatch.readthedocs.org: [http://openhatch.readthedocs.org/en/latest/advanced/advanced_testing.html Advanced Testing]
Anonymous user