On Thu, 24 Mar 2011 11:46:42 -0500 Benjamin Peterson <benjamin at python.org> wrote: > 2011/3/24 Jesus Cea <jcea at jcea.es>: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > Hi, everybody. > > > > I want to test the dev community interest in modifying the stdlib to > > ease dependence injection. > > I, for one, am -1. Code shouldn't be uglified for the purposes of > testing. It's also a slippery slope. Maybe we should add parameters > for open() and io functions? What about sys and os? Those often need > to be mocked. A non-ugly way of doing "dependency injection" is to rely on class/instance attributes instead. e.g.: class FTP: socket_factory = socket.create_connection def open(self, host, port): self.sock = self.socket_factory(host, port) ... Regards Antoine.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4