b.tests : package documentation

Part of bzrlib

Testing framework extensions
Module EncodingAdapter Adapter for running test cases against multiple encodings.
Module TestUtil No module docstring; 5/6 classes, 3/3 functions documented
Package blackbox Black-box tests for bzr.
Package commands Commands behaviour tests for bzr.
Package doc_generate Documentation generation tests.
Module fake_command Undocumented
Module features A collection of commonly used 'Features' to optionally run tests.
Module file_utils No module docstring; 1/1 classes documented
Module fixtures Fixtures that can be used within tests.
Package ftp_server Facilities to use ftp test servers.
Module http_server No module docstring; 5/8 classes documented
Module http_utils No module docstring; 22/22 classes documented
Module https_server HTTPS test server, available when ssl python module is available
Module lock_helpers Helper functions/classes for testing locking
Module matchers Matchers for bzrlib.
Package per_branch Branch implementation tests for bzr.
Package per_bzrdir BzrDir implementation tests for bzr.
Package per_controldir ControlDir implementation tests for bzr.
Package per_controldir_colo BzrDir implementation tests for colocated branch support.
Package per_foreign_vcs Tests specific to foreign branch implementations.
Package per_interbranch InterBranch implementation tests for bzr.
Package per_interrepository InterRepository implementation tests for bzr.
Package per_intertree InterTree implementation tests for bzr.
Package per_inventory Tests for different inventory implementations
Package per_lock OS Lock implementation tests for bzr.
Module per_merger Implementation tests for bzrlib.merge.Merger.
Module per_pack_repository Tests for pack repositories.
Package per_repository Repository implementation tests for bzr.
Package per_repository_chk Repository implementation tests for CHK support.
Package per_repository_reference Repository implementation tests for external reference repositories.
Package per_repository_vf Implementation tests for VersionedFile-based repositories.
Module per_transport Tests for Transport implementations.
Package per_tree Tree implementation tests for bzr.
Package per_uifactory Tests run per UIFactory.
Module per_versionedfile No module docstring; 4/12 classes, 2/2 functions documented
Package per_workingtree WorkingTree implementation tests for bzr.
Module scenarios Generate multiple variations in different scenarios.
Module script Shell-like test scripts.
Package ssl_certs ssl_certs -- provides access to ssl keys and certificates needed by tests
Module stub_sftp A stub SFTP server for loopback SFTP testing.
Module test__annotator Tests for Annotators.
Module test__bencode Tests for bencode structured encoding
Module test__btree_serializer Direct tests of the btree serializer extension
Module test__chk_map Tests for _chk_map_*.
Module test__chunks_to_lines Tests for chunks_to_lines.
Module test__dirstate_helpers Tests for the compiled dirstate helpers.
Module test__groupcompress Tests for the python and pyrex extensions of groupcompress
Module test__known_graph Tests for the python and pyrex extensions of KnownGraph
Module test__rio Tests for _rio_*.
Module test__simple_set Tests for the StaticTupleInterned type.
Module test__static_tuple Tests for the StaticTuple type.
Module test__walkdirs_win32 Tests for the win32 walkdir extension.
Module test_ancestry Undocumented
Module test_annotate Whitebox tests for annotate functionality.
Module test_api Tests for library API infrastructure
Module test_atomicfile Basic tests for AtomicFile
Module test_bad_files Tests being able to ignore bad filetypes.
Module test_bisect_multi Tests for bisect_multi.
Module test_branch Tests for the Branch facility that are not interface tests.
Module test_branchbuilder Tests for the BranchBuilder class.
Module test_btree_index Tests for btree indices.
Module test_bugtracker No module docstring; 5/6 classes documented
Module test_bundle No module docstring; 2/15 classes, 2/2 functions documented
Module test_bzrdir Tests for the BzrDir facility and any format specific tests.
Module test_cache_utf8 Tests for utf8 caching.
Module test_cethread Undocumented
Module test_chk_map Tests for maps built on a CHK versionedfiles facility.
Module test_chk_serializer No module docstring; 1/1 classes documented
Module test_chunk_writer Tests for writing fixed size chunks with compression.
Module test_clean_tree Undocumented
Module test_cleanup Undocumented
Module test_cmdline Undocumented
Module test_commands No module docstring; 1/10 classes documented
Module test_commit No module docstring; 1/4 classes documented
Module test_commit_merge No module docstring; 1/1 classes documented
Module test_config Tests for finding and reading the bzr config file[s].
Module test_conflicts No module docstring; 2/18 classes, 1/2 functions documented
Module test_controldir Tests for the ControlDir facility.
Module test_counted_lock Tests for bzrlib.counted_lock
Module test_crash No module docstring; 1/2 classes documented
Module test_debug Tests for bzrlib.debug
Module test_decorators Tests for decorator functions
Module test_delta No module docstring; 1/4 classes documented
Module test_diff No module docstring; 1/14 classes, 0/3 functions documented
Module test_directory_service Test directory service implementation
Module test_dirstate Tests of the dirstate functionality being built for WorkingTreeFormat4.
Module test_email_message Undocumented
Module test_eol_filters Tests for eol conversion.
Module test_errors Tests for the formatting and construction of errors.
Module test_estimate_compressed_size Tests for our estimation of compressed content.
Module test_export Tests for bzrlib.export.
Module test_export_pot Undocumented
Module test_extract Undocumented
Module test_features Tests for test feature dependencies.
Module test_fetch No module docstring; 1/5 classes, 1/3 functions documented
Module test_fifo_cache Tests for the fifo_cache module.
Module test_filter_tree Tests for ContentFilterTree
Module test_filters Undocumented
Module test_fixtures Tests for test fixtures
Module test_foreign Tests for foreign VCS utility code.
Module test_ftp_transport No module docstring; 1/5 classes documented
Module test_generate_docs Tests for generating docs (man pages).
Module test_generate_ids Tests for bzrlib/generate_ids.py
Module test_globbing Undocumented
Module test_gpg Tests for signing and verifying blobs of data via gpg.
Module test_graph No module docstring; 4/20 classes documented
Module test_groupcompress Tests for group compression.
Module test_hashcache No module docstring; 3/3 classes, 0/1 functions documented
Module test_help Unit tests for the bzrlib.help module.
Module test_hooks Tests for the core Hooks logic.
Module test_http Tests for HTTP implementations.
Module test_http_response Tests from HTTP response parsing.
Module test_https_ca_bundle Testing of bzrlib.transport.http.ca_bundle module
Module test_i18n Tests for bzrlib.i18n
Module test_identitymap Tests for the IdentityMap class.
Module test_ignores Tests for handling of ignore files
Module test_import_tariff Tests for how many modules are loaded in executing various commands.
Module test_index Tests for indices.
Module test_info Undocumented
Module test_inv No module docstring; 0/7 classes, 5/9 functions documented
Module test_inventory_delta Tests for bzrlib.inventory_delta.
Module test_knit Tests for Knit data structure
Module test_lazy_import Test the lazy_import functionality.
Module test_lazy_regex Test that lazy regexes are not compiled right away
Module test_library_state Tests for BzrLibraryState.
Module test_lock Tests for OS Locks.
Module test_lockable_files No module docstring; 2/4 classes documented
Module test_lockdir Tests for LockDir
Module test_log No module docstring; 2/20 classes documented
Module test_lru_cache Tests for the lru_cache module.
Module test_lsprof Tests for profiling data collection.
Module test_mail_client Undocumented
Module test_matchers Tests of bzrlib test matchers.
Module test_memorytree Tests for the MemoryTree class.
Module test_merge No module docstring; 2/11 classes documented
Module test_merge3 Undocumented
Module test_merge_core Undocumented
Module test_merge_directive No module docstring; 6/10 classes documented
Module test_mergetools Undocumented
Module test_missing Undocumented
Module test_msgeditor Test commit message editor.
Module test_multiparent Undocumented
Module test_mutabletree Tests for MutableTree.
Module test_nonascii Test that various operations work in a non-ASCII environment.
Module test_options No module docstring; 3/4 classes, 0/1 functions documented
Module test_osutils Tests for the osutils wrapper.
Module test_osutils_encodings Tests for the osutils wrapper.
Module test_pack Tests for bzrlib.pack.
Module test_patch Undocumented
Module test_patches Undocumented
Module test_permissions Tests for bzr setting permissions.
Module test_plugins Tests for plugins
Module test_progress No module docstring; 3/3 classes documented
Module test_pyutils Tests for bzrlib.pyutils.
Module test_read_bundle Test read_bundle works properly across various transports.
Module test_reconcile Tests for reconiliation behaviour that is repository independent.
Module test_reconfigure Undocumented
Module test_registry Tests for the Registry classes
Module test_remote Tests for remote bzrdir/branch/repo/etc
Module test_rename_map No module docstring; 0/1 classes, 1/1 functions documented
Module test_repository Tests for the Repository facility that are not interface tests.
Module test_revert No module docstring; 1/1 classes documented
Module test_revision No module docstring; 3/7 classes, 1/1 functions documented
Module test_revisionspec No module docstring; 1/17 classes, 1/1 functions documented
Module test_revisiontree Tests for the RevisionTree class.
Module test_rio Tests for rio serialization
Module test_rules Tests for finding, parsing and searching rule-based preferences.
Module test_sampler Document what this test file is expecting to test here.
Module test_scenarios Tests for generating multiple tests for scenarios.
Module test_script Undocumented
Module test_selftest Tests for the test framework.
Module test_serializer Tests for the revision/inventory Serializers.
Module test_server No module docstring; 17/24 classes, 0/1 functions documented
Module test_setup Test for setup.py build process
Module test_sftp_transport No module docstring; 10/14 classes, 1/2 functions documented
Module test_shelf Undocumented
Module test_shelf_ui No module docstring; 1/6 classes documented
Module test_smart Tests for the smart wire/domain protocol.
Module test_smart_add No module docstring; 1/3 classes documented
Module test_smart_request Tests for smart server request infrastructure (bzrlib.smart.request).
Module test_smart_signals Undocumented
Module test_smart_transport Tests for smart transport
Module test_smtp_connection No module docstring; 2/3 classes, 0/1 functions documented
Module test_source These tests are tests about the source code of bzrlib itself.
Module test_ssh_transport Undocumented
Module test_status Undocumented
Module test_store Test Store implementations.
Module test_strace Tests for the strace-invoking support.
Module test_subsume Undocumented
Module test_switch Tests for bzrlib.switch.
Module test_symbol_versioning Symbol versioning tests.
Module test_tag Tests for bzrlib.tag.
Module test_test_server No module docstring; 1/6 classes, 1/1 functions documented
Module test_testament Test testaments for gpg signing.
Module test_textfile Undocumented
Module test_textmerge Undocumented
Module test_timestamp Undocumented
Module test_trace Tests for trace library
Module test_transactions Tests for the behaviour of the Transaction concept in bzr.
Module test_transform No module docstring; 2/16 classes, 0/1 functions documented
Module test_transport No module docstring; 11/25 classes documented
Module test_transport_log Tests for log+ transport decorator.
Module test_tree Tests for Tree and InterTree.
Module test_treebuilder Tests for the TreeBuilder helper class.
Module test_treeshape Undocumented
Module test_tsort Tests for topological sort.
Module test_tuned_gzip Tests for tuned_gzip.
Module test_ui Tests for the bzrlib ui
Module test_uncommit Test uncommit.
Module test_upgrade Tests for upgrade of old trees.
Module test_upgrade_stacked Tests for upgrades of various stacking situations.
Module test_urlutils Tests for the urlutils wrapper.
Module test_utextwrap Tests of the bzrlib.utextwrap.
Module test_version Tests for versioning of bzrlib.
Module test_version_info Tests for version_info
Module test_versionedfile Tests for VersionedFile classes
Module test_weave test suite for weave algorithm
Module test_whitebox Undocumented
Module test_win32utils Tests for win32utils.
Module test_workingtree No module docstring; 5/16 classes documented
Module test_workingtree_4 Tests for WorkingTreeFormat4
Module test_wsgi Tests for WSGI application
Module test_xml No module docstring; 2/3 classes documented
Module testui UI implementations for use in testing.
Module transport_util No module docstring; 3/4 classes, 0/1 functions documented
Module treeshape Test helper for constructing and testing directories.

