-
Notifications
You must be signed in to change notification settings - Fork 2
Exception in question #10
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
Exception in question #10
Conversation
… be passed along to the hamcrest based tests as reason for failure.
|
@perrygoy I'm not sure how you want to address versioning. I updated setup.py to require screenpy 4.0.2 with the assumption that is the next version and that PR ScreenPyHQ/screenpy#22 will be merged. |
I think that will make sense, as nothing will be affected until after we release. We'll probably just need to make sure that |
perrygoy
left a 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.
Looks good to me!
I had one small comment about the caught_exception typing, which probably will get cleared up with the comment i made on the other PR.
…rm to protocols
…e *right* one this time)
perrygoy
left a 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 have one very small action item for you, if you choose to do it (i will need to re-review). If you don't want to, i can sneak in the describe methods when i bump the version before deploying.
|
|
||
| for action in self.actions: | ||
| if "add_to_chain" not in dir(action): | ||
| if not isinstance(action, Chainable): |
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.
So much more readable.
| the_actor.should(See.the(Element(WELCOME_BANNER), IsVisible())) | ||
| """ | ||
|
|
||
| caught_exception: Optional[TargetingError] |
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.
We were talking about this on Discord, and i do really like how we can be extremely explicit here about what kind of exceptions we're expecting to handle in the actual Questions.
| def test_implements_protocol(self): | ||
| r = SaveConsoleLog("") | ||
| assert isinstance(r, Performable) |
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.
If you don't mind, can you add the describe method to SaveConsoleLog and SaveScreenshot? I forgot to add those methods when i added the Actions.
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.
Added
perrygoy
left a 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 appreciate all the extra testing, and the reinforcement of the existing tests as well! Thanks for doing this, @bandophahita.
Like the other PR, i had a few small things that i think we should address before merging. I promise to re-review faster this time!
| show_error_codes = True | ||
| exclude = (?x)( | ||
| setup\.py | ||
| ; | tests/ | ||
| | docs/ | ||
| ) | ||
|
|
||
| [mypy-screenpy.*] | ||
| disallow_untyped_defs = True | ||
|
|
||
| [mypy-tests.*] | ||
| ignore_missing_imports = True |
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.
What do these changes do, and why are they necessary? Also, do we need that commented line 5?
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.
In most cases these settings do nothing for contributers since the pre-commit calls pylint and flake8 to inspect the code. It's really only useful for anyone that want to only run mypy manually on their end for the entire project. Handy, but not actually required by the codebase. I just found I was constantly adding them when I went to inspect the code manually locally.
Here is what the settings do:
show_error_code: includes the actual error code when running mypy rather than only the message. I dunno why mypy doesn't do this by default.exclude: ignores thesetup.pyand thedocsfolder when running mypy manually against the entire project.- I initially ignored the tests folder then later commented it out. I can remove the comment.
ignore_missing_imports: ignores packages that don't have a typeshed to refer to.
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.
Forgot to mention moving disallow_untyped_defs down into [mypy-screenpy.*]. This enforces the mypy rule specifically where it should be, which is in the screenpy directory rather than the entire project. This felt consistent with flake8 and pylint ignoring the tests also.
| def describe(self) -> str: | ||
| """Describe the Action in present tense.""" | ||
| return f"Save browser console log as {self.filename}" |
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.
Thanks again for catching and fixing these!
tests/test_actions.py
Outdated
| from selenium.common.exceptions import WebDriverException | ||
| from selenium.webdriver.common.action_chains import ActionChains | ||
| from selenium.webdriver.common.keys import Keys | ||
| from selenium.webdriver.remote.webelement import WebElement | ||
| from selenium.webdriver.support import expected_conditions as EC |
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.
if we're organizing these by the system -> framework -> module -> local ordering, the Selenium imports should go up by the base screenpy imports.
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.
That raises the question of should the pre-commit hooks handle that for us? isort would likely do this for us but pre-commit doesn't touch the tests.
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.
Yes, isort does. It's been a while coming, i've been meaning to split out the configs for each of our precommit things.
tests/test_actions.py
Outdated
| target = mock.create_autospec(Target, instance=True) | ||
| element = mock.create_autospec(WebElement, instance=True) |
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.
Very nice. :D
| class Describable(Protocol): | ||
| def describe(self) -> str: | ||
| ... |
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.
We won't have access to this Protocol here in screenpy_selenium until the newer version of ScreenPy is released. Should we add a comment here to remind ourselves to remove this one once we have the other available?
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.
That's a good question. I don't know what the right answer is here. But, probably?
tests/test_resolutions.py
Outdated
| @mock.patch("selenium.webdriver.remote.webelement.WebElement", spec=WebElement) | ||
| def test_matches_a_clickable_element(self, element): | ||
| def test_matches_a_clickable_element(self): | ||
| element = mock.create_autospec(WebElement, instance=True) |
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.
Should we have a get_mock_element function for this?
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.
We could. I didn't see it reducing the number of lines of code, but I don't think it would hurt anything.
perrygoy
left a 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.
Thanks again for all this! :D
Addresses #9
Requires ScreenPyHQ/screenpy#22