Skip to content

Commit 0e3be66

Browse files
committed
TST: Remove name argument in fixture
1 parent 0bd8996 commit 0e3be66

2 files changed

Lines changed: 70 additions & 72 deletions

File tree

tests/conftest.py

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def fmurun(tmp_path_factory, monkeypatch, rootpath):
118118
return newpath
119119

120120

121-
@pytest.fixture(name="fmurun_prehook", scope="function")
122-
def fixture_fmurun_prehook(tmp_path_factory, monkeypatch, rootpath):
121+
@pytest.fixture(scope="function")
122+
def fmurun_prehook(tmp_path_factory, monkeypatch, rootpath):
123123
"""A tmp folder structure for testing; here a new fmurun without case metadata."""
124124
tmppath = tmp_path_factory.mktemp("data")
125125
newpath = tmppath / ERTRUN
@@ -147,8 +147,8 @@ def fmurun_w_casemetadata(
147147
return iter_path
148148

149149

150-
@pytest.fixture(name="fmurun_non_equal_real_and_iter", scope="function")
151-
def fixture_fmurun_non_equal_real_and_iter(tmp_path_factory, monkeypatch, rootpath):
150+
@pytest.fixture(scope="function")
151+
def fmurun_non_equal_real_and_iter(tmp_path_factory, monkeypatch, rootpath):
152152
"""Create a tmp folder structure for testing; with non equal real and iter num!"""
153153
tmppath = tmp_path_factory.mktemp("data3")
154154
newpath = tmppath / ERTRUN
@@ -163,8 +163,8 @@ def fixture_fmurun_non_equal_real_and_iter(tmp_path_factory, monkeypatch, rootpa
163163
return rootpath
164164

165165

166-
@pytest.fixture(name="fmurun_no_iter_folder", scope="function")
167-
def fixture_fmurun_no_iter_folder(tmp_path_factory, monkeypatch, rootpath):
166+
@pytest.fixture(scope="function")
167+
def fmurun_no_iter_folder(tmp_path_factory, monkeypatch, rootpath):
168168
"""Create a tmp folder structure for testing; with no iter folder!"""
169169
tmppath = tmp_path_factory.mktemp("data3")
170170
newpath = tmppath / ERTRUN_NO_ITER
@@ -179,8 +179,8 @@ def fixture_fmurun_no_iter_folder(tmp_path_factory, monkeypatch, rootpath):
179179
return rootpath
180180

181181

182-
@pytest.fixture(name="fmurun_w_casemetadata_pred", scope="function")
183-
def fixture_fmurun_w_casemetadata_pred(tmp_path_factory, monkeypatch, rootpath):
182+
@pytest.fixture(scope="function")
183+
def fmurun_w_casemetadata_pred(tmp_path_factory, monkeypatch, rootpath):
184184
"""Create a tmp folder structure for testing; here existing fmurun w/ case meta!"""
185185
tmppath = tmp_path_factory.mktemp("data3")
186186
newpath = tmppath / ERTRUN
@@ -193,8 +193,8 @@ def fixture_fmurun_w_casemetadata_pred(tmp_path_factory, monkeypatch, rootpath):
193193
return rootpath
194194

195195

196-
@pytest.fixture(name="fmurun_pred", scope="session")
197-
def fixture_fmurun_pred(tmp_path_factory, rootpath):
196+
@pytest.fixture(scope="session")
197+
def fmurun_pred(tmp_path_factory, rootpath):
198198
"""Create a tmp folder structure for testing; here a new fmurun for prediction."""
199199
tmppath = tmp_path_factory.mktemp("data_pred")
200200
newpath = tmppath / ERTRUN_PRED
@@ -203,8 +203,8 @@ def fixture_fmurun_pred(tmp_path_factory, rootpath):
203203
return newpath
204204

205205

206-
@pytest.fixture(name="rmsrun_fmu_w_casemetadata", scope="session")
207-
def fixture_rmsrun_fmu_w_casemetadata(tmp_path_factory, rootpath):
206+
@pytest.fixture(scope="session")
207+
def rmsrun_fmu_w_casemetadata(tmp_path_factory, rootpath):
208208
"""Create a tmp folder structure for testing; here existing fmurun w/ case meta!
209209
210210
Then we locate the folder to the ...rms/model folder, pretending running RMS
@@ -250,8 +250,8 @@ def rmssetup_with_fmuconfig(tmp_path_factory, global_config2_path):
250250
return rmspath
251251

252252

253-
@pytest.fixture(name="rmsglobalconfig", scope="function")
254-
def fixture_rmsglobalconfig(rmssetup, monkeypatch: MonkeyPatch):
253+
@pytest.fixture(scope="function")
254+
def rmsglobalconfig(rmssetup, monkeypatch: MonkeyPatch):
255255
"""Read global config."""
256256
# read the global config
257257
monkeypatch.chdir(rmssetup)
@@ -264,10 +264,8 @@ def fixture_rmsglobalconfig(rmssetup, monkeypatch: MonkeyPatch):
264264
return global_cfg
265265

266266

267-
@pytest.fixture(name="globalvars_norwegian_letters", scope="function")
268-
def fixture_globalvars_norwegian_letters(
269-
tmp_path_factory, rootpath, monkeypatch: MonkeyPatch
270-
):
267+
@pytest.fixture(scope="function")
268+
def globalvars_norwegian_letters(tmp_path_factory, rootpath, monkeypatch: MonkeyPatch):
271269
"""Read a global config with norwegian special letters w/ fmu.config utilities."""
272270

273271
tmppath = tmp_path_factory.mktemp("revisionxx")
@@ -288,8 +286,8 @@ def fixture_globalvars_norwegian_letters(
288286
return (rmspath, cfg, gname)
289287

290288

291-
@pytest.fixture(name="casesetup", scope="function")
292-
def fixture_casesetup(tmp_path_factory):
289+
@pytest.fixture(scope="function")
290+
def casesetup(tmp_path_factory):
293291
"""Create the folder structure to mimic a fmu run"""
294292

295293
tmppath = tmp_path_factory.mktemp("mycase")
@@ -301,8 +299,8 @@ def fixture_casesetup(tmp_path_factory):
301299
return tmppath
302300

303301

304-
@pytest.fixture(name="globalconfig1", scope="function")
305-
def fixture_globalconfig1():
302+
@pytest.fixture(scope="function")
303+
def globalconfig1():
306304
"""Minimalistic global config variables no. 1 in ExportData class."""
307305
return global_configuration.GlobalConfiguration(
308306
masterdata=fields.Masterdata(
@@ -383,8 +381,8 @@ def globalconfig2(global_config2_path) -> dict:
383381
return yaml.safe_load(stream)
384382

385383

386-
@pytest.fixture(name="edataobj2", scope="function")
387-
def fixture_edataobj2(globalconfig2):
384+
@pytest.fixture(scope="function")
385+
def edataobj2(globalconfig2):
388386
"""Combined globalconfig2 and other settings; NB for internal unit testing"""
389387
eobj = dio.ExportData(
390388
config=globalconfig2,
@@ -437,15 +435,15 @@ def metadata_examples():
437435
return _metadata_examples()
438436

439437

440-
@pytest.fixture(name="regsurf_nan_only", scope="function")
441-
def fixture_regsurf_nan_only():
438+
@pytest.fixture(scope="function")
439+
def regsurf_nan_only():
442440
"""Create an xtgeo surface with only NaNs."""
443441
logger.debug("Ran %s", _current_function_name())
444442
return xtgeo.RegularSurface(ncol=12, nrow=10, xinc=20, yinc=20, values=np.nan)
445443

446444

447-
@pytest.fixture(name="regsurf_masked_only", scope="function")
448-
def fixture_regsurf_masked_only():
445+
@pytest.fixture(scope="function")
446+
def regsurf_masked_only():
449447
"""Create an xtgeo surface with only masked values."""
450448
logger.debug("Ran %s", _current_function_name())
451449
regsurf = xtgeo.RegularSurface(ncol=12, nrow=10, xinc=20, yinc=20, values=1000)
@@ -458,15 +456,15 @@ def fixture_regsurf_masked_only():
458456
# ======================================================================================
459457

460458

461-
@pytest.fixture(name="regsurf", scope="function")
462-
def fixture_regsurf():
459+
@pytest.fixture(scope="function")
460+
def regsurf():
463461
"""Create an xtgeo surface."""
464462
logger.debug("Ran %s", _current_function_name())
465463
return xtgeo.RegularSurface(ncol=12, nrow=10, xinc=20, yinc=20, values=1234.0)
466464

467465

468-
@pytest.fixture(name="faultroom_object", scope="function")
469-
def fixture_faultroom_object(globalconfig2):
466+
@pytest.fixture(scope="function")
467+
def faultroom_object(globalconfig2):
470468
"""Create a faultroom object."""
471469
logger.debug("Ran %s", _current_function_name())
472470
cfg = deepcopy(globalconfig2)
@@ -494,8 +492,8 @@ def fixture_faultroom_object(globalconfig2):
494492
return FaultRoomSurface({"metadata": faultroom_data, "features": features})
495493

496494

497-
@pytest.fixture(name="tsurf")
498-
def fixture_tsurf() -> TSurfData:
495+
@pytest.fixture()
496+
def tsurf() -> TSurfData:
499497
"""
500498
Create a basic TSurfData object from a dictionary.
501499
"""
@@ -521,8 +519,8 @@ def fixture_tsurf() -> TSurfData:
521519
return TSurfData.model_validate(tsurf_dict)
522520

523521

524-
@pytest.fixture(name="tsurf_as_lines")
525-
def fixture_tsurf_as_lines(tsurf: TSurfData) -> list[str]:
522+
@pytest.fixture()
523+
def tsurf_as_lines(tsurf: TSurfData) -> list[str]:
526524
"""
527525
Create lines to simulate the results of parsing a file with a basic TSurf object.
528526
"""
@@ -560,8 +558,8 @@ def fixture_tsurf_as_lines(tsurf: TSurfData) -> list[str]:
560558
]
561559

562560

563-
@pytest.fixture(name="polygons", scope="function")
564-
def fixture_polygons():
561+
@pytest.fixture(scope="function")
562+
def polygons():
565563
"""Create an xtgeo polygons."""
566564
logger.debug("Ran %s", _current_function_name())
567565
return xtgeo.Polygons(
@@ -574,8 +572,8 @@ def fixture_polygons():
574572
)
575573

576574

577-
@pytest.fixture(name="fault_line", scope="function")
578-
def fixture_fault_line():
575+
@pytest.fixture(scope="function")
576+
def fault_line():
579577
"""Create an xtgeo polygons."""
580578
logger.debug("Ran %s", _current_function_name())
581579
return xtgeo.Polygons(
@@ -589,8 +587,8 @@ def fixture_fault_line():
589587
)
590588

591589

592-
@pytest.fixture(name="points", scope="function")
593-
def fixture_points():
590+
@pytest.fixture(scope="function")
591+
def points():
594592
"""Create an xtgeo points instance."""
595593
logger.debug("Ran %s", _current_function_name())
596594
return xtgeo.Points(
@@ -604,36 +602,36 @@ def fixture_points():
604602
)
605603

606604

607-
@pytest.fixture(name="cube", scope="function")
608-
def fixture_cube():
605+
@pytest.fixture(scope="function")
606+
def cube():
609607
"""Create an xtgeo cube instance."""
610608
logger.debug("Ran %s", _current_function_name())
611609
return xtgeo.Cube(ncol=3, nrow=4, nlay=5, xinc=12, yinc=12, zinc=4, rotation=30)
612610

613611

614-
@pytest.fixture(name="grid", scope="function")
615-
def fixture_grid():
612+
@pytest.fixture(scope="function")
613+
def grid():
616614
"""Create an xtgeo grid instance."""
617615
logger.debug("Ran %s", _current_function_name())
618616
return xtgeo.create_box_grid((3, 4, 5))
619617

620618

621-
@pytest.fixture(name="gridproperty", scope="function")
622-
def fixture_gridproperty():
619+
@pytest.fixture(scope="function")
620+
def gridproperty():
623621
"""Create an xtgeo gridproperty instance."""
624622
logger.debug("Ran %s", _current_function_name())
625623
return xtgeo.GridProperty(ncol=3, nrow=7, nlay=3, values=123.0)
626624

627625

628-
@pytest.fixture(name="dataframe", scope="function")
629-
def fixture_dataframe():
626+
@pytest.fixture(scope="function")
627+
def dataframe():
630628
"""Create an pandas dataframe instance."""
631629
logger.debug("Ran %s", _current_function_name())
632630
return pd.DataFrame({"COL1": [1, 2, 3, 4], "COL2": [99.0, 98.0, 97.0, 96.0]})
633631

634632

635-
@pytest.fixture(name="wellpicks", scope="function")
636-
def fixture_wellpicks():
633+
@pytest.fixture(scope="function")
634+
def wellpicks():
637635
"""Create a pandas dataframe containing wellpicks"""
638636
logger.debug("Ran %s", _current_function_name())
639637
return pd.DataFrame(
@@ -664,8 +662,8 @@ def fixture_wellpicks():
664662
)
665663

666664

667-
@pytest.fixture(name="arrowtable", scope="function")
668-
def fixture_arrowtable():
665+
@pytest.fixture(scope="function")
666+
def arrowtable():
669667
"""Create an arrow table instance."""
670668
try:
671669
from pyarrow import Table
@@ -712,8 +710,8 @@ def _create_aggregated_surface_dataset(
712710
return surfs, metas
713711

714712

715-
@pytest.fixture(name="aggr_sesimic_surfs_mean", scope="function")
716-
def fixture_aggr_seismic_surfs_mean(
713+
@pytest.fixture(scope="function")
714+
def aggr_seismic_surfs_mean(
717715
fmurun_w_casemetadata, rmsglobalconfig, regsurf, monkeypatch: MonkeyPatch
718716
):
719717
"""Create aggregated surfaces, and return aggr. mean surface + lists of metadata"""
@@ -738,8 +736,8 @@ def fixture_aggr_seismic_surfs_mean(
738736
return (aggregated["mean"], metas)
739737

740738

741-
@pytest.fixture(name="aggr_surfs_mean", scope="function")
742-
def fixture_aggr_surfs_mean(
739+
@pytest.fixture(scope="function")
740+
def aggr_surfs_mean(
743741
fmurun_w_casemetadata, rmsglobalconfig, regsurf, monkeypatch: MonkeyPatch
744742
):
745743
"""Create aggregated surfaces, and return aggr. mean surface + lists of metadata"""
@@ -761,8 +759,8 @@ def fixture_aggr_surfs_mean(
761759
return (aggregated["mean"], metas)
762760

763761

764-
@pytest.fixture(name="edataobj3")
765-
def fixture_edataobj3(globalconfig1):
762+
@pytest.fixture()
763+
def edataobj3(globalconfig1):
766764
"""Combined globalconfig and settings to instance, for internal testing"""
767765

768766
return ExportData(
@@ -785,8 +783,8 @@ def export_data_obj_timeseries(globalconfig1):
785783
)
786784

787785

788-
@pytest.fixture(name="mock_summary")
789-
def fixture_summary():
786+
@pytest.fixture()
787+
def mock_summary():
790788
"""Return summary mock data
791789
792790
Returns:
@@ -795,14 +793,14 @@ def fixture_summary():
795793
return pd.DataFrame({"alf": ["A", "B", "C"], "DATE": [1, 2, 3]})
796794

797795

798-
@pytest.fixture(name="mock_relperm")
799-
def fixture_relperm():
796+
@pytest.fixture()
797+
def mock_relperm():
800798
"""Return relperm mock data"""
801799
return pd.DataFrame({"alf": ["A", "B", "C"], "SATNUM": [1, 2, 3]})
802800

803801

804-
@pytest.fixture(name="drogon_summary")
805-
def fixture_drogon_sum(rootpath):
802+
@pytest.fixture()
803+
def drogon_summary(rootpath):
806804
"""Return pyarrow table
807805
808806
Returns:
@@ -813,8 +811,8 @@ def fixture_drogon_sum(rootpath):
813811
return feather.read_table(rootpath / "tests/data/drogon/tabular/summary.arrow")
814812

815813

816-
@pytest.fixture(name="mock_volumes")
817-
def fixture_mock_volumes():
814+
@pytest.fixture()
815+
def mock_volumes():
818816
"""Return volume mock data
819817
820818
Returns:
@@ -832,8 +830,8 @@ def fixture_mock_volumes():
832830
)
833831

834832

835-
@pytest.fixture(name="drogon_volumes")
836-
def fixture_drogon_volumes(rootpath):
833+
@pytest.fixture()
834+
def drogon_volumes(rootpath):
837835
"""Return pyarrow table
838836
839837
Returns:

tests/test_units/test_aggregated_surfaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ def test_regsurf_aggregated(
3737

3838

3939
def test_regsurf_aggregated_content_seismic(
40-
fmurun_w_casemetadata, aggr_sesimic_surfs_mean, monkeypatch: pytest.MonkeyPatch
40+
fmurun_w_casemetadata, aggr_seismic_surfs_mean, monkeypatch: pytest.MonkeyPatch
4141
):
4242
"""
4343
Test generating aggragated metadata for a surface, where the content is seismic
4444
which will require more info.
4545
"""
4646
logger.info("Active folder is %s", fmurun_w_casemetadata)
4747

48-
aggr_mean, metas = aggr_sesimic_surfs_mean # xtgeo_object, list-of-metadata-dicts
48+
aggr_mean, metas = aggr_seismic_surfs_mean # xtgeo_object, list-of-metadata-dicts
4949
logger.info("Aggr. mean is %s", aggr_mean.values.mean())
5050

5151
aggregation_uuid = str(utils.uuid_from_string("1234"))

0 commit comments

Comments
 (0)