mirror of https://github.com/borgbackup/borg.git
commit
dda78d1abd
|
@ -1,5 +1,14 @@
|
|||
try:
|
||||
# Only available in python 3.3+
|
||||
from unittest.mock import *
|
||||
except ImportError:
|
||||
from mock import *
|
||||
"""
|
||||
Mocking
|
||||
|
||||
Note: unittest.mock is broken on at least python 3.3.6 and 3.4.0.
|
||||
it silently ignores mistyped method names starting with assert_...,
|
||||
does nothing and just succeeds.
|
||||
The issue was fixed in the separately distributed "mock" lib, you
|
||||
get an AttributeError there. So, always use that one!
|
||||
|
||||
Details:
|
||||
|
||||
http://engineeringblog.yelp.com/2015/02/assert_called_once-threat-or-menace.html
|
||||
"""
|
||||
from mock import *
|
||||
|
|
|
@ -159,7 +159,7 @@ class RepositoryCommitTestCase(RepositoryTestCaseBase):
|
|||
with patch.object(UpgradableLock, 'upgrade', side_effect=UpgradableLock.WriteLockFailed) as upgrade:
|
||||
self.reopen()
|
||||
self.assert_raises(UpgradableLock.WriteLockFailed, lambda: len(self.repository))
|
||||
upgrade.assert_called_once()
|
||||
upgrade.assert_called_once_with()
|
||||
|
||||
def test_crash_before_write_index(self):
|
||||
self.add_keys()
|
||||
|
@ -309,7 +309,7 @@ class RepositoryCheckTestCase(RepositoryTestCaseBase):
|
|||
# Simulate a crash before compact
|
||||
with patch.object(Repository, 'compact_segments') as compact:
|
||||
self.repository.commit()
|
||||
compact.assert_called_once()
|
||||
compact.assert_called_once_with()
|
||||
self.reopen()
|
||||
self.check(repair=True)
|
||||
self.assert_equal(self.repository.get(bytes(32)), b'data2')
|
||||
|
@ -328,3 +328,7 @@ class RemoteRepositoryCheckTestCase(RepositoryCheckTestCase):
|
|||
|
||||
def open(self, create=False):
|
||||
return RemoteRepository(Location('__testsuite__:' + os.path.join(self.tmppath, 'repository')), create=create)
|
||||
|
||||
def test_crash_before_compact(self):
|
||||
# skip this test, we can't mock-patch a Repository class in another process!
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue