mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.12.12 → v0.13.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.12...v0.13.0) * fix ruff errors --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
26 lines
560 B
Python
26 lines
560 B
Python
import re
|
|
|
|
import pytest
|
|
|
|
from dvc import api
|
|
|
|
|
|
def test_open_raises_error_if_no_context(tmp_dir, dvc):
|
|
tmp_dir.dvc_gen("foo", "foo-text")
|
|
|
|
fd = api.open("foo")
|
|
with pytest.raises(
|
|
AttributeError, match=re.escape("should be used in a with statement.")
|
|
):
|
|
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=re.escape("Only reading `mode` is supported.")
|
|
):
|
|
with api.open("foo", mode="w"):
|
|
pass
|