Function | override_os_environ | Modify os.environ keeping a copy. |
Function | restore_os_environ | Restore os.environ to its original state. |
Class | ExtendedTestResult | Accepts, reports and accumulates the results of running tests. |
Class | TextTestResult | Displays progress and results of tests in text form |
Class | VerboseTestResult | Produce long output, with one line per test run plus times |
Class | TextTestRunner | No class docstring; 2/2 methods documented |
Function | iter_suite_tests | Return all tests in a suite, recursing through nested suites |
Class | TestNotApplicable | A test is not applicable to the situation where it was run. |
Class | UnavailableFeature | A feature required for this test was not available. |
Class | StringIOWrapper | A wrapper around cStringIO which just adds an encoding attribute. |
Class | TestUIFactory | A UI Factory for testing. |
Function | isolated_doctest_setUp | Undocumented |
Function | isolated_doctest_tearDown | Undocumented |
Function | IsolatedDocTestSuite | Overrides doctest.DocTestSuite to handle isolation. |
Class | TestCase | Base class for bzr unit tests. |
Class | CapturedCall | A helper for capturing smart server calls for easy debug analysis. |
Class | TestCaseWithMemoryTransport | Common test class for tests that do not need disk resources. |
Class | TestCaseInTempDir | Derived class that runs a test within a temporary directory. |
Class | TestCaseWithTransport | A test case that provides get_url and get_readonly_url facilities. |
Class | ChrootedTestCase | A support class that provides readonly urls outside the local namespace. |
Function | condition_id_re | Create a condition filter which performs a re check on a test's id. |
Function | condition_isinstance | Create a condition filter which returns isinstance(param, klass). |
Function | condition_id_in_list | Create a condition filter which verify that test's id in a list. |
Function | condition_id_startswith | Create a condition filter verifying that test's id starts with a string. |
Function | exclude_tests_by_condition | 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_re | 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 | exclude_tests_by_re | Create a test suite which excludes some tests from suite. |
Function | preserve_input | A helper for performing test suite transformation chains. |
Function | randomize_suite | Return a new TestSuite with suite's tests in random order. |
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 | run_suite | Run a test suite for bzr selftest. |
Function | fork_decorator | Undocumented |
Function | subprocess_decorator | Undocumented |
Function | exclude_tests | Return a test suite decorator that excludes tests. |
Function | filter_tests | Undocumented |
Function | random_order | Return a test suite decorator factory for randomising tests order. |
Function | tests_first | Undocumented |
Function | identity_decorator | Return suite. |
Class | TestDecorator | A decorator for TestCase/TestSuite objects. |
Class | CountingDecorator | A decorator which calls result.progress(self.countTestCases). |
Class | ExcludeDecorator | A decorator which excludes test matching an exclude pattern. |
Class | FilterTestsDecorator | A decorator which filters tests to those matching a pattern. |
Class | RandomDecorator | A decorator which randomises the order of its tests. |
Class | TestFirstDecorator | A decorator which moves named tests to the front. |
Function | partition_tests | Partition suite into count lists of tests. |
Function | workaround_zealous_crypto_random | Crypto.Random want to help us being secure, but we don't care here. |
Function | fork_for_tests | Take suite and start up one runner per CPU by forking() |
Function | reinvoke_for_tests | Take suite and start up one runner per CPU using subprocess(). |
Class | ProfileResult | Generate profiling data for all activity between start and success. |
Function | selftest | Run the whole test suite under the enhanced runner |
Function | load_test_id_list | Load a test id list from a text file. |
Function | suite_matches_id_list | Warns about tests not appearing or appearing more than once. |
Class | TestIdList | Test id list to filter a test suite. |
Class | TestPrefixAliasRegistry | A registry for test prefix aliases. |
Function | test_suite | Build and return TestSuite for the whole of bzrlib. |
Function | multiply_scenarios | Multiply two or more iterables of scenarios. |
Function | multiply_tests | Multiply tests_list by scenarios into result. |
Function | apply_scenarios | Apply the scenarios in scenarios to test and add to result. |
Function | apply_scenario | Copy test and apply scenario to it. |
Function | clone_test | Clone a test giving it a new id. |
Function | permute_tests_for_extension | Helper for permutating tests against an extension module. |
Function | probe_unicode_in_user_encoding | Try to encode several unicode strings to use in unicode-aware tests. |
Function | probe_bad_non_ascii | Try to find [bad] character with code [128..255] |
Class | SubUnitBzrProtocolClient | Undocumented |
Class | SubUnitBzrRunner | Undocumented |
Function | ModuleAvailableFeature | Undocumented |
Function | _clear__type_equality_funcs | Cleanup bound methods stored on TestCase instances |
Function | _clever_some_str | Undocumented |
Function | _test_suite_testmod_names | Return the standard list of test module names to test. |
Function | _test_suite_modules_to_doctest | Return the list of modules to doctest. |
Function | _multiply_two_scenarios | Multiply two sets of scenarios. |
Function | _rmtree_temp_dir | Undocumented |
Parameters | test | A test instance |
env | A dict containing variable definitions to be installed |
Parameters | test | A test instance previously passed to override_os_environ. |
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.
The method is really a factory and users are expected to use it as such.
Parameters | pattern | A regular expression string. |
Returns | A callable that returns True if the re matches. |
Returns | A callable which when called with one parameter obj return the result of isinstance(obj, klass_or_klass_list). |
Parameters | id_list | A TestIdList object. |
Returns | A callable that returns True if the test's id appears in the list. |
Parameters | starts | A list of string. |
Returns | A callable that returns True if the test's id starts with one of the given strings. |
Parameters | suite | The suite to get tests from. |
condition | A callable whose result evaluates True when called with a test case which should be excluded from the result. | |
Returns | A suite which contains the tests found in suite that fail condition. |
Parameters | suite | The source suite. |
condition | A callable whose result evaluates True when called with a test case which should be included in the result. | |
Returns | A suite which contains the tests found in suite that pass condition. |
Parameters | suite | the source suite |
pattern | pattern that names must match | |
Returns | the newly created suite |
Parameters | suite | The source suite. |
test_id_list | A list of the test ids to keep as strings. | |
Returns | the newly created suite |
Parameters | suite | The source suite. |
start | A list of string the test id must start with one of. | |
Returns | the newly created suite |
Parameters | suite | The suite to get tests from. |
pattern | A regular expression string. Test ids that match this pattern will be excluded from the result. | |
Returns | A 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. |
Parameters | something | Anything you want to preserve. |
Returns | Something. |
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.
Parameters | suite | The suite to split. |
condition | The 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. | |
Returns | A 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. |
Parameters | suite | The suite to split. |
pattern | A 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. | |
Returns | A 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. |
Parameters | runner_class | The class of runner to use. Must support the constructor arguments passed by run_suite which are more than standard python uses. |
Returns | A boolean indicating success. |
Parameters | random_seed | now, a string which casts to a long, or a long. |
runner | A test runner with a stream attribute to report on. |
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.
Returns | An iterable of TestCase-like objects which can each have run(result) called on them to feed tests to result. |
Returns | An iterable of TestCase-like objects which can each have run(result) called on them to feed tests to result. |
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.
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).
Parameters | test_suite | A TestSuite object. |
test_id_list | The 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. |
This function can be replaced if you need to change the default test suite on a global basis, but it is not encouraged.
Parameters | keep_only | A list of test ids limiting the suite returned. |
starting_with | An id limiting the suite returned to the tests starting with it. |
It is safe to pass scenario generators or iterators.
Returns | A list of compound scenarios: the cross-product of all scenarios, with the names concatenated and the parameters merged together. |
Returns | the cartesian product of the two sets of scenarios, that is a scenario for every possible combination of a left scenario and a right scenario. |
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
Parameters | tests | The tests to parameterise. |
scenarios | The scenarios to apply: pairs of (scenario_name, scenario_param_dict). | |
result | A TestSuite to add created tests to. |
Parameters | test | The test to apply scenarios to. |
scenarios | An iterable of scenarios to apply to test. | |
Returns | result | |
See Also | apply_scenario |
Parameters | test | A test to adapt. |
scenario | A 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. | |
Returns | The adapted test. |
Parameters | test | The test to clone. |
new_id | The id to assign to it. | |
Returns | The new test. |
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.
Parameters | standard_tests | A test suite to permute |
loader | A TestLoader | |
py_module_name | The 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_name | The 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. |
Returns | (unicode value, encoded plain string value) or (None, None) |