Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move fixtures to a public module #37

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 1 addition & 59 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,59 +1 @@
import pathlib

import pytest

import jaraco.path
from jaraco import vcs


@pytest.fixture(autouse=True)
def _isolate_home(tmp_home_dir):
"""Isolate the tests from a developer's VCS config."""


def _ensure_present(mgr):
try:
mgr.version()
except Exception:
pytest.skip()


@pytest.fixture
def temp_work_dir(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
return tmp_path


source_tree = dict(
bar=dict(
baz="",
),
)


@pytest.fixture
def hg_repo(temp_work_dir):
repo = vcs.Mercurial()
_ensure_present(repo)
repo._invoke('init', '.')
jaraco.path.build(source_tree)
repo._invoke('addremove')
repo._invoke('ci', '-m', 'committed')
pathlib.Path('bar/baz').write_text('content', encoding='utf-8')
repo._invoke('ci', '-m', 'added content')
return repo


@pytest.fixture
def git_repo(temp_work_dir):
repo = vcs.Git()
_ensure_present(repo)
repo._invoke('init')
repo._invoke('config', 'user.email', 'vip@example.com')
repo._invoke('config', 'user.name', 'Important User')
jaraco.path.build(source_tree)
repo._invoke('add', '.')
repo._invoke('commit', '-m', 'committed')
pathlib.Path('bar/baz').write_text('content', encoding='utf-8')
repo._invoke('commit', '-am', 'added content')
return repo
pytest_plugins = ["jaraco.vcs.testing"]
62 changes: 62 additions & 0 deletions jaraco/vcs/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import pathlib

import pytest

import jaraco.path
from jaraco import vcs


pytest_plugins = ["jaraco.vcs.testing"]


@pytest.fixture(autouse=True)
def _isolate_home(tmp_home_dir):
"""Isolate the tests from a developer's VCS config."""


def _ensure_present(mgr):
try:
mgr.version()
except Exception:
pytest.skip()


@pytest.fixture
def temp_work_dir(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
return tmp_path


source_tree = dict(
bar=dict(
baz="",
),
)


@pytest.fixture
def hg_repo(temp_work_dir):
repo = vcs.Mercurial()
_ensure_present(repo)
repo._invoke('init', '.')
jaraco.path.build(source_tree)
repo._invoke('addremove')
repo._invoke('ci', '-m', 'committed')
pathlib.Path('bar/baz').write_text('content', encoding='utf-8')
repo._invoke('ci', '-m', 'added content')
return repo


@pytest.fixture
def git_repo(temp_work_dir):
repo = vcs.Git()
_ensure_present(repo)
repo._invoke('init')
repo._invoke('config', 'user.email', 'vip@example.com')
repo._invoke('config', 'user.name', 'Important User')
jaraco.path.build(source_tree)
repo._invoke('add', '.')
repo._invoke('commit', '-m', 'committed')
pathlib.Path('bar/baz').write_text('content', encoding='utf-8')
repo._invoke('commit', '-am', 'added content')
return repo
Loading