685
683
new_version_ids.add(version)
686
684
return new_version_ids
689
class InterVersionedFileTestProviderAdapter(object):
690
"""A tool to generate a suite testing multiple inter versioned-file classes.
692
This is done by copying the test once for each InterVersionedFile provider
693
and injecting the transport_server, transport_readonly_server,
694
versionedfile_factory and versionedfile_factory_to classes into each copy.
695
Each copy is also given a new id() to make it easy to identify.
698
def __init__(self, transport_server, transport_readonly_server, formats):
699
self._transport_server = transport_server
700
self._transport_readonly_server = transport_readonly_server
701
self._formats = formats
703
def adapt(self, test):
704
result = unittest.TestSuite()
705
for (interversionedfile_class,
706
versionedfile_factory,
707
versionedfile_factory_to) in self._formats:
708
new_test = deepcopy(test)
709
new_test.transport_server = self._transport_server
710
new_test.transport_readonly_server = self._transport_readonly_server
711
new_test.interversionedfile_class = interversionedfile_class
712
new_test.versionedfile_factory = versionedfile_factory
713
new_test.versionedfile_factory_to = versionedfile_factory_to
714
def make_new_test_id():
715
new_id = "%s(%s)" % (new_test.id(), interversionedfile_class.__name__)
716
return lambda: new_id
717
new_test.id = make_new_test_id()
718
result.addTest(new_test)
722
def default_test_list():
723
"""Generate the default list of interversionedfile permutations to test."""
724
from bzrlib.weave import WeaveFile
725
from bzrlib.knit import KnitVersionedFile
727
# test the fallback InterVersionedFile from annotated knits to weave
728
result.append((InterVersionedFile,
731
for optimiser in InterVersionedFile._optimisers:
732
result.append((optimiser,
733
optimiser._matching_file_from_factory,
734
optimiser._matching_file_to_factory
736
# if there are specific combinations we want to use, we can add them