b.t.fixtures : module documentation

Part of bzrlib.tests

Fixtures that can be used within tests.

Fixtures can be created during a test as a way to separate out creation of objects to test. Fixture objects can hold some state so that different objects created during a test instance can be related. Normally a fixture should live only for the duration of a single test, and its tearDown method should be passed to addCleanup on the test.

Function generate_unicode_names Generate a sequence of arbitrary unique unicode names.
Function generate_unicode_encodings Return a generator of unicode encoding names.
Class RecordingContextManager A context manager that records.
Function build_branch_with_non_ancestral_rev Builds a branch with a rev not in the ancestry of the tip.
Function make_branch_and_populated_tree Make a simple branch and tree.
def generate_unicode_names():

Generate a sequence of arbitrary unique unicode names.

By default they are not representable in ascii.

>>> gen = generate_unicode_names()
>>> n1 = gen.next()
>>> n2 = gen.next()
>>> type(n1)
<type 'unicode'>
>>> n1 == n2
False
>>> n1.encode('ascii', 'replace') == n1
False
def generate_unicode_encodings(universal_encoding=None):

Return a generator of unicode encoding names.

These can be passed to Python encode/decode/etc.

>>> n1 = generate_unicode_names().next()
>>> enc = generate_unicode_encodings(universal_encoding=True).next()
>>> enc2 = generate_unicode_encodings(universal_encoding=False).next()
>>> n1.encode(enc).decode(enc) == n1
True
>>> try:
...   n1.encode(enc2).decode(enc2)
... except UnicodeError:
...   print 'fail'
fail
Parametersuniversal_encodingTrue/False/None tristate to say whether the generated encodings either can or cannot encode all unicode strings.
def build_branch_with_non_ancestral_rev(branch_builder):
Builds a branch with a rev not in the ancestry of the tip.

This is the revision graph:

rev-2
  |
rev-1
  |
(null)

The branch tip is 'rev-1'. 'rev-2' is present in the branch's repository, but is not part of rev-1's ancestry.

Parametersbranch_builderA BranchBuilder (e.g. from TestCaseWithMemoryTransport.make_branch_builder).
Returnsthe new branch
def make_branch_and_populated_tree(testcase):
Make a simple branch and tree.

The tree holds some added but uncommitted files.

API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.