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 test_benchmarks.py and test_workflow.py fixtures to conftest.py file #1121

Merged
Merged
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
39 changes: 31 additions & 8 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import contextlib
import os
import shutil
import contextlib
import textwrap
from os.path import join, abspath, dirname
from os.path import abspath, dirname, join

import pytest
import selenium

from asv import config, repo
from asv import config, environment, repo
from asv.repo import get_repo

from .test_workflow import generate_basic_conf
from .tools import (locked_cache_dir, run_asv_with_conf, _build_dummy_wheels, WAIT_TIME,
DUMMY1_VERSION, DUMMY2_VERSIONS, WIN, HAS_CONDA, PYTHON_VER1, PYTHON_VER2)
from . import tools
from .test_benchmarks import ASV_CONF_JSON, BENCHMARK_DIR
from .test_web import _rebuild_basic_html
from .test_workflow import generate_basic_conf
from .tools import (DUMMY1_VERSION, DUMMY2_VERSIONS, HAS_CONDA, PYTHON_VER1, PYTHON_VER2,
WAIT_TIME, WIN, _build_dummy_wheels, locked_cache_dir, run_asv_with_conf)

try:
import hglib
except ImportError:
hglib = None

from . import tools


def pytest_addoption(parser):
parser.addoption("--webdriver", action="store", default="None",
Expand Down Expand Up @@ -267,3 +268,25 @@ def basic_html(request):
tmpdir = join(str(cache_dir), 'cached')
html_dir, dvcs = _rebuild_basic_html(tmpdir)
return html_dir, dvcs


@pytest.fixture
def benchmarks_fixture(tmpdir):
tmpdir = str(tmpdir)
os.chdir(tmpdir)

shutil.copytree(BENCHMARK_DIR, 'benchmark')

d = {}
d.update(ASV_CONF_JSON)
d['env_dir'] = "env"
d['benchmark_dir'] = 'benchmark'
d['repo'] = tools.generate_test_repo(tmpdir, [0]).path
d['branches'] = ["master"]
conf = config.Config.from_json(d)

repo = get_repo(conf)
envs = list(environment.get_environments(conf, None))
commit_hash = repo.get_hash_from_name(repo.get_branch_name())

return conf, repo, envs, commit_hash
22 changes: 0 additions & 22 deletions test/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,6 @@
ON_PYPY = False


@pytest.fixture
def benchmarks_fixture(tmpdir):
tmpdir = str(tmpdir)
os.chdir(tmpdir)

shutil.copytree(BENCHMARK_DIR, 'benchmark')

d = {}
d.update(ASV_CONF_JSON)
d['env_dir'] = "env"
d['benchmark_dir'] = 'benchmark'
d['repo'] = tools.generate_test_repo(tmpdir, [0]).path
d['branches'] = ["master"]
conf = config.Config.from_json(d)

repo = get_repo(conf)
envs = list(environment.get_environments(conf, None))
commit_hash = repo.get_hash_from_name(repo.get_branch_name())

return conf, repo, envs, commit_hash


def test_discover_benchmarks(benchmarks_fixture):
conf, repo, envs, commit_hash = benchmarks_fixture

Expand Down
2 changes: 1 addition & 1 deletion test/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from asv import benchmarks, config, environment, runner, util
from asv.results import Results

from .test_benchmarks import benchmarks_fixture, ASV_CONF_JSON, BENCHMARK_DIR
from .test_benchmarks import ASV_CONF_JSON, BENCHMARK_DIR

ON_PYPY = hasattr(sys, 'pypy_version_info')

Expand Down
5 changes: 0 additions & 5 deletions test/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ def generate_basic_conf(tmpdir, repo_subdir='', values=dummy_values, dummy_packa
return tmpdir, local, conf, machine_file


@pytest.fixture
def basic_conf(tmpdir, dummy_packages):
return generate_basic_conf(tmpdir)


def test_run_publish(capfd, basic_conf):
tmpdir, local, conf, machine_file = basic_conf
tmpdir = util.long_path(tmpdir)
Expand Down