1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-27 10:18:12 +00:00

Merge pull request #6157 from hexagonrecursion/ununit

Refactor: remove assert_true (master)
This commit is contained in:
TW 2022-01-29 23:19:11 +01:00 committed by GitHub
commit a65f298477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 14 deletions

View file

@ -164,7 +164,6 @@ class BaseTestCase(unittest.TestCase):
assert_not_in = unittest.TestCase.assertNotIn
assert_equal = unittest.TestCase.assertEqual
assert_not_equal = unittest.TestCase.assertNotEqual
assert_true = unittest.TestCase.assertTrue
if raises:
assert_raises = staticmethod(raises)
@ -173,9 +172,9 @@ class BaseTestCase(unittest.TestCase):
@contextmanager
def assert_creates_file(self, path):
self.assert_true(not os.path.exists(path), '{} should not exist'.format(path))
assert not os.path.exists(path), '{} should not exist'.format(path)
yield
self.assert_true(os.path.exists(path), '{} should exist'.format(path))
assert os.path.exists(path), '{} should exist'.format(path)
def assert_dirs_equal(self, dir1, dir2, **kwargs):
diff = filecmp.dircmp(dir1, dir2)

View file

@ -125,11 +125,11 @@ def test_partial(self):
chunks.flush(flush=False)
# the code is expected to leave the last partial chunk in the buffer
self.assert_equal(len(chunks.chunks), 3)
self.assert_true(chunks.buffer.tell() > 0)
assert chunks.buffer.tell() > 0
# now really flush
chunks.flush(flush=True)
self.assert_equal(len(chunks.chunks), 4)
self.assert_true(chunks.buffer.tell() == 0)
assert chunks.buffer.tell() == 0
unpacker = msgpack.Unpacker()
for id in chunks.chunks:
unpacker.feed(cache.objects[id])

View file

@ -628,7 +628,7 @@ def is_sparse(fn, total_size, hole_size):
self.assert_equal(fd.read(hole_size), b'\0' * hole_size)
self.assert_equal(fd.read(len(content)), content)
self.assert_equal(fd.read(hole_size), b'\0' * hole_size)
self.assert_true(is_sparse(filename, total_size, hole_size))
assert is_sparse(filename, total_size, hole_size)
def test_unusual_filenames(self):
filenames = ['normal', 'with some blanks', '(with_parens)', ]
@ -787,7 +787,7 @@ def test_strip_components(self):
self.cmd('create', self.repository_location + '::test', 'input')
with changedir('output'):
self.cmd('extract', self.repository_location + '::test', '--strip-components', '3')
self.assert_true(not os.path.exists('file'))
assert not os.path.exists('file')
with self.assert_creates_file('file'):
self.cmd('extract', self.repository_location + '::test', '--strip-components', '2')
with self.assert_creates_file('dir/file'):
@ -3928,16 +3928,16 @@ def test_remote_repo_strip_components_doesnt_leak(self):
marker = 'cached responses left in RemoteRepository'
with changedir('output'):
res = self.cmd('extract', "--debug", self.repository_location + '::test', '--strip-components', '3')
self.assert_true(marker not in res)
assert marker not in res
with self.assert_creates_file('file'):
res = self.cmd('extract', "--debug", self.repository_location + '::test', '--strip-components', '2')
self.assert_true(marker not in res)
assert marker not in res
with self.assert_creates_file('dir/file'):
res = self.cmd('extract', "--debug", self.repository_location + '::test', '--strip-components', '1')
self.assert_true(marker not in res)
assert marker not in res
with self.assert_creates_file('input/dir/file'):
res = self.cmd('extract', "--debug", self.repository_location + '::test', '--strip-components', '0')
self.assert_true(marker not in res)
assert marker not in res
class ArchiverCorruptionTestCase(ArchiverTestCaseBase):

View file

@ -89,7 +89,7 @@ def test_resize(self):
for x in range(n):
idx[H(x)] = x, x
idx.write(filepath)
self.assert_true(initial_size < os.path.getsize(filepath))
assert initial_size < os.path.getsize(filepath)
for x in range(n):
del idx[H(x)]
self.assert_equal(len(idx), 0)

View file

@ -841,7 +841,7 @@ def test_hints_persistence(self):
def test_hints_behaviour(self):
self.repository.put(H(0), b'data')
self.assert_equal(self.repository.shadow_index, {})
self.assert_true(len(self.repository.compact) == 0)
assert len(self.repository.compact) == 0
self.repository.delete(H(0))
self.repository.commit(compact=False)
# now there should be an entry for H(0) in shadow_index

View file

@ -62,7 +62,7 @@ def test_listxattr_buffer_growth(self):
setxattr(tmp_fn, key, b'x')
got_keys = listxattr(tmp_fn)
self.assert_equal_se(got_keys, keys)
self.assert_true(len(buffer) > 64)
assert len(buffer) > 64
def test_getxattr_buffer_growth(self):
tmp_fn = os.fsencode(self.tmpfile.name)