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 argument to multiple_times #35

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

Add argument to multiple_times #35

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

Comments

@ivancrneto
Copy link
Owner

class TestOs:
    def test_getcwd(self):
        with stubout(os, "getcwd") as m_getcwd:
            m_getcwd().returns("/mox/path")
            # the second call will return a different value
            m_getcwd().returns("/mox/another/path")
            # the three subsequent calls will return "/"
            # if no argument is passed, multiple_times doesn't limit the number of calls
            m_getcwd().multiple_times(3).returns("/")

        assert os.getcwd() == "/mox/path"
        assert os.getcwd() == "/mox/another/path"
        os.getcwd()
        mox.verify(m_getcwd)

multipe_times need to be able to receive an argument (in the example above: 3), so we expect only three calls. The test above should fail unless we add two new calls to os.getcwd()

@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