Fix confusing-with-statement pylint warnings (#119364)
This commit is contained in:
parent
1974ea4fdd
commit
e57bac6da8
3 changed files with 15 additions and 12 deletions
|
@ -519,16 +519,17 @@ def test_get_serial_by_id_no_dir() -> None:
|
|||
|
||||
def test_get_serial_by_id() -> None:
|
||||
"""Test serial by id conversion."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=True))
|
||||
p2 = patch("os.scandir")
|
||||
|
||||
def _realpath(path):
|
||||
if path is sentinel.matched_link:
|
||||
return sentinel.path
|
||||
return sentinel.serial_link_path
|
||||
|
||||
p3 = patch("os.path.realpath", side_effect=_realpath)
|
||||
with p1 as is_dir_mock, p2 as scan_mock, p3:
|
||||
with (
|
||||
patch("os.path.isdir", MagicMock(return_value=True)) as is_dir_mock,
|
||||
patch("os.scandir") as scan_mock,
|
||||
patch("os.path.realpath", side_effect=_realpath),
|
||||
):
|
||||
res = config_flow.get_serial_by_id(sentinel.path)
|
||||
assert res is sentinel.path
|
||||
assert is_dir_mock.call_count == 1
|
||||
|
|
|
@ -900,16 +900,17 @@ def test_get_serial_by_id_no_dir() -> None:
|
|||
|
||||
def test_get_serial_by_id() -> None:
|
||||
"""Test serial by id conversion."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=True))
|
||||
p2 = patch("os.scandir")
|
||||
|
||||
def _realpath(path):
|
||||
if path is sentinel.matched_link:
|
||||
return sentinel.path
|
||||
return sentinel.serial_link_path
|
||||
|
||||
p3 = patch("os.path.realpath", side_effect=_realpath)
|
||||
with p1 as is_dir_mock, p2 as scan_mock, p3:
|
||||
with (
|
||||
patch("os.path.isdir", MagicMock(return_value=True)) as is_dir_mock,
|
||||
patch("os.scandir") as scan_mock,
|
||||
patch("os.path.realpath", side_effect=_realpath),
|
||||
):
|
||||
res = config_flow.get_serial_by_id(sentinel.path)
|
||||
assert res is sentinel.path
|
||||
assert is_dir_mock.call_count == 1
|
||||
|
|
|
@ -771,16 +771,17 @@ def test_get_serial_by_id_no_dir() -> None:
|
|||
|
||||
def test_get_serial_by_id() -> None:
|
||||
"""Test serial by id conversion."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=True))
|
||||
p2 = patch("os.scandir")
|
||||
|
||||
def _realpath(path):
|
||||
if path is sentinel.matched_link:
|
||||
return sentinel.path
|
||||
return sentinel.serial_link_path
|
||||
|
||||
p3 = patch("os.path.realpath", side_effect=_realpath)
|
||||
with p1 as is_dir_mock, p2 as scan_mock, p3:
|
||||
with (
|
||||
patch("os.path.isdir", MagicMock(return_value=True)) as is_dir_mock,
|
||||
patch("os.scandir") as scan_mock,
|
||||
patch("os.path.realpath", side_effect=_realpath),
|
||||
):
|
||||
res = usb.get_serial_by_id(sentinel.path)
|
||||
assert res is sentinel.path
|
||||
assert is_dir_mock.call_count == 1
|
||||
|
|
Loading…
Add table
Reference in a new issue