Rev 5062: Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. in file:///home/vila/src/bzr/cleanup/test-servers/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Feb 11 09:21:46 GMT 2010


At file:///home/vila/src/bzr/cleanup/test-servers/

------------------------------------------------------------
revno: 5062
revision-id: v.ladeuil+lp at free.fr-20100211092145-drh33z43szccfswy
parent: v.ladeuil+lp at free.fr-20100209214558-6xv1a8uq712y1uwc
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: test-servers
timestamp: Thu 2010-02-11 10:21:45 +0100
message:
  Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2010-02-09 13:42:41 +0000
+++ b/NEWS	2010-02-11 09:21:45 +0000
@@ -16,6 +16,11 @@
 
 * ``Repository.get_inventory_sha1()`` has been removed. (Jelmer Vernooij)
 
+* All test servers have been moved out of the bzrlib.transport hierarchy to
+  bzrlib.tests.test_server *except* for MemoryServer, ChrootServer and
+  PathFilteringServer.
+  (Vincent Ladeuil)
+
 New Features
 ************
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-02-09 21:23:58 +0000
+++ b/bzrlib/builtins.py	2010-02-11 09:21:45 +0000
@@ -54,6 +54,7 @@
     )
 from bzrlib.branch import Branch
 from bzrlib.conflicts import ConflictList
+from bzrlib.transport import memory
 from bzrlib.revisionspec import RevisionSpec, RevisionInfo
 from bzrlib.smtp_connection import SMTPConnection
 from bzrlib.workingtree import WorkingTree
@@ -3445,7 +3446,7 @@
             return stub_sftp.SFTPAbsoluteServer
         if typestring == "memory":
             from bzrlib.tests import test_server
-            return test_server.MemoryServer
+            return memory.MemoryServer
         if typestring == "fakenfs":
             from bzrlib.tests import test_server
             return test_server.FakeNFSServer

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2010-02-09 21:03:24 +0000
+++ b/bzrlib/tests/__init__.py	2010-02-11 09:21:45 +0000
@@ -101,7 +101,11 @@
     deprecated_passed,
     )
 import bzrlib.trace
