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

converted tests to use pytest-mock #62

Merged
merged 2 commits into from
Nov 26, 2018
Merged

converted tests to use pytest-mock #62

merged 2 commits into from
Nov 26, 2018

Conversation

heartsucker
Copy link
Contributor

fixes #42

pytest-mock is nice because of some of the guarantees of clean up between functions. It also has some helpers for use in loops. This also removes the constant use of with blocks (which I think makes code more readable because with a 79 char limit, I want as much real estate as possible for code).

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

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

💯

ms.api.download_reply = mocker.MagicMock(return_value=(1234, "/home/user/downloads/foo"))

# check that it runs without raising exceptions
ms.run(False)
Copy link
Contributor

Choose a reason for hiding this comment

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

right now these gpg tests are only checking that no exceptions occur, but we really should be asserting that e.g. the mock of securedrop_client.message_sync.storage.mark_file_as_downloaded was called once with the expected args (not blocking this PR on that, just a flag for when you pick up the gpg wrapper ticket which I know you're working on next)

@redshiftzero redshiftzero merged commit b13ee7c into master Nov 26, 2018
@redshiftzero redshiftzero deleted the pytest-mock branch November 26, 2018 20:22
legoktm pushed a commit that referenced this pull request Dec 11, 2023
build-requirements: update for production beta
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.

consider using pytest-mock
2 participants