Skip to content

Commit

Permalink
Skip multipole-related tests if OPENMC_MULTIPOLE_LIBRARY is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Feb 6, 2018
1 parent b7c63be commit 848305b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
python_files = test*.py
python_classes = NoThanks
filterwarnings = ignore::UserWarning
addopts = -rs
4 changes: 4 additions & 0 deletions tests/regression_tests/diff_tally/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pandas as pd
import openmc
import pytest

from tests.testing_harness import PyAPITestHarness

Expand Down Expand Up @@ -112,6 +113,9 @@ def _get_results(self):
return df.to_csv(None, columns=cols, index=False, float_format='%.7e')


@pytest.mark.skipif('OPENMC_MULTIPOLE_LIBRARY' not in os.environ,
reason='OPENMC_MULTIPOLE_LIBRARY environment variable '
'must be set')
def test_diff_tally():
harness = DiffTallyTestHarness('statepoint.3.h5')
harness.main()
11 changes: 4 additions & 7 deletions tests/regression_tests/multipole/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import openmc
import openmc.model
import pytest

from tests.testing_harness import TestHarness, PyAPITestHarness

Expand Down Expand Up @@ -66,20 +67,16 @@ def make_model():


class MultipoleTestHarness(PyAPITestHarness):
def execute_test(self):
if not 'OPENMC_MULTIPOLE_LIBRARY' in os.environ:
raise RuntimeError("The 'OPENMC_MULTIPOLE_LIBRARY' environment "
"variable must be specified for this test.")
else:
super().execute_test()

def _get_results(self):
outstr = super()._get_results()
su = openmc.Summary('summary.h5')
outstr += str(su.geometry.get_all_cells()[11])
return outstr


@pytest.mark.skipif('OPENMC_MULTIPOLE_LIBRARY' not in os.environ,
reason='OPENMC_MULTIPOLE_LIBRARY environment variable '
'must be set')
def test_multipole():
model = make_model()
harness = MultipoleTestHarness('statepoint.5.h5', model)
Expand Down
7 changes: 5 additions & 2 deletions tests/unit_tests/test_data_multipole.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/usr/bin/env python

import os

import numpy as np
import pytest
import openmc.data


pytestmark = pytest.mark.skipif(
'OPENMC_MULTIPOLE_LIBRARY' not in os.environ,
reason='OPENMC_MULTIPOLE_LIBRARY environment variable must be set')


@pytest.fixture(scope='module')
def u235():
directory = os.environ['OPENMC_MULTIPOLE_LIBRARY']
Expand Down

0 comments on commit 848305b

Please sign in to comment.