Skip to content

Commit

Permalink
test: add conftest.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnhan committed Jun 17, 2024
1 parent 3652a21 commit 5d573be
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
5 changes: 0 additions & 5 deletions tests/accessors/test_kspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
from erlab.io.exampledata import generate_data_angles


@pytest.fixture(scope="session")
def anglemap():
return generate_data_angles(shape=(10, 10, 10), assign_attributes=True)


@pytest.fixture()
def cut():
return generate_data_angles(
Expand Down
8 changes: 0 additions & 8 deletions tests/analysis/test_gold.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@
import numpy as np
import pytest
from erlab.analysis.gold import correct_with_edge, poly, spline
from erlab.io.exampledata import generate_gold_edge
from numpy.testing import assert_allclose


@pytest.fixture(scope="session")
def gold():
return generate_gold_edge(
temp=100, seed=1, nx=15, ny=150, edge_coeffs=(0.04, 1e-5, -3e-4), noise=False
)


@pytest.mark.parametrize("parallel_kw", [{"n_jobs": 1, "return_as": "list"}])
@pytest.mark.parametrize("fast", [True, False])
def test_poly(gold, parallel_kw: dict, fast: bool):
Expand Down
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from erlab.io.exampledata import generate_data_angles, generate_gold_edge


@pytest.fixture()
def anglemap():
return generate_data_angles(shape=(10, 10, 10), assign_attributes=True)


@pytest.fixture()
def gold():
return generate_gold_edge(
temp=100, seed=1, nx=15, ny=150, edge_coeffs=(0.04, 1e-5, -3e-4), noise=False
)
7 changes: 2 additions & 5 deletions tests/interactive/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
from erlab.interactive.kspace import ktool
from numpy.testing import assert_allclose

from ..accessors.test_kspace import anglemap # noqa: TID252, F401
from ..analysis.test_gold import gold # noqa: TID252, F401


def test_goldtool(qtbot, gold): # noqa: F811
def test_goldtool(qtbot, gold):
win = goldtool(gold, execute=False)
qtbot.addWidget(win)
with qtbot.waitExposed(win):
Expand Down Expand Up @@ -56,7 +53,7 @@ def test_dtool(qtbot):
assert win.copy_code() == "result = era.image.minimum_gradient(data)"


def test_ktool(qtbot, anglemap): # noqa: F811
def test_ktool(qtbot, anglemap):
win = ktool(anglemap, execute=False)
qtbot.addWidget(win)
with qtbot.waitExposed(win):
Expand Down

0 comments on commit 5d573be

Please sign in to comment.