From the __init__.py module:

Class CapturedCall A helper for capturing smart server calls for easy debug analysis.
Class ChrootedTestCase A support class that provides readonly urls outside the local namespace.
Class CountingDecorator A decorator which calls result.progress(self.countTestCases).
Class ExcludeDecorator A decorator which excludes test matching an exclude pattern.
Class ExtendedTestResult Accepts, reports and accumulates the results of running tests.
Class FilterTestsDecorator A decorator which filters tests to those matching a pattern.
Function IsolatedDocTestSuite Overrides doctest.DocTestSuite to handle isolation.
Function ModuleAvailableFeature Undocumented
Class ProfileResult Generate profiling data for all activity between start and success.
Class RandomDecorator A decorator which randomises the order of its tests.
Class StringIOWrapper A wrapper around cStringIO which just adds an encoding attribute.
Class SubUnitBzrProtocolClient Undocumented
Class SubUnitBzrRunner Undocumented
Class TestCase Base class for bzr unit tests.
Class TestCaseInTempDir Derived class that runs a test within a temporary directory.
Class TestCaseWithMemoryTransport Common test class for tests that do not need disk resources.
Class TestCaseWithTransport A test case that provides get_url and get_readonly_url facilities.
Class TestDecorator A decorator for TestCase/TestSuite objects.
Class TestFirstDecorator A decorator which moves named tests to the front.
Class TestIdList Test id list to filter a test suite.
Class TestNotApplicable A test is not applicable to the situation where it was run.
Class TestPrefixAliasRegistry A registry for test prefix aliases.
Class TestUIFactory A UI Factory for testing.
Class TextTestResult Displays progress and results of tests in text form
Class TextTestRunner No class docstring; 2/2 methods documented
Class UnavailableFeature A feature required for this test was not available.
Class VerboseTestResult Produce long output, with one line per test run plus times
Function apply_scenario Copy test and apply scenario to it.
Function apply_scenarios Apply the scenarios in scenarios to test and add to result.
Function clone_test Clone a test giving it a new id.
Function condition_id_in_list Create a condition filter which verify that test's id in a list.
Function condition_id_re Create a condition filter which performs a re check on a test's id.
Function condition_id_startswith Create a condition filter verifying that test's id starts with a string.
Function condition_isinstance Create a condition filter which returns isinstance(param, klass).
Function exclude_tests Return a test suite decorator that excludes tests.
Function exclude_tests_by_condition Create a test suite which excludes some tests from suite.
Function exclude_tests_by_re Create a test suite which excludes some tests from suite.
Function filter_suite_by_condition Create a test suite by filtering another one.
Function filter_suite_by_id_list Create a test suite by filtering another one.
Function filter_suite_by_id_startswith Create a test suite by filtering another one.
Function filter_suite_by_re Create a test suite by filtering another one.
Function filter_tests Undocumented
Function fork_decorator Undocumented
Function fork_for_tests Take suite and start up one runner per CPU by forking()
Function identity_decorator Return suite.
Function isolated_doctest_setUp Undocumented
Function isolated_doctest_tearDown Undocumented
Function iter_suite_tests Return all tests in a suite, recursing through nested suites
Function load_test_id_list Load a test id list from a text file.
Function multiply_scenarios Multiply two or more iterables of scenarios.
Function multiply_tests Multiply tests_list by scenarios into result.
Function override_os_environ Modify os.environ keeping a copy.
Function partition_tests Partition suite into count lists of tests.
Function permute_tests_for_extension Helper for permutating tests against an extension module.
Function preserve_input A helper for performing test suite transformation chains.
Function probe_bad_non_ascii Try to find [bad] character with code [128..255]
Function probe_unicode_in_user_encoding Try to encode several unicode strings to use in unicode-aware tests.
Function random_order Return a test suite decorator factory for randomising tests order.
Function randomize_suite Return a new TestSuite with suite's tests in random order.
Function reinvoke_for_tests Take suite and start up one runner per CPU using subprocess().
Function restore_os_environ Restore os.environ to its original state.
Function run_suite Run a test suite for bzr selftest.
Function selftest Run the whole test suite under the enhanced runner
Function split_suite_by_condition Split a test suite into two by a condition.
Function split_suite_by_re Split a test suite into two by a regular expression.
Function subprocess_decorator Undocumented
Function suite_matches_id_list Warns about tests not appearing or appearing more than once.
Function test_suite Build and return TestSuite for the whole of bzrlib.
Function tests_first Undocumented
Function workaround_zealous_crypto_random Crypto.Random want to help us being secure, but we don't care here.
Function _clear__type_equality_funcs Cleanup bound methods stored on TestCase instances
Function _clever_some_str Undocumented
Function _multiply_two_scenarios Multiply two sets of scenarios.
Function _rmtree_temp_dir Undocumented
Function _test_suite_modules_to_doctest Return the list of modules to doctest.
Function _test_suite_testmod_names Return the standard list of test module names to test.
def override_os_environ(test, env=None):
Modify os.environ keeping a copy.
ParameterstestA test instance
envA dict containing variable definitions to be installed
def restore_os_environ(test):
Restore os.environ to its original state.
ParameterstestA test instance previously passed to override_os_environ.
def _clear__type_equality_funcs(test):
Cleanup bound methods stored on TestCase instances

