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

Add a context manager for verification #28

Open
ivancrneto opened this issue Jan 6, 2024 · 0 comments
Open

Add a context manager for verification #28

ivancrneto opened this issue Jan 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ivancrneto
Copy link
Owner

Idea for a verification context manager:

class Verification(object):
    def __init__(self, m):
        self.m = m

    def __enter__(self):
        self.m.ReplayAll()

    def __exit__(self, exc_type, exc_value, traceback):
        if exc_type is None and exc_value is None and traceback is None:
            self.m.VerifyAll()
``

This would allow one to say:
def test_foo(self):
    with self.mox.Verification():
        # …

This nicely delineates the code under test from the setup code.

@ivancrneto ivancrneto added the enhancement New feature or request label Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant