Skip to content

Commit

Permalink
Move test assets to be near their tests (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Oct 21, 2020
1 parent 7bdbf3e commit c576a3b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

here = Path(__file__).absolute().parent
results = here / "test_results"
tests_root_directory = Path(__file__).absolute().parent
results = tests_root_directory / "test_results"
is_ci = "CI" in environ

shutil.rmtree(results, ignore_errors=True, onerror=None)
Expand All @@ -37,8 +37,8 @@
rundb_path = f"{results}/rundb"
logs_path = f"{results}/logs"
out_path = f"{results}/out"
root_path = str(Path(here).parent)
examples_path = Path(here).parent.joinpath("examples")
root_path = str(Path(tests_root_directory).parent)
examples_path = Path(tests_root_directory).parent.joinpath("examples")
environ["PYTHONPATH"] = root_path
environ["MLRUN_DBPATH"] = rundb_path
environ["MLRUN_httpdb__dirpath"] = rundb_path
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/runtimes/test_funcdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import yaml

from mlrun.runtimes import funcdoc
from tests.conftest import here
from tests.conftest import tests_root_directory


def load_rst_cases(name):
with open(here / name) as fp:
with open(tests_root_directory / "runtimes" / name) as fp:
data = yaml.load(fp)

for i, case in enumerate(data):
Expand Down Expand Up @@ -65,7 +65,7 @@ def eval_func(code):


def load_info_cases():
with open(here / "info_cases.yml") as fp:
with open(tests_root_directory / "runtimes" / "info_cases.yml") as fp:
cases = yaml.load(fp)

for case in cases:
Expand Down Expand Up @@ -144,7 +144,7 @@ def fn() -> None:


def test_ast_compound():
with open(f"{here}/arc.txt") as fp:
with open(f"{tests_root_directory}/runtimes/arc.txt") as fp:
code = fp.read()

fn = ast_func(code)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import pytest

from tests.conftest import here, in_docker, wait_for_server
from tests.conftest import tests_root_directory, in_docker, wait_for_server

prj_dir = here.parent
prj_dir = tests_root_directory.parent
is_ci = "CI" in environ


Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sys import executable, stderr
from subprocess import run, PIPE
from tests.conftest import (
here,
tests_root_directory,
examples_path,
root_path,
)
Expand Down Expand Up @@ -67,7 +67,7 @@ def test_main_run_hyper():

def test_main_run_noctx():
out = exec_run(
f"{here}/no_ctx.py",
f"{tests_root_directory}/no_ctx.py",
["--mode", "noctx"] + compose_param_list(dict(p1=5, p2='"aaa"')),
"test_main_run_noctx",
)
Expand Down
8 changes: 5 additions & 3 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from tests.conftest import (
examples_path,
has_secrets,
here,
tests_root_directory,
out_path,
tag_test,
verify_state,
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_handler_hyper():

def test_handler_hyperlist():
run_spec = tag_test(base_spec, "test_handler_hyperlist")
run_spec.spec.param_file = "{}/param_file.csv".format(here)
run_spec.spec.param_file = "{}/param_file.csv".format(tests_root_directory)
result = new_function().run(run_spec, handler=my_func)
print(result)
assert len(result.status.iterations) == 3 + 1, "hyper parameters test failed"
Expand Down Expand Up @@ -165,7 +165,9 @@ def test_local_handler():
def test_local_no_context():
spec = tag_test(base_spec, "test_local_no_context")
spec.spec.parameters = {"xyz": "789"}
result = new_function(command="{}/no_ctx.py".format(here), mode="noctx").run(spec)
result = new_function(
command="{}/no_ctx.py".format(tests_root_directory), mode="noctx"
).run(spec)
verify_state(result)

db = get_run_db().connect()
Expand Down

0 comments on commit c576a3b

Please sign in to comment.