-
Notifications
You must be signed in to change notification settings - Fork 126
Make SlapdObject a context manager #198
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #198 +/- ##
==========================================
+ Coverage 70.52% 70.62% +0.09%
==========================================
Files 49 49
Lines 4808 4806 -2
Branches 811 811
==========================================
+ Hits 3391 3394 +3
+ Misses 1082 1078 -4
+ Partials 335 334 -1
Continue to review full report at Codecov.
|
slapdtest is an internal helper for python-ldap tests. I'm worried about adding features that aren't used in the tests. |
I understand. I'm ok with that, yes. FWIW, I find slapdtest extremely convenient and useful to test my application's LDAP interactions. I see a lot of value in it. The module is documented, so its use is encouraged to some degree. Would you like me to add a test? I don't mind adding it and will help make sure the API continues to work. |
The main thing I'm worried about is feature creep: I'm not sure what the scope of slapdtest should be. This particular change is fine; I'll merge it next time I get a block of time for python-ldap. |
I share Petr's opinion. For me, the slapdtest package is an internal test helper for python-ldap. We should document the fact, that slapdtest doesn't have the same API stability as the rest of the package. I see two problems with your PR
|
If you choose to take this direction, I'm OK with that. Here is an example of another project using From @encukou
From @tiran
I'm still happy to write a test if it is desired, but I'm getting a mixed message on whether or not it is desired.
It behaves exactly the same as calling |
Allows for automatic cleanup of resources using the with statement. For example: with slapdtest.SlapdObject() as server: server.ldapadd(...) ... When using SlapdObject in a function, it is more convenient and concise than using try/finally pattern.
I have updated the PR to include:
|
OK. Let's go in that direction. #203
Always better to have a test! It's not absolutely required if we think of sldaptest as only an internal testing tool. |
In code I'd write today, anything that could have I want to merge this. @tiran, do you want to comment? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retract my approval.
The change needs a versionchanged entry in the documentation of slapdtest.
Allows for automatic cleanup of resources using the with statement. For example:
When using
SlapdObject
in a function, it is more convenient and concise than using atry
/finally
pattern.