mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 23:09:48 +01:00
* Run CI for Python3.9, skips hdfs tests for 3.9 Also, `dvc[hdfs]` install will be a no-op till we have a pyarrow wheel for 3.9. Note that this does not add an entry to the classifier claiming it supports 3.9, that will be added when 3.9 gets released (or, wait for pyarrow to be released). * Skip HDFS related tests on Python3.9 Also, fix the python version regex for `3.9.0b5` like versions. * Exclude python3.9 for Windows libxml does not have wheels for Python39. We do compile them on Linux and Mac * Update tests/unit/test_info.py * Use realpath for gitignore Windows tests for Python3.8 was failing intermittently. Note: Also removed the realpath wrap around self.root_dir as it's already a realpath when `Git` is instantiated. Co-authored-by: Ruslan Kuprieiev <[email protected]>
81 lines
2.4 KiB
Python
81 lines
2.4 KiB
Python
import os
|
|
import re
|
|
import shutil
|
|
|
|
import pytest
|
|
|
|
from dvc.info import get_dvc_info, psutil
|
|
|
|
# Python's version is in the shape of:
|
|
# <major>.<minor>.<patch>[{a|b|rc}N][.postN][.devN]
|
|
# `patch` is more than enough for the tests.
|
|
# Refer PEP-0440 for complete regex just in-case.
|
|
PYTHON_VERSION_REGEX = r"Python \d\.\d+\.\d+\S*"
|
|
|
|
|
|
@pytest.mark.parametrize("scm_init", [True, False])
|
|
def test_info_in_repo(scm_init, tmp_dir):
|
|
tmp_dir.init(scm=scm_init, dvc=True)
|
|
# Create `.dvc/cache`, that is needed to check supported link types.
|
|
os.mkdir(tmp_dir.dvc.cache.local.cache_dir)
|
|
|
|
dvc_info = get_dvc_info()
|
|
|
|
assert re.search(r"DVC version: \d+\.\d+\.\d+.*", dvc_info)
|
|
assert re.search(f"Platform: {PYTHON_VERSION_REGEX} on .*", dvc_info)
|
|
assert re.search(r"Supports: .*", dvc_info)
|
|
assert re.search(r"Cache types: .*", dvc_info)
|
|
|
|
if scm_init:
|
|
assert "Repo: dvc, git" in dvc_info
|
|
else:
|
|
assert "Repo: dvc (no_scm)" in dvc_info
|
|
|
|
|
|
def test_info_in_subdir(tmp_dir, scm, caplog):
|
|
dvc_subdir = tmp_dir / "subdir"
|
|
dvc_subdir.mkdir()
|
|
|
|
with dvc_subdir.chdir():
|
|
dvc_subdir.init(scm=False, dvc=True)
|
|
with dvc_subdir.dvc.config.edit() as conf:
|
|
del conf["core"]["no_scm"]
|
|
|
|
dvc_info = get_dvc_info()
|
|
|
|
assert "Repo: dvc (subdir), git" in dvc_info
|
|
|
|
|
|
def test_info_in_broken_git_repo(tmp_dir, dvc, scm, caplog):
|
|
shutil.rmtree(dvc.scm.dir)
|
|
dvc_info = get_dvc_info()
|
|
|
|
assert "Repo: dvc, git (broken)" in dvc_info
|
|
|
|
|
|
@pytest.mark.skipif(psutil is None, reason="No psutil.")
|
|
def test_fs_info_in_repo(tmp_dir, dvc, caplog):
|
|
os.mkdir(dvc.cache.local.cache_dir)
|
|
dvc_info = get_dvc_info()
|
|
|
|
assert re.search(r"Cache directory: .* on .*", dvc_info)
|
|
assert re.search(r"Workspace directory: .* on .*", dvc_info)
|
|
|
|
|
|
def test_info_outside_of_repo(tmp_dir, caplog):
|
|
dvc_info = get_dvc_info()
|
|
|
|
assert re.search(r"DVC version: \d+\.\d+\.\d+.*", dvc_info)
|
|
assert re.search(f"Platform: {PYTHON_VERSION_REGEX} on .*", dvc_info)
|
|
assert re.search(r"Supports: .*", dvc_info)
|
|
assert not re.search(r"Cache types: .*", dvc_info)
|
|
assert "Repo:" not in dvc_info
|
|
|
|
|
|
@pytest.mark.skipif(psutil is None, reason="No psutil.")
|
|
def test_fs_info_outside_of_repo(tmp_dir, caplog):
|
|
dvc_info = get_dvc_info()
|
|
assert re.search(r"DVC version: \d+\.\d+\.\d+.*", dvc_info)
|
|
assert re.search(f"Platform: {PYTHON_VERSION_REGEX} on .*", dvc_info)
|
|
assert re.search(r"Supports: .*", dvc_info)
|