小编m3t*_*3ta的帖子

在Doctests中使用Mocks?

我正在使用doctests。我想知道对外部执行功能(例如发送电子邮件,连接到服务器等)进行功能测试的正确方法是什么?使用Mock似乎是答案,但它会使函数的文档字符串变得混乱。

例如:

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')
    """
...
Run Code Online (Sandbox Code Playgroud)

python testing doctest mocking python-3.5

6
推荐指数
0
解决办法
535
查看次数

标签 统计

doctest ×1

mocking ×1

python ×1

python-3.5 ×1

testing ×1