Skip to content

Commit

Permalink
Fix blockers list in rwlock error message (iterative#3285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Suor authored Feb 6, 2020
1 parent 509ce3e commit e28371f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions dvc/rwlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_rwlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e28371f

Please sign in to comment.