test: fix autopep8 issues
This commit is contained in:
parent
530afa566f
commit
8c95bd9dd7
8 changed files with 21 additions and 19 deletions
|
|
@ -185,7 +185,7 @@ class TestFormatV1(unittest.TestCase):
|
|||
self.assertEqual(info.version, "1")
|
||||
self.assertEqual(info.module, fmt)
|
||||
|
||||
#pylint: disable=too-many-statements
|
||||
# pylint: disable=too-many-statements
|
||||
@unittest.skipUnless(test.TestBase.can_bind_mount(), "root-only")
|
||||
def test_format_output(self):
|
||||
"""Test that output formatting is as expected"""
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ def test_calculate_space(tmpdir):
|
|||
env = os.environ.copy()
|
||||
env["POSIXLY_CORRECT"] = "1"
|
||||
output = subprocess.check_output(["du", "-s", path_target], env=env, encoding="utf8")
|
||||
return int(output.split()[0].strip())*512
|
||||
return int(output.split()[0].strip()) * 512
|
||||
|
||||
test_dir = os.path.join(tmpdir, "dir")
|
||||
os.mkdir(test_dir)
|
||||
|
|
@ -67,7 +67,7 @@ def test_calculate_space(tmpdir):
|
|||
assert fscache.FsCache._calculate_space(test_dir) == du(test_dir)
|
||||
|
||||
with open(os.path.join(test_dir, "sparse-file"), "wb") as f:
|
||||
f.truncate(10*1024*1024)
|
||||
f.truncate(10 * 1024 * 1024)
|
||||
f.write(b"I'm not an empty file")
|
||||
assert fscache.FsCache._calculate_space(test_dir) == du(test_dir)
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ def test_basic(tmpdir):
|
|||
|
||||
cache = fscache.FsCache("osbuild-test-appid", tmpdir)
|
||||
with cache:
|
||||
cache.info = cache.info._replace(maximum_size=1024*1024)
|
||||
cache.info = cache.info._replace(maximum_size=1024 * 1024)
|
||||
|
||||
with cache.stage() as rpath:
|
||||
with open(os.path.join(tmpdir, rpath, "bar"), "x", encoding="utf8") as f:
|
||||
|
|
@ -418,6 +418,7 @@ def test_size_discard(tmpdir):
|
|||
with cache.load("foo") as rpath:
|
||||
pass
|
||||
|
||||
|
||||
def test_cache_last_used_noent(tmpdir):
|
||||
cache = fscache.FsCache("osbuild-test-appid", tmpdir)
|
||||
with pytest.raises(fscache.FsCache.MissError):
|
||||
|
|
@ -428,7 +429,7 @@ def test_cache_last_used_noent(tmpdir):
|
|||
def test_cache_load_updates_last_used(tmpdir):
|
||||
cache = fscache.FsCache("osbuild-test-appid", tmpdir)
|
||||
with cache:
|
||||
cache.info = cache.info._replace(maximum_size=1024*1024)
|
||||
cache.info = cache.info._replace(maximum_size=1024 * 1024)
|
||||
with cache.store("foo"):
|
||||
pass
|
||||
with cache.load("foo"):
|
||||
|
|
@ -473,7 +474,7 @@ def test_cache_full_behavior(tmp_path):
|
|||
with cache.store("o1") as rpath:
|
||||
rpath_f1 = os.path.join(tmp_path, rpath, "f1")
|
||||
with open(rpath_f1, "wb") as fp:
|
||||
fp.write(b'a'*64*1024)
|
||||
fp.write(b'a' * 64 * 1024)
|
||||
assert cache._calculate_space(tmp_path) > 64 * 1024
|
||||
assert cache._calculate_space(tmp_path) < 128 * 1024
|
||||
with cache.load("o1") as o:
|
||||
|
|
@ -482,7 +483,7 @@ def test_cache_full_behavior(tmp_path):
|
|||
with cache.store("o2") as rpath:
|
||||
rpath_f2 = os.path.join(tmp_path, rpath, "f2")
|
||||
with open(rpath_f2, "wb") as fp:
|
||||
fp.write(b'b'*64*1024)
|
||||
fp.write(b'b' * 64 * 1024)
|
||||
assert cache._calculate_space(tmp_path) > 128 * 1024
|
||||
assert cache._calculate_space(tmp_path) < 192 * 1024
|
||||
with cache.load("o2") as o:
|
||||
|
|
@ -491,7 +492,7 @@ def test_cache_full_behavior(tmp_path):
|
|||
with cache.store("o3") as rpath:
|
||||
rpath_f3 = os.path.join(tmp_path, rpath, "f3")
|
||||
with open(rpath_f3, "wb") as fp:
|
||||
fp.write(b'b'*128*1024)
|
||||
fp.write(b'b' * 128 * 1024)
|
||||
assert cache._calculate_space(tmp_path) > 128 * 1024
|
||||
assert cache._calculate_space(tmp_path) < 192 * 1024
|
||||
with pytest.raises(fscache.FsCache.MissError):
|
||||
|
|
|
|||
|
|
@ -274,4 +274,4 @@ def test_atomics_nfs(nfsmnts):
|
|||
# NFS mounts with no shared caches. Unfortunately, this keeps
|
||||
# triggering kernel-oopses, so we disable the tests for now:
|
||||
|
||||
#_test_atomics_with(nfsmnts[0], nfsmnts[1])
|
||||
# _test_atomics_with(nfsmnts[0], nfsmnts[1])
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ def test_libc_futimes_works(tmpdir):
|
|||
mtime1 = os.stat(stamp_file).st_mtime
|
||||
with open(stamp_file, "wb") as fp:
|
||||
libc.futimens(fp.fileno(), ctypes.byref(linux.c_timespec_times2(
|
||||
atime=linux.c_timespec(tv_sec=3, tv_nsec=300*1000*1000),
|
||||
atime=linux.c_timespec(tv_sec=3, tv_nsec=300 * 1000 * 1000),
|
||||
mtime=linux.c_timespec(tv_sec=0, tv_nsec=libc.UTIME_OMIT),
|
||||
)))
|
||||
assert os.stat(stamp_file).st_atime == 3.3
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class FakeFileSystemMountService(FileSystemMountService):
|
|||
def __init__(self, args=None): # pylint: disable=super-init-not-called
|
||||
# override __init__ to make it testable
|
||||
pass
|
||||
|
||||
def translate_options(self, options):
|
||||
return options
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class TestPasswdLike(unittest.TestCase):
|
|||
with open(os.path.join(tmpdir, "result"), "r", encoding="utf8") as f:
|
||||
self.assertEqual(sorted(f.readlines()), sorted(result_file_lines))
|
||||
|
||||
#pylint: disable=no-self-use
|
||||
# pylint: disable=no-self-use
|
||||
def test_subids_cfg(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ def create_image_with_partitions(tmp_path):
|
|||
tree.mkdir()
|
||||
img = tree / "disk.img"
|
||||
with img.open("w") as fp:
|
||||
fp.truncate(20*1024*1024)
|
||||
fp.truncate(20 * 1024 * 1024)
|
||||
for cmd in [
|
||||
["parted", "--script", img, "mklabel", "msdos"],
|
||||
["parted", "--script", img, "mkpart", "primary", "ext4", "1MiB", "10Mib"],
|
||||
|
|
@ -210,7 +210,7 @@ def test_mount_with_partition(tmp_path):
|
|||
mntmgr = mounts.MountManager(devmgr, mnt_base)
|
||||
opts = {}
|
||||
# mount both partitions
|
||||
for i in range(1,3):
|
||||
for i in range(1, 3):
|
||||
mount_opts = mounts.Mount(
|
||||
name=f"name-{i}", info=ext4_mod_info, device=dev,
|
||||
partition=i, target=f"/mnt-{i}", options=opts)
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ class TestStages(test.TestBase):
|
|||
raise_assertion('length of differences different')
|
||||
|
||||
for (file1, differences1), (file2, differences2) in \
|
||||
zip(tree_diff1['differences'].items(), tree_diff2['differences'].items()):
|
||||
zip(tree_diff1['differences'].items(), tree_diff2['differences'].items()):
|
||||
|
||||
if file1 != file2:
|
||||
raise_assertion(f"filename different: {file1}, {file2}")
|
||||
|
|
@ -185,18 +185,18 @@ class TestStages(test.TestBase):
|
|||
raise_assertion("length of file differences different")
|
||||
|
||||
for (difference1_kind, difference1_values), (difference2_kind, difference2_values) in \
|
||||
zip(differences1.items(), differences2.items()):
|
||||
zip(differences1.items(), differences2.items()):
|
||||
if difference1_kind != difference2_kind:
|
||||
raise_assertion(f"different difference kinds: {difference1_kind}, {difference2_kind}")
|
||||
|
||||
if difference1_values[0] is not None \
|
||||
and difference2_values[0] is not None \
|
||||
and difference1_values[0] != difference2_values[0]:
|
||||
and difference2_values[0] is not None \
|
||||
and difference1_values[0] != difference2_values[0]:
|
||||
raise_assertion(f"before values are different: {difference1_values[0]}, {difference2_values[0]}")
|
||||
|
||||
if difference1_values[1] is not None \
|
||||
and difference2_values[1] is not None \
|
||||
and difference1_values[1] != difference2_values[1]:
|
||||
and difference2_values[1] is not None \
|
||||
and difference1_values[1] != difference2_values[1]:
|
||||
raise_assertion(f"after values are different: {difference1_values[1]}, {difference2_values[1]}")
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue