From 5d573be103f20c1d288b9fdb2ee9398298a02877 Mon Sep 17 00:00:00 2001 From: Kimoon Han Date: Mon, 17 Jun 2024 14:58:34 +0900 Subject: [PATCH] test: add conftest.py --- tests/accessors/test_kspace.py | 5 ----- tests/analysis/test_gold.py | 8 -------- tests/conftest.py | 14 ++++++++++++++ tests/interactive/test_tools.py | 7 ++----- 4 files changed, 16 insertions(+), 18 deletions(-) create mode 100644 tests/conftest.py diff --git a/tests/accessors/test_kspace.py b/tests/accessors/test_kspace.py index f8f397e8..e7878ae9 100644 --- a/tests/accessors/test_kspace.py +++ b/tests/accessors/test_kspace.py @@ -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( diff --git a/tests/analysis/test_gold.py b/tests/analysis/test_gold.py index 2eefe9c3..c22f619e 100644 --- a/tests/analysis/test_gold.py +++ b/tests/analysis/test_gold.py @@ -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): diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..da97029a --- /dev/null +++ b/tests/conftest.py @@ -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 + ) diff --git a/tests/interactive/test_tools.py b/tests/interactive/test_tools.py index bbbadcd2..03a4e466 100644 --- a/tests/interactive/test_tools.py +++ b/tests/interactive/test_tools.py @@ -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): @@ -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):