1

我希望我的测试服务器有一个虚拟配置变量

我有以下夹具:


@pytest.fixture
def server():
    app.config.thing =1 #the dummy var
    return app.test_client

和一个测试

def test_thing(server):

    assert server.config.thing == 1

我收到以下错误:

AttributeError:“SanicTestClient”对象没有属性“config”

我该如何解决?

4

1 回答 1

1

SanicTestClient是应用程序的包装器 - 它不是应用程序本身。所以简单地做assert server.app.config.thing == 1

于 2019-08-26T16:37:15.647 回答