@@ -50,7 +50,7 @@ def test_package(host, docker_image):
5050 }[docker_image ]
5151 if release is None :
5252 with pytest .raises (NotImplementedError ):
53- ssh .release
53+ ssh .release # noqa: B018
5454 else :
5555 assert release in ssh .release
5656
@@ -66,7 +66,7 @@ def test_held_package(host):
6666def test_rpmdb_corrupted (host ):
6767 host .check_output ("dd if=/dev/zero of=/var/lib/rpm/rpmdb.sqlite bs=1024 count=1" )
6868 with pytest .raises (RuntimeError ) as excinfo :
69- host .package ("zsh" ).is_installed
69+ host .package ("zsh" ).is_installed # noqa: B018
7070 assert (
7171 "Could not check if RPM package 'zsh' is installed. error: sqlite failure:"
7272 ) in str (excinfo .value )
@@ -82,7 +82,7 @@ def test_non_default_package_tool(host):
8282@pytest .mark .destructive
8383def test_uninstalled_package_version (host ):
8484 with pytest .raises (AssertionError ) as excinfo :
85- host .package ("zsh" ).version
85+ host .package ("zsh" ).version # noqa: B018
8686 assert (
8787 "The package zsh is not installed, dpkg-query output: unknown ok not-installed"
8888 in str (excinfo .value )
@@ -91,7 +91,7 @@ def test_uninstalled_package_version(host):
9191 host .check_output ("apt-get -y remove sudo" )
9292 assert not host .package ("sudo" ).is_installed
9393 with pytest .raises (AssertionError ) as excinfo :
94- host .package ("sudo" ).version
94+ host .package ("sudo" ).version # noqa: B018
9595 assert (
9696 "The package sudo is not installed, dpkg-query output: "
9797 "deinstall ok config-files 1.9."
@@ -114,11 +114,7 @@ def test_systeminfo(host, docker_image):
114114
115115@all_images
116116def test_ssh_service (host , docker_image ):
117- if docker_image == "rockylinux9" :
118- name = "sshd"
119- else :
120- name = "ssh"
121-
117+ name = "sshd" if docker_image == "rockylinux9" else "ssh"
122118 ssh = host .service (name )
123119 # wait at max 10 seconds for ssh is running
124120 for _ in range (10 ):
@@ -196,7 +192,7 @@ def test_socket(host):
196192
197193 assert not host .socket ("tcp://4242" ).is_listening
198194
199- if not host .backend .get_connection_type () = = "docker" :
195+ if host .backend .get_connection_type () ! = "docker" :
200196 # FIXME
201197 for spec in (
202198 "tcp://22" ,
@@ -324,7 +320,7 @@ def test_file(host):
324320 assert link .linked_to == "/d/f"
325321 assert link .linked_to == f
326322 assert f == host .file ("/d/f" )
327- assert not d = = f
323+ assert d ! = f
328324
329325 host .check_output ("ln /d/f /d/h" )
330326 hardlink = host .file ("/d/h" )
@@ -334,7 +330,7 @@ def test_file(host):
334330 assert isinstance (f .inode , int )
335331 assert hardlink .inode == f .inode
336332 assert f == host .file ("/d/f" )
337- assert not d = = f
333+ assert d ! = f
338334
339335 host .check_output ("rm -f /d/p && mkfifo /d/p" )
340336 assert host .file ("/d/p" ).is_pipe
@@ -516,7 +512,7 @@ def test_supervisor(host, supervisorctl_path, supervisorctl_conf):
516512 host .run ("service supervisor stop" )
517513 assert not host .service ("supervisor" ).is_running
518514 with pytest .raises (RuntimeError ) as excinfo :
519- host .supervisor (
515+ host .supervisor ( # noqa: B018
520516 "tail" ,
521517 supervisorctl_path = supervisorctl_path ,
522518 supervisorctl_conf = supervisorctl_conf ,
@@ -551,9 +547,9 @@ def test_sudo_from_root(host):
551547
552548def test_sudo_fail_from_root (host ):
553549 assert host .user ().name == "root"
554- with pytest . raises ( AssertionError ) as exc :
555- with host .sudo ( "unprivileged" ):
556- assert host . user (). name == "unprivileged"
550+ with host . sudo ( "unprivileged" ) :
551+ assert host .user (). name == "unprivileged"
552+ with pytest . raises ( AssertionError ) as exc :
557553 host .check_output ("ls /root/invalid" )
558554 assert str (exc .value ).startswith ("Unexpected exit code" )
559555 with host .sudo ():
0 commit comments