Clear the dict breaking a few (mostly) harmless cycles in the affected unittests released with Python 2.6 and initial Python 2.7 versions.

For a few revisions between Python 2.7.1 and Python 2.7.2 that annoyingly shipped in Oneiric, an object with no clear method was used, hence the extra complications, see bug 809048 for details.

def iter_suite_tests(suite):
Return all tests in a suite, recursing through nested suites
def _clever_some_str(value):
Undocumented
def isolated_doctest_setUp(test):
Undocumented
def isolated_doctest_tearDown(test):
Undocumented
def IsolatedDocTestSuite(*args, **kwargs):
Overrides doctest.DocTestSuite to handle isolation.

The method is really a factory and users are expected to use it as such.

def condition_id_re(pattern):
Create a condition filter which performs a re check on a test's id.
ParameterspatternA regular expression string.
ReturnsA callable that returns True if the re matches.
def condition_isinstance(klass_or_klass_list):
Create a condition filter which returns isinstance(param, klass).
ReturnsA callable which when called with one parameter obj return the result of isinstance(obj, klass_or_klass_list).
def condition_id_in_list(id_list):
Create a condition filter which verify that test's id in a list.
Parametersid_listA TestIdList object.
ReturnsA callable that returns True if the test's id appears in the list.
def condition_id_startswith(starts):
Create a condition filter verifying that test's id starts with a string.
ParametersstartsA list of string.
ReturnsA callable that returns True if the test's id starts with one of the given strings.
def exclude_tests_by_condition(suite, condition):
Create a test suite which excludes some tests from suite.
ParameterssuiteThe suite to get tests from.
conditionA callable whose result evaluates True when called with a test case which should be excluded from the result.
ReturnsA suite which contains the tests found in suite that fail condition.
def filter_suite_by_condition(suite, condition):
Create a test suite by filtering another one.
ParameterssuiteThe source suite.
conditionA callable whose result evaluates True when called with a test case which should be included in the result.
ReturnsA suite which contains the tests found in suite that pass condition.
def filter_suite_by_re(suite, pattern):
Create a test suite by filtering another one.
Parameterssuitethe source suite
patternpattern that names must match
Returnsthe newly created suite
def filter_suite_by_id_list(suite, test_id_list):
Create a test suite by filtering another one.
ParameterssuiteThe source suite.
test_id_listA list of the test ids to keep as strings.
Returnsthe newly created suite
def filter_suite_by_id_startswith(suite, start):
Create a test suite by filtering another one.
ParameterssuiteThe source suite.
startA list of string the test id must start with one of.
Returnsthe newly created suite
def exclude_tests_by_re(suite, pattern):
Create a test suite which excludes some tests from suite.
ParameterssuiteThe suite to get tests from.
patternA regular expression string. Test ids that match this pattern will be excluded from the result.
ReturnsA TestSuite that contains all the tests from suite without the tests that matched pattern. The order of tests is the same as it was in suite.
def preserve_input(something):
A helper for performing test suite transformation chains.
ParameterssomethingAnything you want to preserve.
ReturnsSomething.
def randomize_suite(suite):
Return a new TestSuite with suite's tests in random order.

