jeudi 22 décembre 2016

Using Mocks inside Doctests?

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')
    """
...

Aucun commentaire:

Enregistrer un commentaire