-from bzrlib.transport import get_transport, pathfilter
+from bzrlib.transport import (
+    get_transport,
+    memory,
+    pathfilter,
+    )
 import bzrlib.transport
 from bzrlib.trace import mutter, note
 from bzrlib.tests import (
@@ -2205,7 +2209,7 @@
         is no means to override it.
         """
         if self.__vfs_server is None:
-            self.__vfs_server = test_server.MemoryServer()
+            self.__vfs_server = memory.MemoryServer()
             self.start_server(self.__vfs_server)
         return self.__vfs_server
 
@@ -2686,7 +2690,7 @@
 
     def setUp(self):
         super(ChrootedTestCase, self).setUp()
-        if not self.vfs_transport_factory == test_server.MemoryServer:
+        if not self.vfs_transport_factory == memory.MemoryServer:
             self.transport_readonly_server = HttpServer
 
 

=== modified file 'bzrlib/tests/blackbox/test_cat.py'
--- a/bzrlib/tests/blackbox/test_cat.py	2010-02-09 21:28:15 +0000
+++ b/bzrlib/tests/blackbox/test_cat.py	2010-02-11 09:21:45 +0000
@@ -22,7 +22,7 @@
 import os
 
 from bzrlib import tests
-from bzrlib.tests import test_server
+from bzrlib.transport import memory
 
 
 class TestCat(tests.TestCaseWithTransport):
@@ -196,6 +196,6 @@
         self.assertEqual('contents of README\n', out)
 
     def test_cat_nonexistent_branch(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         self.run_bzr_error(['^bzr: ERROR: Not a branch'],
                            ['cat', self.get_url()])

=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py	2010-02-09 21:27:20 +0000
+++ b/bzrlib/tests/blackbox/test_info.py	2010-02-11 09:21:45 +0000
@@ -29,7 +29,7 @@
     upgrade,
     urlutils,
     )
-from bzrlib.tests import test_server
+from bzrlib.transport import memory
 
 
 class TestInfo(tests.TestCaseWithTransport):
@@ -39,7 +39,7 @@
         self._repo_strings = "2a"
 
     def test_info_non_existing(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         location = self.get_url()
         out, err = self.run_bzr('info '+location, retcode=3)
         self.assertEqual(out, '')

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2010-02-09 21:25:59 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2010-02-11 09:21:45 +0000
@@ -583,7 +583,7 @@
         return transport.get_transport(target)
 
 
-class RedirectingMemoryServer(test_server.MemoryServer):
+class RedirectingMemoryServer(memory.MemoryServer):
 
     def start_server(self):
         self._dirs = {'/': None}

=== modified file 'bzrlib/tests/blackbox/test_selftest.py'
--- a/bzrlib/tests/blackbox/test_selftest.py	2010-02-09 21:23:58 +0000
+++ b/bzrlib/tests/blackbox/test_selftest.py	2010-02-11 09:21:45 +0000
@@ -23,9 +23,8 @@
 from bzrlib.tests import (
     features,
     stub_sftp,
-    test_server,
     )
-
+from bzrlib.transport import memory
 
 class SelfTestPatch:
 
@@ -84,8 +83,7 @@
         # Test that we can pass a transport to the selftest core - memory
         # version.
         params = self.get_params_passed_to_core('selftest --transport=memory')
-        self.assertEqual(test_server.MemoryServer,
-            params[1]["transport"])
+        self.assertEqual(memory.MemoryServer, params[1]["transport"])
 
     def test_parameters_passed_to_core(self):
         params = self.get_params_passed_to_core('selftest --list-only')

=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py	2010-02-09 21:21:54 +0000
+++ b/bzrlib/tests/blackbox/test_send.py	2010-02-11 09:21:45 +0000
@@ -26,7 +26,7 @@
     tests,
     )
 from bzrlib.bundle import serializer
-from bzrlib.tests import test_server
+from bzrlib.transport import memory
 
 
 def load_tests(standard_tests, module, loader):
@@ -281,7 +281,7 @@
         self.assertEqual('rev3', md.revision_id)
 
     def test_nonexistant_branch(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         location = self.get_url('absentdir/')
         out, err = self.run_bzr(["send", "--from", location], retcode=3)
         self.assertEqual(out, '')

=== modified file 'bzrlib/tests/per_branch/__init__.py'
--- a/bzrlib/tests/per_branch/__init__.py	2010-02-09 20:57:03 +0000
+++ b/bzrlib/tests/per_branch/__init__.py	2010-02-11 09:21:45 +0000
@@ -34,6 +34,7 @@
 from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat
 from bzrlib.tests import test_server
 from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir
+from bzrlib.transport import memory
 
 
 def make_scenarios(transport_server, transport_readonly_server,
@@ -145,7 +146,7 @@
         test_server.SmartTCPServer_for_testing,
         test_server.ReadonlySmartTCPServer_for_testing,
         [(remote_branch_format, remote_branch_format._matchingbzrdir)],
-        test_server.MemoryServer,
+        memory.MemoryServer,
         name_suffix='-default'))
     # Also add tests for RemoteBranch with HPSS protocol v2 (i.e. bzr <1.6)
     # server.
@@ -153,7 +154,7 @@
         test_server.SmartTCPServer_for_testing_v2_only,
         test_server.ReadonlySmartTCPServer_for_testing_v2_only,
         [(remote_branch_format, remote_branch_format._matchingbzrdir)],
-        test_server.MemoryServer,
+        memory.MemoryServer,
         name_suffix='-v2'))
     return scenarios
 

=== modified file 'bzrlib/tests/per_branch/test_bound_sftp.py'
--- a/bzrlib/tests/per_branch/test_bound_sftp.py	2010-02-09 21:17:27 +0000
+++ b/bzrlib/tests/per_branch/test_bound_sftp.py	2010-02-11 09:21:45 +0000
@@ -26,13 +26,14 @@
     tests,
     )
 from bzrlib.tests import test_server
+from bzrlib.transport import memory
 
 
 class BoundSFTPBranch(tests.TestCaseWithTransport):
 
     def setUp(self):
         tests.TestCaseWithTransport.setUp(self)
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         if self.transport_server is test_server.LocalURLServer:
             self.transport_server = None
 

=== modified file 'bzrlib/tests/per_branch/test_branch.py'
--- a/bzrlib/tests/per_branch/test_branch.py	2010-02-09 21:16:20 +0000
+++ b/bzrlib/tests/per_branch/test_branch.py	2010-02-11 09:21:45 +0000
@@ -35,9 +35,9 @@
 from bzrlib.tests import (
     http_server,
     per_branch,
-    test_server,
     )
 from bzrlib.tests.http_server import HttpServer
+from bzrlib.transport import memory
 
 
 class TestTestCaseWithBranch(per_branch.TestCaseWithBranch):
@@ -512,7 +512,7 @@
 
     def setUp(self):
         super(ChrootedTests, self).setUp()
-        if not self.vfs_transport_factory == test_server.MemoryServer:
+        if not self.vfs_transport_factory == memory.MemoryServer:
             self.transport_readonly_server = HttpServer
 
     def test_open_containing(self):

=== modified file 'bzrlib/tests/per_bzrdir/__init__.py'
--- a/bzrlib/tests/per_bzrdir/__init__.py	2010-02-09 20:57:03 +0000
+++ b/bzrlib/tests/per_bzrdir/__init__.py	2010-02-11 09:21:45 +0000
@@ -31,6 +31,7 @@
     test_server,
     TestCaseWithTransport,
     )
+from bzrlib.transport import memory
 
 
 def make_scenarios(vfs_factory, transport_server, transport_readonly_server,
@@ -92,14 +93,14 @@
     # test the remote server behaviour when backed with a MemoryTransport
     # Once for the current version
     scenarios.extend(make_scenarios(
-        test_server.MemoryServer,
+        memory.MemoryServer,
         test_server.SmartTCPServer_for_testing,
         test_server.ReadonlySmartTCPServer_for_testing,
         [(RemoteBzrDirFormat())],
         name_suffix='-default'))
     # And once with < 1.6 - the 'v2' protocol.
     scenarios.extend(make_scenarios(
-        test_server.MemoryServer,
+        memory.MemoryServer,
         test_server.SmartTCPServer_for_testing_v2_only,
         test_server.ReadonlySmartTCPServer_for_testing_v2_only,
         [(RemoteBzrDirFormat())],

=== modified file 'bzrlib/tests/per_pack_repository.py'
--- a/bzrlib/tests/per_pack_repository.py	2010-02-09 21:45:58 +0000
+++ b/bzrlib/tests/per_pack_repository.py	2010-02-11 09:21:45 +0000
@@ -54,6 +54,7 @@
     )
 from bzrlib.transport import (
     get_transport,
+    memory,
     )
 from bzrlib.tests import test_server
 from bzrlib.tests.per_repository import TestCaseWithRepository
@@ -238,7 +239,7 @@
 
     def test_commit_write_group_returns_new_pack_names(self):
         # This test doesn't need real disk.
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         format = self.get_format()
         repo = self.make_repository('foo', format=format)
         repo.lock_write()
@@ -707,7 +708,7 @@
 
         Also requires that the exception is logged.
         """
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         repo = self.make_repository('repo', format=self.get_format())
         token = repo.lock_write()
         self.addCleanup(repo.unlock)
@@ -724,7 +725,7 @@
             repo.leave_lock_in_place()
 
     def test_abort_write_group_does_raise_when_not_suppressed(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         repo = self.make_repository('repo', format=self.get_format())
         token = repo.lock_write()
         self.addCleanup(repo.unlock)
@@ -737,7 +738,7 @@
             repo.leave_lock_in_place()
 
     def test_suspend_write_group(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         repo = self.make_repository('repo', format=self.get_format())
         token = repo.lock_write()
         self.addCleanup(repo.unlock)
@@ -757,7 +758,7 @@
         self.assertEqual(wg_tokens[0], md5.hexdigest())
 
     def test_resume_chk_bytes(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         repo = self.make_repository('repo', format=self.get_format())
         if repo.chk_bytes is None:
             raise TestNotApplicable('no chk_bytes for this repository')
@@ -781,7 +782,7 @@
 
     def test_resume_write_group_then_abort(self):
         # Create a repo, start a write group, insert some data, suspend.
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         repo = self.make_repository('repo', format=self.get_format())
         token = repo.lock_write()
         self.addCleanup(repo.unlock)
@@ -802,7 +803,7 @@
             [], same_repo._pack_collection._pack_transport.list_dir(''))
 
     def test_commit_resumed_write_group(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         repo = self.make_repository('repo', format=self.get_format())
         token = repo.lock_write()
         self.addCleanup(repo.unlock)
@@ -830,7 +831,7 @@
         self.assertEqual([expected_pack_name], pack_names)
 
     def test_resume_malformed_token(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         # Make a repository with a suspended write group
         repo = self.make_repository('repo', format=self.get_format())
         token = repo.lock_write()

=== modified file 'bzrlib/tests/per_repository/__init__.py'
--- a/bzrlib/tests/per_repository/__init__.py	2010-02-09 20:57:03 +0000
+++ b/bzrlib/tests/per_repository/__init__.py	2010-02-11 09:21:45 +0000
@@ -39,6 +39,7 @@
     test_server,
     )
 from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir
+from bzrlib.transport import memory
 
 
 def formats_to_scenarios(formats, transport_server, transport_readonly_server,
@@ -87,12 +88,12 @@
         [('-default', RemoteRepositoryFormat())],
         test_server.SmartTCPServer_for_testing,
         test_server.ReadonlySmartTCPServer_for_testing,
-        test_server.MemoryServer))
+        memory.MemoryServer))
     format_scenarios.extend(formats_to_scenarios(
         [('-v2', RemoteRepositoryFormat())],
         test_server.SmartTCPServer_for_testing_v2_only,
         test_server.ReadonlySmartTCPServer_for_testing_v2_only,
-        test_server.MemoryServer))
+        memory.MemoryServer))
     return format_scenarios
 
 