The tests in the input suite are flattened into a single suite in order to accomplish this. Any nested TestSuites are removed to provide global randomness.

def split_suite_by_condition(suite, condition):
Split a test suite into two by a condition.
ParameterssuiteThe suite to split.
conditionThe condition to match on. Tests that match this condition are returned in the first test suite, ones that do not match are in the second suite.
ReturnsA tuple of two test suites, where the first contains tests from suite matching the condition, and the second contains the remainder from suite. The order within each output suite is the same as it was in suite.
def split_suite_by_re(suite, pattern):
Split a test suite into two by a regular expression.
ParameterssuiteThe suite to split.
patternA regular expression string. Test ids that match this pattern will be in the first test suite returned, and the others in the second test suite returned.
ReturnsA tuple of two test suites, where the first contains tests from suite matching pattern, and the second contains the remainder from suite. The order within each output suite is the same as it was in suite.
def run_suite(suite, name='test', verbose=False, pattern='.*', stop_on_failure=False, transport=None, lsprof_timed=None, bench_history=None, matching_tests_first=None, list_only=False, random_seed=None, exclude_pattern=None, strict=False, runner_class=None, suite_decorators=None, stream=None, result_decorators=None):
Run a test suite for bzr selftest.
Parametersrunner_classThe class of runner to use. Must support the constructor arguments passed by run_suite which are more than standard python uses.
ReturnsA boolean indicating success.
def fork_decorator(suite):
Undocumented
def subprocess_decorator(suite):
Undocumented
def exclude_tests(exclude_pattern):
Return a test suite decorator that excludes tests.
def filter_tests(pattern):
Undocumented
def random_order(random_seed, runner):
Return a test suite decorator factory for randomising tests order.
Parametersrandom_seednow, a string which casts to a long, or a long.
runnerA test runner with a stream attribute to report on.
def tests_first(pattern):
Undocumented
def identity_decorator(suite):
Return suite.
def partition_tests(suite, count):
Partition suite into count lists of tests.
def workaround_zealous_crypto_random():
Crypto.Random want to help us being secure, but we don't care here.

