Rev 27: Refactor tests into a helper. in lp:~jameinel/+junk/file_locking
John Arbash Meinel
john at arbash-meinel.com
Mon Sep 21 22:10:50 BST 2009
At lp:~jameinel/+junk/file_locking
------------------------------------------------------------
revno: 27
revision-id: john at arbash-meinel.com-20090921211042-3jviz29epgcs2z13
parent: john at arbash-meinel.com-20090921210906-ryhj0sqlvkt19lrl
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: file_locking
timestamp: Mon 2009-09-21 16:10:42 -0500
message:
Refactor tests into a helper.
-------------- next part --------------
=== modified file 'tests/test_file_lock.py'
--- a/tests/test_file_lock.py 2009-09-21 21:09:06 +0000
+++ b/tests/test_file_lock.py 2009-09-21 21:10:42 +0000
@@ -354,6 +354,11 @@
trans = self.get_transport('')
return file_lock.FileLockLogger.initialize(trans, path)
+ def make_locking_info(self):
+ logger = self.make_logger()
+ li = file_lock.FileLockingInfo(['file-id-1', 'file-id-2'], {}, logger)
+ return li, logger
+
def test_init(self):
trans = self.get_transport('')
logger = self.make_logger()
@@ -365,8 +370,7 @@
'host: .*\n', flags=re.MULTILINE)
def test_lock_created(self):
- logger = self.make_logger()
- li = file_lock.FileLockingInfo(['file-id-1', 'file-id-2'], {}, logger)
+ li, logger = self.make_locking_info()
info = li.create_lock('file-id-1')
logger.flush()
self.assertContainsRe(logger._transport.get_bytes(logger._filename),
@@ -382,9 +386,7 @@
'.*\n', flags=re.MULTILINE)
def test_lock_removed(self):
- logger = self.make_logger()
- li = file_lock.FileLockingInfo(['file-id-1', 'file-id-2'], {},
- logger)
+ li, logger = self.make_locking_info()
info = li.create_lock('file-id-1')
li.remove_lock('file-id-1')
logger.flush()
@@ -403,9 +405,7 @@
flags=re.MULTILINE)
def test_track_id(self):
- logger = self.make_logger()
- li = file_lock.FileLockingInfo(['file-id-1', 'file-id-2'], {},
- logger)
+ li, logger = self.make_locking_info()
li.track('file-id-3')
logger.flush()
self.assertContainsRe(logger._transport.get_bytes(logger._filename),
@@ -420,9 +420,7 @@
flags=re.MULTILINE)
def test_stop_tracking(self):
- logger = self.make_logger()
- li = file_lock.FileLockingInfo(['file-id-1', 'file-id-2'], {},
- logger)
+ li, logger = self.make_locking_info()
li.stop_tracking('file-id-2')
logger.flush()
self.assertContainsRe(logger._transport.get_bytes(logger._filename),
More information about the bazaar-commits
mailing list