mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
api: open: Raise ValueError if rev is used in wrong mode.
Closes #7405 Co-authored-by: Peter Rowlands (변기호) <[email protected]>
This commit is contained in:
co-authored by
Peter Rowlands
parent
15e10a1d81
commit
1663b97eaa
@@ -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
|
||||
Reference in New Issue
Block a user