Skip to content

Commit

Permalink
TST: Refactor use of roxar marking
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Nov 3, 2021
1 parent c0e99a6 commit 738ea08
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 755 deletions.
3 changes: 1 addition & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ log_cli_level = INFO
testpaths =
tests
markers =
skipifroxar: skipped if in roxar environment
skipunlessroxar: skipped if not in the roxar environment
bigtest: A big test not executed by default
requires_opm: A test requiring opm in the environment
requires_roxar: Test requires to run in RMS python
13 changes: 6 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@ def pytest_runtest_setup(item):
if "XTG_BIGTEST" not in os.environ:
pytest.skip("Skip big test (no env variable XTG_BIGTEST)")

# pytest.mark.skipifroxar:
if "skipifroxar" in markers:
if "ROXENV" in os.environ:
pytest.skip("Skip test in ROXENV (env variable ROXENV is present)")

# pytest.mark.skipunlessroxar:
if "skipunlessroxar" in markers:
# pytest.mark.requires_roxar:
if "requires_roxar" in markers:
if "ROXENV" not in os.environ:
pytest.skip("Skip test if outside ROXENV (env variable ROXENV is present)")

Expand Down Expand Up @@ -76,6 +71,8 @@ def assert_almostequal(this, that, tol, txt=""):
@pytest.fixture(name="show_plot")
def fixture_xtgshow():
"""For eventual plotting, to be uses in an if sence inside a test."""
if "ROXENV" in os.environ:
pytest.skip("Skip plotting tests in roxar environment")
if any(word in os.environ for word in ["XTGSHOW", "XTG_SHOW"]):
return True
return False
Expand Down Expand Up @@ -114,6 +111,8 @@ def pytest_addoption(parser):

@pytest.fixture(name="generate_plot")
def fixture_generate_plot(request):
if "ROXENV" in os.environ:
pytest.skip("Skip plotting tests in roxar environment")
return request.config.getoption("--generate-plots")


Expand Down
11 changes: 5 additions & 6 deletions tests/test_etc/test_etc_make_avg_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
FFILE1 = TPATH / "polygons/reek/1/top_upper_reek_faultpoly.zmap"


@pytest.mark.skipifroxar
def test_avg02(tmpdir, generate_plot):
"""Make average map from Reek Eclipse."""
grd = Grid()
Expand Down Expand Up @@ -91,8 +90,7 @@ def test_avg02(tmpdir, generate_plot):
assert avgmap.values.mean() == pytest.approx(0.1653, abs=0.01)


@pytest.mark.skipifroxar
def test_avg03(tmpdir):
def test_avg03(tmpdir, generate_plot):
"""Make average map from Reek Eclipse, speed up by zone_avgrd."""
grd = Grid()
grd.from_file(GFILE2, fformat="egrid")
Expand Down Expand Up @@ -147,9 +145,10 @@ def test_avg03(tmpdir):
fau = Polygons(FFILE1, fformat="zmap")
fspec = {"faults": fau}

avgmap.quickplot(
filename=join(tmpdir, "tmp_poro3.png"), xlabelrotation=30, faults=fspec
)
if generate_plot:
avgmap.quickplot(
filename=join(tmpdir, "tmp_poro3.png"), xlabelrotation=30, faults=fspec
)
avgmap.to_file(join(tmpdir, "tmp.poro3.gri"), fformat="irap_ascii")

logger.info(avgmap.values.mean())
Expand Down
1 change: 0 additions & 1 deletion tests/test_etc/test_etc_make_hcpv_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
ROFF1_PROPS = TPATH / "3dgrids/eme/1/emerald_hetero.roff"


@pytest.mark.skipifroxar
def test_hcpvfz1(tmpdir, generate_plot):
"""HCPV thickness map."""

Expand Down
94 changes: 0 additions & 94 deletions tests/test_grid3d/test_grid_roxapi.py

This file was deleted.

50 changes: 0 additions & 50 deletions tests/test_grid3d/test_grid_roxapi_bigtest.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_plot/test_grid3dsliceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
USEFILE3 = TPATH / "etc/colortables/rainbow_reverse.rmscolor"


@pytest.mark.skipifroxar
def test_slice_simple_layer(tmpdir, show_plot, generate_plot):
"""Trigger XSection class, and do some simple things basically."""
layslice = Grid3DSlice()
Expand Down
6 changes: 0 additions & 6 deletions tests/test_plot/test_map.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import sys
from os.path import join

import pytest

import xtgeo
from xtgeo.common import XTGeoDialog
from xtgeo.plot import Map
Expand All @@ -26,7 +24,6 @@
SFILE2 = TPATH / "surfaces/reek/1/reek_perm_lay1.gri"


