From 393db0bd7e2a0e24f5c9a9e980f32dd06ff0037b Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Tue, 3 Sep 2024 12:00:20 -0600 Subject: [PATCH] Moved pytest fixture that returns test data to conftest.py --- imap_processing/tests/idex/conftest.py | 22 ++++++++++++++++++++++ imap_processing/tests/idex/test_idex_l0.py | 19 ------------------- imap_processing/tests/idex/test_idex_l1.py | 18 ------------------ 3 files changed, 22 insertions(+), 37 deletions(-) create mode 100644 imap_processing/tests/idex/conftest.py diff --git a/imap_processing/tests/idex/conftest.py b/imap_processing/tests/idex/conftest.py new file mode 100644 index 000000000..a2a9d4d77 --- /dev/null +++ b/imap_processing/tests/idex/conftest.py @@ -0,0 +1,22 @@ +from pathlib import Path + +import pytest +import xarray as xr + +from imap_processing import imap_module_directory +from imap_processing.idex.l1.idex_l1 import PacketParser + + +@pytest.fixture() +def decom_test_data() -> xr.Dataset: + """Return a ``xarray`` dataset containing test data. + + Returns + ------- + dataset : xarray.Dataset + A ``xarray`` dataset containing the test data + """ + test_file = Path( + f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts" + ) + return PacketParser(test_file, "001").data diff --git a/imap_processing/tests/idex/test_idex_l0.py b/imap_processing/tests/idex/test_idex_l0.py index 131640619..d8ead8495 100644 --- a/imap_processing/tests/idex/test_idex_l0.py +++ b/imap_processing/tests/idex/test_idex_l0.py @@ -1,28 +1,9 @@ """Tests the decommutation process for IDEX CCSDS Packets.""" -from pathlib import Path - import numpy as np -import pytest import xarray as xr from imap_processing import imap_module_directory -from imap_processing.idex.l1.idex_l1 import PacketParser - - -@pytest.fixture(scope="session") -def decom_test_data() -> xr.Dataset: - """Return a ``xarray`` dataset containing test data. - - Returns - ------- - dataset : xarray.Dataset - A ``xarray`` dataset containing the test data - """ - test_file = Path( - f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts" - ) - return PacketParser(test_file, "001").data def test_idex_decom_length(decom_test_data: xr.Dataset): diff --git a/imap_processing/tests/idex/test_idex_l1.py b/imap_processing/tests/idex/test_idex_l1.py index d7ca35e15..7bf72aea3 100644 --- a/imap_processing/tests/idex/test_idex_l1.py +++ b/imap_processing/tests/idex/test_idex_l1.py @@ -1,7 +1,5 @@ """Tests the L1 processing for decommutated IDEX data""" -from pathlib import Path - import numpy as np import pytest import xarray as xr @@ -9,22 +7,6 @@ from imap_processing import imap_module_directory from imap_processing.cdf.utils import load_cdf, write_cdf -from imap_processing.idex.l1.idex_l1 import PacketParser - - -@pytest.fixture() -def decom_test_data() -> xr.Dataset: - """Return a ``xarray`` dataset containing test data. - - Returns - ------- - dataset : xarray.Dataset - A ``xarray`` dataset containing the test data - """ - test_file = Path( - f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts" - ) - return PacketParser(test_file, "v001").data def test_idex_cdf_file(decom_test_data: xr.Dataset):