Skip to content

Conversation

@MarcelWilson
Copy link
Contributor

Addresses #9
Requires ScreenPyHQ/screenpy#22

… be passed along to the hamcrest based tests as reason for failure.
@MarcelWilson
Copy link
Contributor Author

@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.

@perrygoy
Copy link
Member

perrygoy commented Jul 5, 2022

@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 screenpy v4.0.2 gets released first, or at least very soon after.

perrygoy
perrygoy previously approved these changes Jul 5, 2022
Copy link
Member

@perrygoy perrygoy left a 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.

perrygoy
perrygoy previously approved these changes Jul 17, 2022
Copy link
Member

@perrygoy perrygoy left a 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):
Copy link
Member

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]
Copy link
Member

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.

Comment on lines +711 to +713
def test_implements_protocol(self):
r = SaveConsoleLog("")
assert isinstance(r, Performable)
Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@bandophahita bandophahita requested a review from perrygoy July 21, 2022 21:23
Copy link
Member

@perrygoy perrygoy left a 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!

Comment on lines 2 to 13
show_error_codes = True
exclude = (?x)(
setup\.py
; | tests/
| docs/
)

[mypy-screenpy.*]
disallow_untyped_defs = True

[mypy-tests.*]
ignore_missing_imports = True
Copy link
Member

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?

Copy link
Contributor

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 the setup.py and the docs folder 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.

Copy link
Contributor

@bandophahita bandophahita Aug 4, 2022

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.

Comment on lines +47 to +49
def describe(self) -> str:
"""Describe the Action in present tense."""
return f"Save browser console log as {self.filename}"
Copy link
Member

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!

Comment on lines 41 to 45
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
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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.

Comment on lines 51 to 52
target = mock.create_autospec(Target, instance=True)
element = mock.create_autospec(WebElement, instance=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. :D

Comment on lines +5 to +7
class Describable(Protocol):
def describe(self) -> str:
...
Copy link
Member

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?

Copy link
Contributor

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?

@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)
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member

@perrygoy perrygoy left a 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

@bandophahita bandophahita merged commit 73a9c7f into ScreenPyHQ:trunk Aug 9, 2022
@MarcelWilson MarcelWilson deleted the exception_in_question branch September 15, 2022 14:19
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

Successfully merging this pull request may close these issues.

3 participants