@pytest.mark.skipifroxar
def test_simple_plot(tmpdir, generate_plot):
"""Test as simple map plot only making an instance++ and plot."""

Expand All @@ -44,7 +41,6 @@ def test_simple_plot(tmpdir, generate_plot):
myplot.close()


@pytest.mark.skipifroxar
def test_map_plot_with_points(tmpdir, generate_plot):
"""Test as simple map plot with underlying points."""

Expand All @@ -70,7 +66,6 @@ def test_map_plot_with_points(tmpdir, generate_plot):
myplot.close()


@pytest.mark.skipifroxar
def test_more_features_plot(tmpdir, generate_plot):
"""Map with some more features added, such as label rotation."""

Expand All @@ -92,7 +87,6 @@ def test_more_features_plot(tmpdir, generate_plot):
myplot.close()


@pytest.mark.skipifroxar
def test_perm_logarithmic_map(tmpdir, generate_plot):
"""Map with PERM, log scale."""

Expand Down
47 changes: 0 additions & 47 deletions tests/test_plot/test_xsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import glob
from os.path import join

import matplotlib.pyplot as plt
import pytest

import tests.test_common.test_xtg as tsetup
import xtgeo
from xtgeo.plot import XSection

Expand All @@ -32,20 +28,13 @@

USEFILE7 = TPATH / "wells/reek/1/OP_2.w"

BIGRGRID1 = "../xtgeo-testdata-equinor/data/3dgrids/gfb/gullfaks_gg.roff"
BIGPROP1 = "../xtgeo-testdata-equinor/data/3dgrids/gfb/gullfaks_gg_phix.roff"
BIGWELL1 = "../xtgeo-testdata-equinor/data/wells/gfb/1/34_10-A-42.w"
BIGWELL2 = "../xtgeo-testdata-equinor/data/wells/gfb/1/34_10-A-41.w"


@pytest.mark.skipifroxar
def test_xsection_init():
"""Trigger XSection class, basically."""
xsect = XSection()
assert xsect.pagesize == "A4"


@pytest.mark.skipifroxar
def test_simple_plot(tmpdir, show_plot, generate_plot):
"""Test as simple XSECT plot."""

Expand Down Expand Up @@ -88,7 +77,6 @@ def test_simple_plot(tmpdir, show_plot, generate_plot):
myplot.close()


@pytest.mark.skipifroxar
def test_simple_plot_with_seismics(tmpdir, show_plot, generate_plot):
"""Test as simple XSECT plot with seismic backdrop."""

Expand Down Expand Up @@ -143,40 +131,6 @@ def test_simple_plot_with_seismics(tmpdir, show_plot, generate_plot):
myplot.close()


@pytest.mark.skipifroxar
@tsetup.equinor
@tsetup.bigtest
def test_xsect_larger_geogrid(show_plot):
"""Test a larger xsection"""

mygrid = xtgeo.Grid(BIGRGRID1)
poro = xtgeo.GridProperty(BIGPROP1)
mywell1 = xtgeo.Well(BIGWELL1)
mywell2 = xtgeo.Well(BIGWELL2)

fence1 = mywell1.get_fence_polyline(sampling=5, tvdmin=1750, asnumpy=True)

(hmin1, hmax1, vmin1, vmax1, arr1) = mygrid.get_randomline(
fence1, poro, zmin=1750, zmax=2100, zincrement=0.2
)

fence2 = mywell2.get_fence_polyline(sampling=5, tvdmin=1500, asnumpy=True)

(hmin2, hmax2, vmin2, vmax2, arr2) = mygrid.get_randomline(
fence2, poro, zmin=1500, zmax=1850, zincrement=0.2
)

if show_plot:
plt.figure()
plt.imshow(arr1, cmap="rainbow", extent=(hmin1, hmax1, vmax1, vmin1))
plt.axis("tight")
plt.figure()
plt.imshow(arr2, cmap="rainbow", extent=(hmin2, hmax2, vmax2, vmin2))
plt.axis("tight")
plt.show()


@pytest.mark.skipifroxar
def test_multiple_subplots(tmpdir, show_plot, generate_plot):
"""Test as simple XSECT plot."""

Expand All @@ -191,7 +145,6 @@ def test_multiple_subplots(tmpdir, show_plot, generate_plot):
myplot.close()


@pytest.mark.skipifroxar
def test_reek1(tmpdir, generate_plot):
"""Test XSect for a Reek well."""

Expand Down
Loading

0 comments on commit 738ea08

Please sign in to comment.