[Python-Dev] dependency injection for testing [was Python 3.3 release schedule posted]
Michael Foord
fuzzyman at voidspace.org.uk
Thu Mar 24 03:16:26 CET 2011
On 24/03/2011 02:06, Jesus Cea wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 23/03/11 20:56, Georg Brandl wrote:
>> For 3.3, I'd like to revive the tradition of listing planned large-scale
>> changes in the PEP.
> I want to integrate dependence injection in the stdlib, specially in
> libs creating sockets. This would be an optional feature.
>
> The idea would be, for instance, that smtplib could call an optional
> constructor to create a socket-like object, if some is provided.
>
> That would break the implicit dependency with sockets, reduce
> monkey-patching need, and ease testing the libs.
>
In general I dislike dependency injection if it's only done for
testability. With monkey patching (if done right) you can safely test
Python code without messing with your public interfaces just to make
code testable.
A clean solution that does monkey patching correctly for us, for use
within our own tests would be a better solution in my opinion.
All the best,
Michael Foord
> I proposed this on the list like a year ago. Somebody else said he was
> planning a PEP... not done yet, I guess.
>
> Digging the archive:
> <http://mail.python.org/pipermail/python-dev/2010-April/099237.html>
>
> - --
> Jesus Cea Avion _/_/ _/_/_/ _/_/_/
> jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/
> jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/
> . _/_/ _/_/ _/_/ _/_/ _/_/
> "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
> "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
> "El amor es poner tu felicidad en la felicidad de otro" - Leibniz
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQCVAwUBTYqnDplgi5GaxT1NAQJTxQP/U9dk4x9r9Fbwm7zEzEMydzxqqiY/FF6z
> PA52YDRPUgyeiDnhmZwk1f9PqnwYWkgf2qmDi+v0eXLZJYqs/rBEcaY36yP1sgP+
> +RrFp4aTpf6oqp7HSwrJMoOS2BmRZxLmzShfKecX+3q33Ix1C1EvcF8F8Yg4P4s6
> Pd+jRaGvJRs=
> =Ec5o
> -----END PGP SIGNATURE-----
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
More information about the Python-Dev
mailing list