用法:
test.support.check__all__(test_case, module, name_of_module=None, extra=(), not_exported=())
斷言
module
的__all__
變量包含所有公共名稱。模塊的公共名稱(其 API)會根據它們是否符合公共名稱約定並在
module
中定義來自動檢測。name_of_module
參數可以指定(作為字符串或其元組)API 可以定義哪些模塊以便被檢測為公共 API。一種情況是module
從其他模塊導入其部分公共 API,可能是 C 後端(如csv
及其_csv
)。extra
參數可以是一組名稱,否則這些名稱不會被自動檢測為 “public”,例如沒有正確__module__
屬性的對象。如果提供,它將被添加到自動檢測到的中。not_exported
參數可以是一組名稱,即使它們的名稱另有說明,也不能將其視為公共 API 的一部分。示例使用:
import bar import foo import unittest from test import support class MiscTestCase(unittest.TestCase): def test__all__(self): support.check__all__(self, foo) class OtherTestCase(unittest.TestCase): def test__all__(self): extra = {'BAR_CONST', 'FOO_CONST'} not_exported = {'baz'} # Undocumented name. # bar imports part of its API from _bar. support.check__all__(self, bar, ('bar', '_bar'), extra=extra, not_exported=not_exported)
3.6 版中的新函數。
相關用法
- Python test.support.check_impl_detail用法及代碼示例
- Python test.support.catch_unraisable_exception用法及代碼示例
- Python test.support.captured_stdin用法及代碼示例
- Python test.support.load_package_tests用法及代碼示例
- Python test.support.import_helper.import_fresh_module用法及代碼示例
- Python test.support.threading_helper.catch_threading_exception用法及代碼示例
- Python test.support.warnings_helper.check_warnings用法及代碼示例
- Python numpy testing.decorators.slow用法及代碼示例
- Python numpy testing.decorators.setastest用法及代碼示例
- Python tesnsorflow.grad_pass_through()用法及代碼示例
- Python textwrap.indent用法及代碼示例
- Python tensorflow.eye()用法及代碼示例
- Python tensorflow.fill()用法及代碼示例
- Python tensorflow.math.special.dawsn()用法及代碼示例
- Python tensorflow.ensure_shape()用法及代碼示例
- Python tensorflow.math.special.fresnel_cos()用法及代碼示例
- Python tensorflow.raw_ops.Cos()用法及代碼示例
- Python tensorflow.get_logger()用法及代碼示例
- Python tensorflow.math.sqrt()用法及代碼示例
- Python tensorflow.math.atanh()用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 test.support.check__all__。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。