This workaround some test failure related to the sftp server. Once paramiko stop using the controversial API in Crypto.Random, we may get rid of it.

def fork_for_tests(suite):
Take suite and start up one runner per CPU by forking()
ReturnsAn iterable of TestCase-like objects which can each have run(result) called on them to feed tests to result.
def reinvoke_for_tests(suite):
Take suite and start up one runner per CPU using subprocess().
ReturnsAn iterable of TestCase-like objects which can each have run(result) called on them to feed tests to result.
def selftest(verbose=False, pattern='.*', stop_on_failure=True, transport=None, test_suite_factory=None, lsprof_timed=None, bench_history=None, matching_tests_first=None, list_only=False, random_seed=None, exclude_pattern=None, strict=False, load_list=None, debug_flags=None, starting_with=None, runner_class=None, suite_decorators=None, stream=None, lsprof_tests=False):
Run the whole test suite under the enhanced runner
def load_test_id_list(file_name):
Load a test id list from a text file.

The format is one test id by line. No special care is taken to impose strict rules, these test ids are used to filter the test suite so a test id that do not match an existing test will do no harm. This allows user to add comments, leave blank lines, etc.

def suite_matches_id_list(test_suite, id_list):
Warns about tests not appearing or appearing more than once.

When using a prefined test id list, it may occurs that some tests do not exist anymore or that some tests use the same id. This function warns the tester about potential problems in his workflow (test lists are volatile) or in the test suite itself (using the same id for several tests does not help to localize defects).

