tests — Core test infrastructure#
Core infrastructure for the Pywikibot test suite.
This module defines the main groups of test modules and implements the unittest load tests protocol. It controls the order in which test modules are loaded and provides the entry point used by the test runner.
It also provides helpers for locating test data paths and for controlling API request caching during tests.
The test modules are grouped into library tests, which cover Pywikibot
library components, and script tests, which cover Pywikibot scripts. The
corresponding module collections are available as
library_test_modules and script_test_modules.
Shared test infrastructure such as test case classes and reusable test
components is implemented in tests.aspects, tests.basepage,
and tests.utils.
For information about running tests, writing new tests, and available test options, see Pywikibot tests.
- class tests.TestRequest(*args, **kwargs)[source]#
Bases:
CachedRequestAdd caching to every Request except logins.
- tests.collector(loader=<unittest.loader.TestLoader object>)[source]#
Load the default modules.
This is the entry point is specified in setup.py
- tests.create_path_func(base_func, subpath)[source]#
Return a function returning a path relative to the given directory.
- tests.join_cache_path(*names)#
Return a path relative to
root/tests/apicache/.
- tests.join_data_path(*names)#
Return a path relative to
root/tests/data/.
- tests.join_html_data_path(*names)#
Return a path relative to
root/tests/data/html/.
- tests.join_images_path(*names)#
Return a path relative to
root/tests/data/images/.
- tests.join_pages_path(*names)#
Return a path relative to
root/tests/pages/.
- tests.join_xml_data_path(*names)#
Return a path relative to
root/tests/data/xml/.
- tests.library_test_modules = {'api', 'basesite', 'bot', 'category', 'collections', 'config', 'cosmetic_changes', 'datasite', 'date', 'diff', 'djvu', 'dry_api', 'dry_site', 'echo', 'edit', 'edit_failure', 'editor', 'eventstreams', 'exceptions', 'family', 'file', 'fixes', 'flaggedrevs', 'gui', 'http', 'i18n', 'interwiki_graph', 'interwiki_link', 'interwikimap', 'link', 'linter', 'logentries', 'login', 'mediawikiversion', 'memento', 'mysql', 'namespace', 'oauth', 'page', 'pagegenerators', 'paraminfo', 'plural', 'proofreadpage', 'setup', 'site', 'site_decorators', 'site_detect', 'site_generators', 'site_login_logout', 'site_obsoletesites', 'siteinfo', 'sparql', 'superset', 'tests', 'textlib', 'thanks', 'throttle', 'time', 'timestripper', 'titletranslate', 'token', 'tools', 'tools_chars', 'tools_deprecate', 'tools_formatter', 'tools_threading', 'ui', 'ui_options', 'unlinkbot', 'upload', 'uploadbot', 'user', 'version', 'wbtypes', 'wikibase', 'wikibase_edit', 'wikiblame', 'wikistats', 'wikiwho', 'xmlreader'}#
Names of test modules covering Pywikibot framework components. The corresponding test files end with
_tests.py.
- tests.load_tests(loader=<unittest.loader.TestLoader object>, tests=None, pattern=None)[source]#
Load the default modules.
- tests.script_test_modules = {'add_text', 'archivebot', 'cache', 'category_bot', 'checkimages', 'commonscat', 'data_ingestion', 'deletionbot', 'download_dump', 'fixing_redirects', 'generate_family_file', 'generate_user_files', 'harvest_template', 'interwikibot', 'interwikidata', 'make_dist', 'noreferences', 'patrolbot', 'protectbot', 'pwb', 'redirect_bot', 'reflinks', 'replacebot', 'revertbot', 'script', 'speedy_delete', 'template_bot', 'uploadscript', 'weblinkchecker', 'welcome'}#
Names of test modules covering Pywikibot scripts. The corresponding test files end with
_tests.py.