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

Expose mock directly #335

Merged
merged 6 commits into from
May 28, 2024
Merged

Expose mock directly #335

merged 6 commits into from
May 28, 2024

Conversation

DominicOram
Copy link
Contributor

@DominicOram DominicOram commented May 23, 2024

Fixes #325

This is a little messier than assert_mock_put_called_with for the case where you just care about the value and not the kwargs, but I think that in general it's nicer to supply the Mock as it's a well known object that developers can then just use as they wish.

@DominicOram DominicOram marked this pull request as ready for review May 24, 2024 08:25
Copy link
Contributor

@callumforrester callumforrester left a comment

Choose a reason for hiding this comment

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

Thanks, mostly looks good, just one thing...

def assert_mock_put_called_with(signal: Signal, value: Any, wait=ANY, timeout=ANY):
backend = _get_mock_signal_backend(signal)
backend.put_mock.assert_called_with(value, wait=wait, timeout=timeout)
def get_mock_put(signal: Signal) -> Mock:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: I think this function should have a docstring since it's name is confusing ("put" is a noun here but it looks like a verb because it is almost everywhere else). Alternatively I'm happy with a rename if you can think of something better.

Copy link
Contributor

@evalott100 evalott100 May 24, 2024

Choose a reason for hiding this comment

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

I agree on the docstring point.

I also think the name is confusing (it getting the Mock put of a mock backend rather than the underlying SoftSignal put).

Id say get_backend_put_mock would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like having the word backend exposed to the user as nothing else externally facing in this file mentions backend, they all use mock_put as a phrase so this should match them. Added the docstring though

Copy link
Contributor

@evalott100 evalott100 left a comment

Choose a reason for hiding this comment

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

I agree it's nicer to expose the mock directly, just the one thread from Callum's review above.

Copy link
Contributor

@callumforrester callumforrester left a comment

Choose a reason for hiding this comment

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

Lgtm! Cheers

@DominicOram DominicOram dismissed evalott100’s stale review May 24, 2024 14:45

Dismissing as stale

@abbiemery abbiemery merged commit ee65c72 into main May 28, 2024
18 checks passed
@abbiemery abbiemery deleted the 325_expose_mock_directly branch May 28, 2024 15:48
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.

Write a recommendation for asserting multiple things on a signal
4 participants