Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonkeyPatcher should (optionally) raise AttributeError if the target attribute is undefined #237

Open
wallrj opened this issue Jul 5, 2016 · 1 comment

Comments

@wallrj
Copy link

wallrj commented Jul 5, 2016

In Twisted's version, you get AttributeError if you attempt to patch a non-existent attribute.
I like that because tests blow up if I mistype the attribute name or if someone else changes the attribute name:

That's one of the reasons I use patch in Flocker, even on non-global objects.

The testtools version silently ignores these errors:

Does anyone agree that "check attribute exists" should at least be an option?

@jml
Copy link
Member

jml commented Jul 9, 2016

Either an option or a default on a differently named object (e.g.
SafeMonkeyPatcher). Can't change default on current version as that will
break existing code.

On Tue, 5 Jul 2016 at 11:44, Richard Wall notifications@github.com wrote:

In Twisted's version, you get AttributeError if you attempt to patch a
non-existent attribute.
I like that because tests blow up if I mistype the attribute name or if
someone else changes the attribute name:

https://github.com/twisted/twisted/blob/twisted-16.2.0/twisted/python/monkey.py

That's one of the reasons I use patch in Flocker, even on non-global
objects.

The testtools version silently ignores these errors:

https://github.com/testing-cabal/testtools/blob/master/testtools/monkey.py

Does anyone agree that "check attribute exists" should at least be an
option?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#237, or mute the
thread
https://github.com/notifications/unsubscribe/AAHq6rialg0kZ8qZ6xR8NyPvxKj2ShYgks5qSjWEgaJpZM4JE_hK
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants