On Thu, 24 Mar 2011 11:46:42 -0500 Benjamin Peterson <benja...@python.org> wrote:
> 2011/3/24 Jesus Cea <j...@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. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com