=== modified file 'bzrlib/tests/per_repository/test_write_group.py'
--- a/bzrlib/tests/per_repository/test_write_group.py	2010-02-09 21:36:10 +0000
+++ b/bzrlib/tests/per_repository/test_write_group.py	2010-02-11 09:21:45 +0000
@@ -33,6 +33,7 @@
     per_repository,
     test_server,
     )
+from bzrlib.transport import memory
 
 
 class TestWriteGroup(per_repository.TestCaseWithRepository):
@@ -118,7 +119,7 @@
     def test_abort_write_group_does_not_raise_when_suppressed(self):
         if self.transport_server is test_server.LocalURLServer:
             self.transport_server = None
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         repo = self.make_repository('repo')
         token = repo.lock_write()
         self.addCleanup(repo.unlock)

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2010-02-09 20:49:50 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2010-02-11 09:21:45 +0000
@@ -48,10 +48,12 @@
 from bzrlib.tests import(
     http_server,
     http_utils,
-    test_server,
     )
 from bzrlib.tests.test_http import TestWithTransport_pycurl
-from bzrlib.transport import get_transport
+from bzrlib.transport import (
+    get_transport,
+    memory,
+    )
 from bzrlib.transport.http._urllib import HttpTransport_urllib
 from bzrlib.transport.nosmart import NoSmartTransportDecorator
 from bzrlib.transport.readonly import ReadonlyTransportDecorator
