Skip to content

Commit

Permalink
use fixture in test_run_inputs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibbelink committed Nov 13, 2023
1 parent d61ffe6 commit a1d337f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions tests/test_run_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess

from pytest import skip
import pytest

import run_inputs as ri
from helper import cyclus_has_coin
Expand All @@ -11,16 +12,22 @@ def coin_skipper(filename):
raise skip(filename + " cannot be executed since Cyclus was not installed "
"with COIN support")


def test_inputs():
def get_files():
files, _, _ = ri.get_files(ri.input_path)
for f in files:
absfile = os.path.join(ri.input_path, f)
with open(absfile) as fh:
src = fh.read()
if cyclus_has_coin() or "GrowthRegion" not in src:
testf = ri.TestFile(ri.cyclus_path, f, "-v0")
testf.run()
assert testf.passed, "Failed running {}".format(f)
else:
coin_skipper(absfile)
yield f

@pytest.fixture(params=get_files())
def file_fixture(request):
return request.param

def test_inputs(file_fixture):
absfile = os.path.join(ri.input_path, file_fixture)
with open(absfile) as fh:
src = fh.read()
if cyclus_has_coin() or "GrowthRegion" not in src:
testf = ri.TestFile(ri.cyclus_path, file_fixture, "-v0")
testf.run()
assert testf.passed, "Failed running {}".format(file_fixture)
else:
coin_skipper(absfile)

0 comments on commit a1d337f

Please sign in to comment.