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

and_assert_not_called shouldn't need any behaviour defined beforehand #315

Open
Piojo opened this issue Aug 24, 2021 · 2 comments
Open

and_assert_not_called shouldn't need any behaviour defined beforehand #315

Piojo opened this issue Aug 24, 2021 · 2 comments
Assignees

Comments

@Piojo
Copy link

Piojo commented Aug 24, 2021

I'm using TestSlide version: 2.6.3

Given:

self.mock_callable(foo, 'bar').and_assert_not_called()

should work. I currently need:

self.mock_callable(foo, 'bar').to_return_value(None).and_assert_not_called()

but since I don't want it called I don't want any return value defined!!

I know I could simply leave the callable unmocked and let StrictMock fail in such an event, but the error message is confusing - I really want it to notify that there is an unwanted call, instead of something I forgot to mock away.

@deathowl
Copy link
Member

Will do this soon, thanks for the report @Piojo :)

@deathowl deathowl self-assigned this Sep 27, 2021
@fornellas
Copy link
Contributor

@Piojo I believe all 3 cases should raise an exception if a call is made:

self.mock_callable(foo, 'bar')
self.mock_callable(foo, 'bar').and_assert_not_called()
self.mock_callable(foo, 'bar').to_return_value(None).and_assert_not_called()

sot "they work equally". Though:

  • The exception from self.mock_callable(foo, 'bar') sohuld be generic such as "no behaviour defined for this call".
  • And for the others, the exception should be "unexpected call received".
    So... "kinda" the same, though not really :-P

No harm in adding self.mock_callable(foo, 'bar').and_assert_not_called() shortcut though :-D

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

No branches or pull requests

3 participants