小编Asm*_*oox的帖子

Sphinx 不会为标题生成侧边栏目录

我正在努力处理 Sphinx 生成的文档中的侧边栏目录。

我只想在我的文档左侧有一种自动生成的索引树。相反,我只看到空白标题: 在此处输入图片说明 (我希望你不介意目标文档是波兰语)

我的 index.rst 文件:

.. SIMail documentation master file, created by
   sphinx-quickstart on Mon Nov 26 12:38:31 2018.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to SIMail docs!
=======================

.. toctree::
   :numbered:

Providers
==============

.. automodule:: Providers
   :members:

Connection managers
===================

.. automodule:: ConnectionManagers
   :members:


Indices and tables
******************

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Run Code Online (Sandbox Code Playgroud)

我的 conf.py 文件:

# -*- coding: utf-8 -*- …
Run Code Online (Sandbox Code Playgroud)

python sidebar tableofcontents python-sphinx toctree

9
推荐指数
1
解决办法
4900
查看次数

mock.patch() 作为装饰器和上下文管理器之间的区别

我有一个模拟问题,当使用装饰器时我无法解决几个小时@mock.patch,但当尝试使用上下文管理器时立即解决。我想做的是问它在幕后工作方式是否还有更多差异?说得更多,我的意思不仅仅是设置模拟上下文。

我的示例是关于模拟 aiohttp 服务器的数据库连接。测试如下:

后端/测试/test_server.py

# source: https://docs.aiohttp.org/en/stable/testing.html#unittest

from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop
from alchemy_mock.mocking import AlchemyMagicMock
from backend.app import create_app
from datetime import datetime
from unittest import mock

import aiohttp
import asyncio
import json


class MyAppTestCase(AioHTTPTestCase):
    """
    Class for testing aiohttp server

    Methods
    -------
    ...
    test_get_version()
        Test response for GET /version
    """

    @mock.patch('backend.app.SessionProvider')
    async def get_application(self, mock_sess_prov):
        mock_sess_prov.session = AlchemyMagicMock()
        mock_sess_prov.start_session = lambda: None
        return create_app()

...


    @unittest_run_loop
    async def test_get_version(self):
        """Test response for GET …
Run Code Online (Sandbox Code Playgroud)

python unit-testing mocking aiohttp

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

错误膨胀类 android.support.design.bottomappbar.BottomAppBar

我正在尝试从 material.io 测试 BottomAppBar 功能。但是,当我尝试运行应用程序时,我会立即崩溃:

> 10-20 22:21:25.067 27571-27571/com.example.asmox.bcl E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.asmox.bcl, PID: 27571
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.asmox.bcl/com.example.asmox.bcl.ViewActivity}: android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class android.support.design.bottomappbar.BottomAppBar
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class android.support.design.bottomappbar.BottomAppBar
        at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) …
Run Code Online (Sandbox Code Playgroud)

android android-bottomappbar

4
推荐指数
2
解决办法
3946
查看次数