forked from iterative/dvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: open: Raise ValueError if rev is used in wrong mode.
Closes iterative#7405 Co-authored-by: Peter Rowlands (변기호) <[email protected]>
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
from dvc import api | ||
|
||
|
||
def test_open_raises_error_if_no_context(tmp_dir, dvc): | ||
tmp_dir.dvc_gen("foo", "foo-text") | ||
|
||
with pytest.raises( | ||
AttributeError, match="should be used in a with statement." | ||
): | ||
fd = api.open("foo") | ||
fd.read() | ||
|
||
|
||
def test_open_rev_raises_error_on_wrong_mode(tmp_dir, dvc): | ||
tmp_dir.dvc_gen("foo", "foo-text") | ||
|
||
with pytest.raises(ValueError, match="Only reading `mode` is supported."): | ||
with api.open("foo", mode="w"): | ||
pass |