4 ms·
Context managers are quite powerful, you can use them for more than resource closing. They're handy to make instrumentation easier too, for example by allowing
by bbrazil 11y ago
Context managers are quite powerful, you can use them for more than resource closing. They're handy to make instrumentation easier too, for example by allowing you put the code you want to count exceptions in in a with block as shown in http://www.slideshare.net/brianbrazil/python-ireland-monitoring-your-python-with-prometheus/25 http://www.slideshare.net/brianbrazil/python-ireland-monitor...
- ckv428 11y agoI've had success implementing context managers with page object models when testing with selenium. All page objects assume the same base page (e.g. the home page of the web app) and will return the browser to that page upon exiting the with block. It works really well.