@@ -354,7 +356,7 @@
 
     def test_create_branch_convenience_root(self):
         """Creating a branch at the root of a fs should work."""
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         # outside a repo the default convenience output is a repo+branch_tree
         format = bzrdir.format_registry.make_bzrdir('knit')
         branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
@@ -565,7 +567,7 @@
 
     def setUp(self):
         super(ChrootedTests, self).setUp()
-        if not self.vfs_transport_factory == test_server.MemoryServer:
+        if not self.vfs_transport_factory == memory.MemoryServer:
             self.transport_readonly_server = http_server.HttpServer
 
     def local_branch_path(self, branch):
@@ -1049,7 +1051,7 @@
 
     def setUp(self):
         super(NonLocalTests, self).setUp()
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
 
     def test_create_branch_convenience(self):
         # outside a repo the default convenience output is a repo+branch_tree

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2010-02-09 20:57:03 +0000
+++ b/bzrlib/tests/test_selftest.py	2010-02-11 09:21:45 +0000
@@ -624,7 +624,7 @@
     def test_get_readonly_url_none(self):
         from bzrlib.transport import get_transport
         from bzrlib.transport.readonly import ReadonlyTransportDecorator
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         self.transport_readonly_server = None
         # calling get_readonly_transport() constructs a decorator on the url
         # for the server
