如何使用 docstring 作为 Python unittest 描述?

How to use docstring as Python unittest description?

我正在使用 Python 3.4.3。 test_*** 方法中的所有文档字符串都将被忽略。

class MovieQueriesTest(ApiBaseTest):
    """Tests for query operations against movies endpoint"""

    def test_query_empty_result(self):
        """
        Query which yields empty results must be well-formed
        """
        response = self.client.get('/api/movies')
        self.assert200(response, 'Empty movie response should have status 200')

未收集文档字符串 Tests for query operations against movies endpoint,但收集了测试方法名称 test_query_empty_result

这就是 Pycharm 的 Monitoring and Managing Tests 功能的实现方式。恐怕您无法将其配置为显示文档字符串而不是测试名称。