Tests¶
- trytond.tests.test_tryton.DB_NAME¶
The name of the database to use for testing. Its value is taken from the environment variable of the same name.
- trytond.tests.test_tryton.USER¶
The user id used to test the transactions
- trytond.tests.test_tryton.CONTEXT¶
The context used to test the transactions
- trytond.tests.test_tryton.activate_module(name)¶
Activate the named module for the tested database.
In case database does not exist and the
DB_CACHEenvironment variable is set then Tryton restores a backup found in the directory pointed byDB_CACHE. Otherwise it procees to the creation of the database and the activation of the module.
ModuleTestCase¶
- class trytond.tests.test_tryton.ModuleTestCase¶
A subclass of unittest.TestCase that tests a Tryton module. Some tests are included to ensure that the module works properly.
It creates a temporary database with the module activated in setUpClass and drops it in the tearDownClass method.
- ModuleTestCase.module¶
Name of the tested module.
Helpers¶
- trytond.tests.test_tryton.with_transaction(user=1, context=None)¶
Return a decorator to run a test case inside a
Transaction. It is rolled back and the cache cleared at the end of the test.
doctest helpers¶
- trytond.tests.test_tryton.doctest_setup()¶
Prepare the run of the doctest by creating a database and dropping it beforehand if necessary. This function should be used as the
setUpparameter.Deprecated since version 4.2: The
doctest_setupfunction should not be used anymore to set upDocFileSuite(). New modules should useactivate_modules()instead.
- trytond.tests.test_tryton.doctest_teardown()¶
Clean up after the run of the doctest by dropping the database. It should be used as
tearDownparameter when creating aDocFileSuite.
- trytond.tests.test_tryton.doctest_checker¶
A specialized doctest checker to ensure the Python compatibility.
- trytond.tests.test_tryton.load_doc_tests(name, path, loader, tests, pattern)¶
An helper that follows the
load_testsprotocol to load asDocTestall*.rstfiles indirectory, with the modulenameand thepathto the module file from which the doc tests are registered.
- trytond.tests.test_tryton.suite()¶
A function returning a subclass of
unittest.TestSuitethat drops the database if it does not exist prior to the run of the tests.
Tools¶
- trytond.tests.tools.activate_modules(modules)¶
Activate a list of
modulesfor scenario based on proteus doctests.
- trytond.tests.tools.set_user(user, config)¶
Set the user of the
configproteus connection touser.