@@ -677,7 +677,7 @@
 
     def setUp(self):
         super(TestTestCaseTransports, self).setUp()
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
 
     def test_make_bzrdir_preserves_transport(self):
         t = self.get_transport()
@@ -1469,7 +1469,7 @@
         # permitted.
         # Manually set one up (TestCase doesn't and shouldn't provide magic
         # machinery)
-        transport_server = test_server.MemoryServer()
+        transport_server = memory.MemoryServer()
         transport_server.start_server()
         self.addCleanup(transport_server.stop_server)
         t = transport.get_transport(transport_server.get_url())
@@ -1557,7 +1557,7 @@
             result.calls)
 
     def test_start_server_registers_url(self):
-        transport_server = test_server.MemoryServer()
+        transport_server = memory.MemoryServer()
         # A little strict, but unlikely to be changed soon.
         self.assertEqual([], self._bzr_selftest_roots)
         self.start_server(transport_server)
@@ -1950,7 +1950,7 @@
         self.check_transport_set(stub_sftp.SFTPAbsoluteServer)
 
     def test_transport_memory(self):
-        self.check_transport_set(test_server.MemoryServer)
+        self.check_transport_set(memory.MemoryServer)
 
 
 class TestSelftestWithIdList(tests.TestCaseInTempDir, SelfTestHelper):
@@ -2621,7 +2621,7 @@
         # Running bzr in blackbox mode, normal/expected/user errors should be
         # caught in the regular way and turned into an error message plus exit
         # code.
-        transport_server = test_server.MemoryServer()
+        transport_server = memory.MemoryServer()
         transport_server.start_server()
         self.addCleanup(transport_server.stop_server)
         url = transport_server.get_url()

=== modified file 'bzrlib/tests/test_server.py'
--- a/bzrlib/tests/test_server.py	2010-02-09 20:41:54 +0000
+++ b/bzrlib/tests/test_server.py	2010-02-11 09:21:45 +0000
@@ -74,33 +74,6 @@
         return urlutils.local_path_to_url('')
 
 
