test: fix all pylint issues
This commit is contained in:
parent
7f3dbb2e2d
commit
57b5c7994e
15 changed files with 18 additions and 35 deletions
|
|
@ -258,16 +258,16 @@ def test_on_close(tempdir):
|
|||
|
||||
|
||||
@patch("os.open", side_effect=FileNotFoundError)
|
||||
def test_loop_handles_error_in_init(mocked_open):
|
||||
def test_loop_handles_error_in_init(mocked_open): # pylint: disable=unused-argument
|
||||
with pytest.raises(FileNotFoundError):
|
||||
lopo = loop.Loop(999)
|
||||
loop.Loop(999)
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.getuid() != 0, reason="root only")
|
||||
def test_loop_create_mknod():
|
||||
# tmpdir must be /var/tmp because /tmp is usually mounted with "nodev"
|
||||
with TemporaryDirectory(dir="/var/tmp") as tmpdir:
|
||||
with patch.object(loop, "DEV_PATH", new=tmpdir) as mocked_dev_path:
|
||||
with patch.object(loop, "DEV_PATH", new=tmpdir):
|
||||
lopo = loop.Loop(1337)
|
||||
assert lopo.devname == "loop1337"
|
||||
assert pathlib.Path(f"{tmpdir}/loop1337").is_block_device()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class TapeMonitor(osbuild.monitor.BaseMonitor):
|
|||
def begin(self, pipeline: osbuild.Pipeline):
|
||||
self.counter["begin"] += 1
|
||||
|
||||
def finish(self, result):
|
||||
def finish(self, results):
|
||||
self.counter["finish"] += 1
|
||||
self.output = self.logger.getvalue()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from osbuild.mounts import Mount
|
||||
from osbuild.meta import ModuleInfo
|
||||
|
||||
|
|
|
|||
|
|
@ -348,4 +348,3 @@ def test_object_export_preserves_override(tmp_path, object_store):
|
|||
assert expected_exported_path.exists()
|
||||
assert expected_exported_path.stat().st_uid == 0
|
||||
assert expected_exported_path.stat().st_gid == 0
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
#
|
||||
import os.path
|
||||
|
||||
import pytest
|
||||
|
||||
from osbuild.testutil import make_fake_input_tree
|
||||
|
||||
|
||||
|
|
@ -15,6 +13,6 @@ def test_make_fake_tree(tmp_path): # pylint: disable=unused-argument
|
|||
})
|
||||
assert os.path.isdir(fake_input_tree)
|
||||
assert os.path.exists(os.path.join(fake_input_tree, "fake-file-one"))
|
||||
assert open(os.path.join(fake_input_tree, "fake-file-one")).read() == "Some content"
|
||||
assert open(os.path.join(fake_input_tree, "fake-file-one"), encoding="utf8").read() == "Some content"
|
||||
assert os.path.exists(os.path.join(fake_input_tree, "second/fake-file-two"))
|
||||
assert open(os.path.join(fake_input_tree, "second/fake-file-two")).read() == "Second content"
|
||||
assert open(os.path.join(fake_input_tree, "second/fake-file-two"), encoding="utf").read() == "Second content"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
#
|
||||
# Tests for the 'osbuild.util.testutil' module.
|
||||
#
|
||||
import os.path
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
from osbuild.testutil.imports import import_module_from_path
|
||||
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ def test_calculate_space(tmpdir):
|
|||
os.makedirs(os.path.join(test_dir, "dir"))
|
||||
assert fscache.FsCache._calculate_space(test_dir) == du(test_dir)
|
||||
|
||||
with open(os.path.join(test_dir, "sparse-file"), "w") as f:
|
||||
with open(os.path.join(test_dir, "sparse-file"), "wb") as f:
|
||||
f.truncate(10*1024*1024)
|
||||
f.write("I'm not an empty file")
|
||||
f.write(b"I'm not an empty file")
|
||||
assert fscache.FsCache._calculate_space(test_dir) == du(test_dir)
|
||||
|
||||
|
||||
|
|
@ -429,9 +429,9 @@ 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)
|
||||
with cache.store("foo") as rpath:
|
||||
with cache.store("foo"):
|
||||
pass
|
||||
with cache.load("foo") as rpath:
|
||||
with cache.load("foo"):
|
||||
pass
|
||||
load_time1 = cache._last_used("foo")
|
||||
# would be nice to have a helper for this in cache
|
||||
|
|
@ -440,7 +440,7 @@ def test_cache_load_updates_last_used(tmpdir):
|
|||
mtime1 = os.stat(cache._path(obj_lock_path)).st_mtime
|
||||
assert load_time1 > 0
|
||||
sleep_for_fs()
|
||||
with cache.load("foo") as rpath:
|
||||
with cache.load("foo"):
|
||||
pass
|
||||
# load time is updated
|
||||
load_time2 = cache._last_used("foo")
|
||||
|
|
|
|||
|
|
@ -252,10 +252,10 @@ def test_libc_futimens_errcheck():
|
|||
def test_libc_futimes_works(tmpdir):
|
||||
libc = linux.Libc.default()
|
||||
stamp_file = os.path.join(tmpdir, "foo")
|
||||
with open(stamp_file, "w") as fp:
|
||||
fp.write("meep")
|
||||
with open(stamp_file, "wb") as fp:
|
||||
fp.write(b"meep")
|
||||
mtime1 = os.stat(stamp_file).st_mtime
|
||||
with open(stamp_file, "w") as fp:
|
||||
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),
|
||||
mtime=linux.c_timespec(tv_sec=0, tv_nsec=libc.UTIME_OMIT),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -25,7 +24,7 @@ def test_mount_guard_failure_msg(tmp_path):
|
|||
# This needs a proper refactor so that FileSystemMountService just uses
|
||||
# a common mount helper.
|
||||
class FakeFileSystemMountService(FileSystemMountService):
|
||||
def __init__(self, args=None):
|
||||
def __init__(self, args=None): # pylint: disable=super-init-not-called
|
||||
# override __init__ to make it testable
|
||||
pass
|
||||
def translate_options(self, options):
|
||||
|
|
@ -45,4 +44,3 @@ def test_osbuild_mount_failure_msg(tmp_path):
|
|||
}
|
||||
mnt_service.mount(args)
|
||||
assert "special device /dev/invalid-src does not exist" in str(e.value)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -212,10 +212,10 @@ def test_mount_with_partition(tmp_path):
|
|||
opts = {}
|
||||
# mount both partitions
|
||||
for i in range(1,3):
|
||||
mount = mounts.Mount(
|
||||
mount_opts = mounts.Mount(
|
||||
name=f"name-{i}", info=ext4_mod_info, device=dev,
|
||||
partition=i, target=f"/mnt-{i}", options=opts)
|
||||
mntmgr.mount(mount)
|
||||
mntmgr.mount(mount_opts)
|
||||
|
||||
# check that the both mounts actually happend
|
||||
output = subprocess.check_output(
|
||||
|
|
@ -227,4 +227,3 @@ def test_mount_with_partition(tmp_path):
|
|||
chld = lsblk_info["blockdevices"][0]["children"]
|
||||
assert chld[0]["mountpoints"] == [f"{mnt_base}/mnt-1"]
|
||||
assert chld[1]["mountpoints"] == [f"{mnt_base}/mnt-2"]
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
import json
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import json
|
|||
import os
|
||||
import socketserver
|
||||
import subprocess
|
||||
import tempfile
|
||||
import threading
|
||||
|
||||
import pytest
|
||||
|
|
@ -66,7 +65,7 @@ def can_setup_netns() -> bool:
|
|||
try:
|
||||
with netns():
|
||||
return True
|
||||
except BaseException: # pylint: disable=bare-except
|
||||
except BaseException: # pylint: disable=broad-exception-caught
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import contextlib
|
||||
import difflib
|
||||
import functools
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue