Using Mocks inside Doctests?

2.6k views Asked by At

I am using doctests. I am wondering what is the correct way to doctest a function that performs an external action (e.g. sends email, connects to a server, etc)? Using Mock seems like the answer but it will muddy up the doc string of the function.

For example:

class SSHConnection(BaseConnection):
    """Provides basic SSH functions.

    >>> host = '127.0.0.1'
    >>> port = 22
    >>> username = 'user'
    >>> password = 'password'
    >>> ssh = SSHConnection(host, username, password, port)
    >>> ssh.execute('uname -a')
    """
...
0

There are 0 answers