mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-19 16:20:52 +00:00
Move FakeCanary to common_util
Couldn't bring myself to move it back to test_storage.
This commit is contained in:
parent
23140b8b1c
commit
b75b48e68c
@ -87,31 +87,3 @@ def skip_if_cannot_represent_filename(u):
|
||||
u.encode(enc)
|
||||
except UnicodeEncodeError:
|
||||
raise unittest.SkipTest("A non-ASCII filename could not be encoded on this platform.")
|
||||
|
||||
|
||||
class Marker(object):
|
||||
pass
|
||||
|
||||
class FakeCanary(object):
|
||||
"""For use in storage tests.
|
||||
|
||||
Can be moved back to test_storage.py once enough Python 3 porting has been
|
||||
done.
|
||||
"""
|
||||
def __init__(self, ignore_disconnectors=False):
|
||||
self.ignore = ignore_disconnectors
|
||||
self.disconnectors = {}
|
||||
def notifyOnDisconnect(self, f, *args, **kwargs):
|
||||
if self.ignore:
|
||||
return
|
||||
m = Marker()
|
||||
self.disconnectors[m] = (f, args, kwargs)
|
||||
return m
|
||||
def dontNotifyOnDisconnect(self, marker):
|
||||
if self.ignore:
|
||||
return
|
||||
del self.disconnectors[marker]
|
||||
def getRemoteTubID(self):
|
||||
return None
|
||||
def getPeer(self):
|
||||
return "<fake>"
|
||||
|
@ -87,6 +87,34 @@ class StallMixin(object):
|
||||
return d
|
||||
|
||||
|
||||
class Marker(object):
|
||||
pass
|
||||
|
||||
class FakeCanary(object):
|
||||
"""For use in storage tests.
|
||||
|
||||
Can be moved back to test_storage.py once enough Python 3 porting has been
|
||||
done.
|
||||
"""
|
||||
def __init__(self, ignore_disconnectors=False):
|
||||
self.ignore = ignore_disconnectors
|
||||
self.disconnectors = {}
|
||||
def notifyOnDisconnect(self, f, *args, **kwargs):
|
||||
if self.ignore:
|
||||
return
|
||||
m = Marker()
|
||||
self.disconnectors[m] = (f, args, kwargs)
|
||||
return m
|
||||
def dontNotifyOnDisconnect(self, marker):
|
||||
if self.ignore:
|
||||
return
|
||||
del self.disconnectors[marker]
|
||||
def getRemoteTubID(self):
|
||||
return None
|
||||
def getPeer(self):
|
||||
return "<fake>"
|
||||
|
||||
|
||||
class ShouldFailMixin(object):
|
||||
|
||||
def shouldFail(self, expected_failure, which, substring,
|
||||
|
@ -27,8 +27,7 @@ from allmydata.util import fileutil, hashutil, pollmixin
|
||||
from allmydata.storage.server import StorageServer, si_b2a
|
||||
from allmydata.storage.crawler import ShareCrawler, TimeSliceExceeded
|
||||
|
||||
from allmydata.test.common_py3 import FakeCanary
|
||||
from allmydata.test.common_util import StallMixin
|
||||
from allmydata.test.common_util import StallMixin, FakeCanary
|
||||
|
||||
class BucketEnumeratingCrawler(ShareCrawler):
|
||||
cpu_slice = 500 # make sure it can complete in a single slice
|
||||
|
@ -52,7 +52,7 @@ from allmydata.storage_client import (
|
||||
_StorageServer,
|
||||
)
|
||||
from .common import LoggingServiceParent, ShouldFailMixin
|
||||
from .common_py3 import FakeCanary
|
||||
from .common_util import FakeCanary
|
||||
|
||||
|
||||
class UtilTests(unittest.TestCase):
|
||||
|
@ -50,7 +50,7 @@ from allmydata.web.storage import (
|
||||
StorageStatusElement,
|
||||
remove_prefix
|
||||
)
|
||||
from .common_py3 import FakeCanary
|
||||
from .common_util import FakeCanary
|
||||
|
||||
def remove_tags(s):
|
||||
s = re.sub(br'<[^>]*>', b' ', s)
|
||||
|
@ -33,7 +33,7 @@ from .common import (
|
||||
from ..common import (
|
||||
SameProcessStreamEndpointAssigner,
|
||||
)
|
||||
from ..common_py3 import (
|
||||
from ..common_util import (
|
||||
FakeCanary,
|
||||
)
|
||||
from ..common_web import (
|
||||
|
Loading…
x
Reference in New Issue
Block a user