From 8829a37919d07305777fb56176c1379397f6f676 Mon Sep 17 00:00:00 2001 From: Alexander Schepanovski Date: Thu, 6 Feb 2020 20:44:15 +0700 Subject: [PATCH] Fix blockers list in rwlock error message --- dvc/rwlock.py | 5 +++-- tests/unit/test_rwlock.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dvc/rwlock.py b/dvc/rwlock.py index c9d15eae23..6b1d4de14f 100644 --- a/dvc/rwlock.py +++ b/dvc/rwlock.py @@ -66,10 +66,11 @@ def _infos_to_str(infos): def _check_blockers(lock, info, *, mode, waiters): for path_info in waiters: blockers = [ - info + blocker for path, infos in lock[mode].items() if path_info.overlaps(path) - if info not in (infos if type(infos) is list else [infos]) + for blocker in (infos if isinstance(infos, list) else [infos]) + if blocker != info ] if not blockers: diff --git a/tests/unit/test_rwlock.py b/tests/unit/test_rwlock.py index f44e0303f6..4bb3f1969a 100644 --- a/tests/unit/test_rwlock.py +++ b/tests/unit/test_rwlock.py @@ -62,12 +62,12 @@ def test_rwlock_subdirs(tmp_path): subfoo = PathInfo("foo/subfoo") with rwlock(path, "cmd1", [foo], []): - with pytest.raises(LockError): + with pytest.raises(LockError, match=r"subfoo(.|\n)*cmd1"): with rwlock(path, "cmd2", [], [subfoo]): pass with rwlock(path, "cmd1", [], [subfoo]): - with pytest.raises(LockError): + with pytest.raises(LockError, match=r"'foo'(.|\n)*cmd1"): with rwlock(path, "cmd2", [foo], []): pass