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

Ensure the user chain the tool in a proper order #13

Open
zhukovgreen opened this issue Jun 5, 2023 · 1 comment
Open

Ensure the user chain the tool in a proper order #13

zhukovgreen opened this issue Jun 5, 2023 · 1 comment

Comments

@zhukovgreen
Copy link
Owner

zhukovgreen commented Jun 5, 2023

Currently nothing forbids to do when(...).then_return, but
it is expected only when.called_with.then_return

An exception should be raised in inproper order of the methods

@absalukaskosina
Copy link

I was thinking about that when I was testing how to do no args.

What do you think that instead of raising exception, using when would return object that simply does not have .then_return function?

I know it would take some code refactoring, but it might be easier for users to understand, which methods should be used in each step.

Something like:

class Z:
      ....

class Y:
    def then_return(signature) -> Z: 
      ....

class X: 
   def called_with(signature) -> Y:
      ...

def when(signature) -> X:
   .....

So when you call when(...) IDE would simply not whisper you to use then_return, because X does not have it there.

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

2 participants