Exemple #1
0
def test_is_release():
    with mock.patch.object(dvc.version.subprocess, "check_output") as m:
        m.side_effect = subprocess.CalledProcessError(1, "cmd")
        ret = dvc.version._is_release(None, dvc.version._BASE_VERSION)
        assert ret is False

        m.side_effect = None
        m.return_value = cast_bytes(dvc.version._BASE_VERSION)
        ret = dvc.version._is_release(None, dvc.version._BASE_VERSION)
        assert ret

        m.return_value = cast_bytes("630d1741c2d5dd89a3176bd15b63121b905d35c9")
        ret = dvc.version._is_release(None, dvc.version._BASE_VERSION)
        assert ret is False
Exemple #2
0
    def test_ignore_in_child_dir_unicode(self):
        ignore_file = os.path.join(self.dvc.root_dir, DvcIgnore.DVCIGNORE_FILE)
        with open(ignore_file, "wb") as fobj:
            fobj.write(cast_bytes(self.UNICODE, "utf-8"))

        forbidden_path = os.path.join(self.dvc.root_dir, self.UNICODE)
        all_paths = self._get_all_paths()

        self.assertNotIn(forbidden_path, all_paths)
Exemple #3
0
    def get_match(self, abs_path):
        relative_path = relpath(abs_path, self.dirname)
        if os.name == "nt":
            relative_path = relative_path.replace("\\", "/")
        relative_path = cast_bytes(relative_path, "utf-8")

        for pattern in self.patterns:
            if match_pattern(relative_path,
                             pattern) and self._no_negate_pattern_matches(
                                 relative_path):
                return (abs_path, pattern, self.ignore_file_path)
        return None
Exemple #4
0
def read_pattern(p):
    return cast_bytes(p, "utf-8")