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

Is it possible to only mock one command and run the rest with MockContext? #990

Open
red8888 opened this issue Mar 18, 2024 · 0 comments
Open

Comments

@red8888
Copy link

red8888 commented Mar 18, 2024

I have some integration tests where I do want to run some commands, but mock out the others.

Obviously I can just factor the code in a way that would let me monkey patch some functions but I'm curious if MockContext has supports this ootb.

For example, I can't do something like this can I? Or can I extend MockContext with this functionality somehow?

ctx = MockContext(
    run={
        "my cmd 1": Result(stdout="mock output"),
        "my cmd 3": Result(stdout="mock output"),
    },
    # Run the cmd for real in this block
    actually_run={
        "my cmd 2": Result(stdout="mock output"),
    }
)
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

1 participant