-class MemoryServer(TestServer):
-    """Server for the MemoryTransport for testing with."""
-
-    def start_server(self):
-        self._dirs = {'/':None}
-        self._files = {}
-        self._locks = {}
-        self._scheme = "memory+%s:///" % id(self)
-        def memory_factory(url):
-            from bzrlib.transport import memory
-            result = memory.MemoryTransport(url)
-            result._dirs = self._dirs
-            result._files = self._files
-            result._locks = self._locks
-            return result
-        self._memory_factory = memory_factory
-        transport.register_transport(self._scheme, self._memory_factory)
-
-    def stop_server(self):
-        # unregister this server
-        transport.unregister_transport(self._scheme, self._memory_factory)
-
-    def get_url(self):
-        """See bzrlib.transport.Server.get_url."""
-        return self._scheme
-
-
 class DecoratorServer(TestServer):
     """Server for the TransportDecorator for testing with.
 

=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py	2010-02-09 21:01:32 +0000
+++ b/bzrlib/tests/test_smart.py	2010-02-11 09:21:45 +0000
@@ -51,6 +51,7 @@
 from bzrlib.tests import test_server
 from bzrlib.transport import (
     chroot,
+    memory,
     )
 
 
@@ -79,7 +80,7 @@
 class TestCaseWithChrootedTransport(tests.TestCaseWithTransport):
 
     def setUp(self):
-        self.vfs_transport_factory = test_server.MemoryServer
+        self.vfs_transport_factory = memory.MemoryServer
         tests.TestCaseWithTransport.setUp(self)
         self._chroot_server = None
 

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2010-02-09 20:59:03 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2010-02-11 09:21:45 +0000
@@ -40,10 +40,7 @@
         server,
         vfs,
 )
-from bzrlib.tests import (
-    test_server,
-    test_smart,
-    )
+from bzrlib.tests import test_smart
 from bzrlib.transport import (
         http,
         local,
@@ -1002,7 +999,7 @@
         # tests wanting a server. The latter should be updated to use
         # self.vfs_transport_factory etc.
         if not backing_transport:
-            mem_server = test_server.MemoryServer()
+            mem_server = memory.MemoryServer()
             mem_server.start_server()
             self.addCleanup(mem_server.stop_server)
             self.permit_url(mem_server.get_url())

=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py	2010-02-09 20:46:18 +0000
+++ b/bzrlib/tests/test_transport.py	2010-02-11 09:21:45 +0000
@@ -251,7 +251,7 @@
 class TestMemoryServer(tests.TestCase):
 
     def test_create_server(self):
-        server = test_server.MemoryServer()
+        server = memory.MemoryServer()
         server.start_server()
         url = server.get_url()
         self.assertTrue(url in transport.transport_list_registry)

=== modified file 'bzrlib/transport/memory.py'
--- a/bzrlib/transport/memory.py	2010-02-09 17:13:04 +0000
+++ b/bzrlib/transport/memory.py	2010-02-11 09:21:45 +0000
@@ -300,8 +300,37 @@
         self.transport = None
 
 
+class MemoryServer(transport.Server):
+    """Server for the MemoryTransport for testing with."""
+
+    def start_server(self):
+        self._dirs = {'/':None}
+        self._files = {}
+        self._locks = {}
+        self._scheme = "memory+%s:///" % id(self)
+        def memory_factory(url):
+            from bzrlib.transport import memory
+            result = memory.MemoryTransport(url)
+            result._dirs = self._dirs
+            result._files = self._files
+            result._locks = self._locks
+            return result
+        self._memory_factory = memory_factory
+        transport.register_transport(self._scheme, self._memory_factory)
+
+    def stop_server(self):
+        # unregister this server
+        transport.unregister_transport(self._scheme, self._memory_factory)
+
+    def get_url(self):
+        """See bzrlib.transport.Server.get_url."""
+        return self._scheme
+
+    def get_bogus_url(self):
+        raise NotImplementedError
+
+
 def get_test_permutations():
     """Return the permutations to be used in testing."""
-    from bzrlib.tests import test_server
-    return [(MemoryTransport, test_server.MemoryServer),
+    return [(MemoryTransport, MemoryServer),
             ]



More information about the bazaar-commits mailing list