Revert other tests and test only glob exception.

This commit is contained in:
Karthikeyan Singaravelan
2022-05-11 18:37:09 +03:00
committed by Ruslan Kuprieiev
parent fb36db450f
commit b8d738220d
5 changed files with 15 additions and 26 deletions
-6
View File
@@ -349,9 +349,3 @@ class CircularImportError(DvcException):
class PrettyDvcException(DvcException):
def __pretty_exc__(self, **kwargs):
"""Print prettier exception message."""
class GlobDoesNotMatchError(DvcException):
def __init__(self, glob):
msg = f"Glob {glob} has no matches."
super().__init__(msg)
+3 -2
View File
@@ -476,7 +476,7 @@ def is_exec(mode):
def glob_targets(targets, glob=True, recursive=True):
from dvc.exceptions import GlobDoesNotMatchError
from ..exceptions import DvcException
if not glob:
return targets
@@ -490,7 +490,8 @@ def glob_targets(targets, glob=True, recursive=True):
]
if not results:
raise GlobDoesNotMatchError(targets)
msg = f"Glob {targets} has no matches."
raise DvcException(msg)
return results
-6
View File
@@ -16,7 +16,6 @@ from dvc.data.db import ODBManager
from dvc.dvcfile import DVC_FILE_SUFFIX
from dvc.exceptions import (
DvcException,
GlobDoesNotMatchError,
InvalidArgumentError,
OutputDuplicationError,
OverlappingOutputPathsError,
@@ -293,11 +292,6 @@ def test_add_filtered_files_in_dir(
assert stage.outs[0].def_path in expected_def_paths
def test_add_glob_no_result_exception(dvc):
with pytest.raises(GlobDoesNotMatchError):
dvc.add(["invalid*"], glob=True)
class TestAddExternal(TestAdd):
@pytest.fixture
def hash_name(self):
-12
View File
@@ -8,7 +8,6 @@ from flaky.flaky_decorator import flaky
import dvc as dvc_module
from dvc.cli import main
from dvc.data.db.local import LocalObjectDB
from dvc.exceptions import GlobDoesNotMatchError
from dvc.external_repo import clean_repos
from dvc.objects.db import ObjectDB
from dvc.stage.exceptions import StageNotFound
@@ -571,14 +570,3 @@ def test_target_remote(tmp_dir, dvc, make_remote):
"6b18131dc289fd37006705affe961ef8.dir",
"b8a9f715dbb64fd5c56e7783c6820a61",
}
def test_push_pull_glob_no_match(
tmp_dir,
dvc,
):
with pytest.raises(GlobDoesNotMatchError):
dvc.push(targets="b*", glob=True)
with pytest.raises(GlobDoesNotMatchError):
dvc.pull(targets="b*", glob=True)
+12
View File
@@ -1,4 +1,9 @@
import re
import pytest
from dvc import utils
from dvc.exceptions import DvcException
from dvc.fs.local import LocalFileSystem
@@ -42,3 +47,10 @@ def test_boxify():
)
assert expected == utils.boxify("message")
def test_glob_no_match():
with pytest.raises(
DvcException, match=re.escape("Glob ['invalid*'] has no matches.")
):
utils.glob_targets(["invalid*"], glob=True)