Sanic 如何加载测试应用程序的配置?

Sanic how to load confguration for test app?

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

我有以下夹具:


@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' object has no attribute 'config`

我该如何解决这个问题?

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