Rev 5021: Move MemoryServer to bzrlib.tests.test_server in file:///home/vila/src/bzr/cleanup/test-servers/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Feb 9 17:13:05 GMT 2010


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

------------------------------------------------------------
revno: 5021
revision-id: v.ladeuil+lp at free.fr-20100209171304-2ppoju422x02s7fm
parent: v.ladeuil+lp at free.fr-20100209170838-f11kugp9yns8lt5t
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: test-servers
timestamp: Tue 2010-02-09 18:13:04 +0100
message:
  Move MemoryServer to bzrlib.tests.test_server
-------------- next part --------------
=== modified file 'bzrlib/tests/test_server.py'
--- a/bzrlib/tests/test_server.py	2010-02-09 17:08:38 +0000
+++ b/bzrlib/tests/test_server.py	2010-02-09 17:13:04 +0000
@@ -68,6 +68,33 @@
         return urlutils.local_path_to_url('')
 
 
+class MemoryServer(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
+
+
 class DecoratorServer(Server):
     """Server for the TransportDecorator for testing with.
 

=== modified file 'bzrlib/transport/memory.py'
--- a/bzrlib/transport/memory.py	2010-01-08 17:28:25 +0000
+++ b/bzrlib/transport/memory.py	2010-02-09 17:13:04 +0000
@@ -28,6 +28,7 @@
 import warnings
 
 from bzrlib import (
+    transport,
     urlutils,
     )
 from bzrlib.errors import (
@@ -42,10 +43,6 @@
     AppendBasedFileStream,
     _file_streams,
     LateReadError,
-    register_transport,
-    Server,
-    Transport,
-    unregister_transport,
     )
 
 
@@ -64,7 +61,7 @@
             self.st_mode = S_IFDIR | perms
 
 
-class MemoryTransport(Transport):
+class MemoryTransport(transport.Transport):
     """This is an in memory file system for transient data storage."""
 
     def __init__(self, url=""):
@@ -303,33 +300,8 @@
         self.transport = None
 
 
-class MemoryServer(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):
-            result = MemoryTransport(url)
-            result._dirs = self._dirs
-            result._files = self._files
-            result._locks = self._locks
-            return result
-        self._memory_factory = memory_factory
-        register_transport(self._scheme, self._memory_factory)
-
-    def stop_server(self):
-        # unregister this server
-        unregister_transport(self._scheme, self._memory_factory)
-
-    def get_url(self):
-        """See bzrlib.transport.Server.get_url."""
-        return self._scheme
-
-
 def get_test_permutations():
     """Return the permutations to be used in testing."""
-    return [(MemoryTransport, MemoryServer),
+    from bzrlib.tests import test_server
+    return [(MemoryTransport, test_server.MemoryServer),
             ]



More information about the bazaar-commits mailing list