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

Returning exceptions #23

Open
michaelsteigman opened this issue Mar 4, 2021 · 2 comments
Open

Returning exceptions #23

michaelsteigman opened this issue Mar 4, 2021 · 2 comments

Comments

@michaelsteigman
Copy link

michaelsteigman commented Mar 4, 2021

Has consideration been given to allowing tests to pass in an exception to return? E.g.

self.mock_ldap.set_return_value( "simple_bind_s", ("cn=admin,dc=mgb,dc=org", "ldaptest"), ldap.SERVER_DOWN )

@timabbott
Copy link
Sponsor Member

I haven't thought about this (though maybe the original maintainer did -- we have mostly done bug fixes and Python version support updates since adopting the project). I would try to follow the patterns of the Python mock library for this sort of thing; and so I wouldn't conflate a return value (returning an exception object) with raising an exception in the syntax. See https://docs.python.org/3/library/unittest.mock.html ; I think we probably would want to call this side_effect.

Patches that come with tests are welcome!

@michaelsteigman
Copy link
Author

michaelsteigman commented Mar 5, 2021 via email

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