Parameterstest_suiteA TestSuite object.
test_id_listThe list of test ids that should be found in test_suite.
Returns(absents, duplicates) absents is a list containing the test found in id_list but not in test_suite, duplicates is a list containing the test found multiple times in test_suite.
def _test_suite_testmod_names():
Return the standard list of test module names to test.
def _test_suite_modules_to_doctest():
Return the list of modules to doctest.
def test_suite(keep_only=None, starting_with=None):
Build and return TestSuite for the whole of bzrlib.

This function can be replaced if you need to change the default test suite on a global basis, but it is not encouraged.

Parameterskeep_onlyA list of test ids limiting the suite returned.
starting_withAn id limiting the suite returned to the tests starting with it.
def multiply_scenarios(*scenarios):
Multiply two or more iterables of scenarios.

It is safe to pass scenario generators or iterators.

ReturnsA list of compound scenarios: the cross-product of all scenarios, with the names concatenated and the parameters merged together.
def _multiply_two_scenarios(scenarios_left, scenarios_right):
Multiply two sets of scenarios.
Returnsthe cartesian product of the two sets of scenarios, that is a scenario for every possible combination of a left scenario and a right scenario.
def multiply_tests(tests, scenarios, result):

Multiply tests_list by scenarios into result.

This is the core workhorse for test parameterisation.

