-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
added __enter__ and __exit__ methods #4078
Conversation
Adding __enter__ and __exit__ methods to the WebDriver class to create support for the with function in python https://docs.python.org/3/reference/compound_stmts.html#with
Why not add these to the base class, so all sub-classes inherit it? Also, could you add tests? I know this has been proposed before, and although I have no objection to it, I wonder if there's a reason not to add it that I'm unaware of. @AutomatedTester? |
@@ -61,6 +61,15 @@ def __init__(self, executable_path="phantomjs", | |||
raise | |||
|
|||
self._is_remote = False | |||
""" | |||
In order for the python with statement to work __enter__ and __exit__ methods must be deffined in the object. |
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 don't think this comment is needed. if anything, I would just state "enter and exit methods enable using this class as a context manager"
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.
Removed comment.
@davehunt I've added the methods to the Class level. |
Add a test that using |
I dont mind this change. |
@zamai are you still planning on writing tests for this? |
@lmtierney hi, I'm planning to write them this weekend, will let you know here |
@zamai, small nitpicks: |
Hey, @cgoldberg and @lmtierney |
lgtm, but still needs tests |
@zamai This still needs a simple test, please update |
Closed in favor of #5919 |
Adding enter and exit methods to the WebDriver class to create support for the with function in python
https://docs.python.org/3/reference/compound_stmts.html#with
X
in the preceding checkbox, I verify that I have signed the Contributor License Agreement