mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
conftest: remove dvc_repo, erepo, git, git_erepo
This commit is contained in:
+1
-78
@@ -2,12 +2,9 @@ import os
|
||||
|
||||
import mockssh
|
||||
import pytest
|
||||
from git import Repo
|
||||
from git.exc import GitCommandNotFound
|
||||
|
||||
from dvc.remote.ssh.connection import SSHConnection
|
||||
from dvc.repo import Repo as DvcRepo
|
||||
from .basic_env import TestDirFixture, TestDvcGitFixture, TestGitFixture
|
||||
from .basic_env import TestDirFixture
|
||||
from .dir_helpers import * # noqa
|
||||
|
||||
|
||||
@@ -42,38 +39,6 @@ def repo_dir():
|
||||
old_fixture.tearDown()
|
||||
|
||||
|
||||
# NOTE: this duplicates code from GitFixture,
|
||||
# would fix itself once class-based fixtures are removed
|
||||
@pytest.fixture
|
||||
def git(repo_dir):
|
||||
# NOTE: handles EAGAIN error on BSD systems (osx in our case).
|
||||
# Otherwise when running tests you might get this exception:
|
||||
#
|
||||
# GitCommandNotFound: Cmd('git') not found due to:
|
||||
# OSError('[Errno 35] Resource temporarily unavailable')
|
||||
retries = 5
|
||||
while True:
|
||||
try:
|
||||
git = Repo.init()
|
||||
break
|
||||
except GitCommandNotFound:
|
||||
retries -= 1
|
||||
if not retries:
|
||||
raise
|
||||
|
||||
try:
|
||||
git.index.add([repo_dir.CODE])
|
||||
git.index.commit("add code")
|
||||
yield git
|
||||
finally:
|
||||
git.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dvc_repo(repo_dir):
|
||||
yield DvcRepo.init(repo_dir._root_dir, no_scm=True)
|
||||
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
user = "user"
|
||||
@@ -98,51 +63,9 @@ def ssh(ssh_server):
|
||||
yield SSHConnection(**ssh_server.test_creds)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def erepo(repo_dir):
|
||||
repo = TestDvcGitFixture()
|
||||
repo.setUp()
|
||||
try:
|
||||
stage_foo = repo.dvc.add(repo.FOO)[0]
|
||||
stage_bar = repo.dvc.add(repo.BAR)[0]
|
||||
stage_data_dir = repo.dvc.add(repo.DATA_DIR)[0]
|
||||
repo.dvc.scm.add([stage_foo.path, stage_bar.path, stage_data_dir.path])
|
||||
repo.dvc.scm.commit("init repo")
|
||||
|
||||
repo.create("version", "master")
|
||||
repo.dvc.add("version")
|
||||
repo.dvc.scm.add([".gitignore", "version.dvc"])
|
||||
repo.dvc.scm.commit("master")
|
||||
|
||||
repo.dvc.scm.checkout("branch", create_new=True)
|
||||
os.unlink(os.path.join(repo.root_dir, "version"))
|
||||
repo.create("version", "branch")
|
||||
repo.dvc.add("version")
|
||||
repo.dvc.scm.add([".gitignore", "version.dvc"])
|
||||
repo.dvc.scm.commit("branch")
|
||||
|
||||
repo.dvc.scm.checkout("master")
|
||||
|
||||
repo.dvc.scm.close()
|
||||
repo.git.close()
|
||||
|
||||
os.chdir(repo._saved_dir)
|
||||
yield repo
|
||||
finally:
|
||||
repo.tearDown()
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def _close_pools():
|
||||
from dvc.remote.pool import close_pools
|
||||
|
||||
yield
|
||||
close_pools()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def git_erepo():
|
||||
repo = TestGitFixture()
|
||||
repo.setUp()
|
||||
yield repo
|
||||
repo.tearDown()
|
||||
|
||||
Reference in New Issue
Block a user