Typically the load_tests() method for a per-implementation test suite will call multiply_tests and return the result.

This returns the passed in result TestSuite with the cross product of all the tests repeated once for each scenario. Each test is adapted by adding the scenario name at the end of its id(), and updating the test object's __dict__ with the scenario_param_dict.

>>> import bzrlib.tests.test_sampler
>>> r = multiply_tests(
...     bzrlib.tests.test_sampler.DemoTest('test_nothing'),
...     [('one', dict(param=1)),
...      ('two', dict(param=2))],
...     TestUtil.TestSuite())
>>> tests = list(iter_suite_tests(r))
>>> len(tests)
2
>>> tests[0].id()
'bzrlib.tests.test_sampler.DemoTest.test_nothing(one)'
>>> tests[0].param
1
>>> tests[1].param
2
ParameterstestsThe tests to parameterise.
scenariosThe scenarios to apply: pairs of (scenario_name, scenario_param_dict).
resultA TestSuite to add created tests to.
def apply_scenarios(test, scenarios, result):
Apply the scenarios in scenarios to test and add to result.
ParameterstestThe test to apply scenarios to.
scenariosAn iterable of scenarios to apply to test.
Returnsresult
See Alsoapply_scenario
def apply_scenario(test, scenario):
Copy test and apply scenario to it.
ParameterstestA test to adapt.
scenarioA tuple describing the scenarion. The first element of the tuple is the new test id. The second element is a dict containing attributes to set on the test.
ReturnsThe adapted test.
def clone_test(test, new_id):
Clone a test giving it a new id.
ParameterstestThe test to clone.
new_idThe id to assign to it.
ReturnsThe new test.
def permute_tests_for_extension(standard_tests, loader, py_module_name, ext_module_name):
Helper for permutating tests against an extension module.

This is meant to be used inside a modules 'load_tests()' function. It will create 2 scenarios, and cause all tests in the 'standard_tests' to be run against both implementations. Setting 'test.module' to the appropriate module. See bzrlib.tests.test__chk_map.load_tests as an example.

Parametersstandard_testsA test suite to permute
loaderA TestLoader
py_module_nameThe python path to a python module that can always be loaded, and will be considered the 'python' implementation. (eg 'bzrlib._chk_map_py')
ext_module_nameThe python path to an extension module. If the module cannot be loaded, a single test will be added, which notes that the module is not available. If it can be loaded, all standard_tests will be run against that module.
Returns(suite, feature) suite is a test-suite that has all the permuted tests. feature is the Feature object that can be used to determine if the module is available.
def _rmtree_temp_dir(dirname, test_id=None):
Undocumented
def probe_unicode_in_user_encoding():
Try to encode several unicode strings to use in unicode-aware tests. Return first successfull match.
Returns(unicode value, encoded plain string value) or (None, None)
def probe_bad_non_ascii(encoding):
Try to find [bad] character with code [128..255] that cannot be decoded to unicode in some encoding. Return None if all non-ascii characters is valid for given encoding.
@deprecated_function(deprecated_in((2, 5, 0)))
def ModuleAvailableFeature(name):
Undocumented
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.