Skip one test in test_track_output if vtk Python module is not available.

This commit is contained in:
Paul Romano 2013-11-07 10:17:51 +01:00
parent 19c52d915a
commit 727451319d

View file

@ -3,26 +3,32 @@
import os
from subprocess import Popen, STDOUT, PIPE, call
import filecmp
from nose_mpi import NoseMPI
import glob
from nose.plugins.skip import SkipTest
from nose_mpi import NoseMPI
pwd = os.path.dirname(__file__)
def setup():
def setup():
os.putenv('PWD', pwd)
os.chdir(pwd)
def test_run():
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
stderr=STDOUT, stdout=PIPE)
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
returncode = proc.wait()
print(proc.communicate()[0])
assert returncode == 0
def test_created_outputs():
outputs = [glob.glob(''.join((pwd, '/track_1_1_1.*')))]
outputs.append(glob.glob(''.join((pwd, '/track_1_1_2.*'))))
@ -30,7 +36,15 @@ def test_created_outputs():
assert len(files) == 1
assert files[0].endswith('binary') or files[0].endswith('h5')
def test_outputs():
# If vtk python module is not available, we can't run track.py so skip this
# test
try:
import vtk
except ImportError:
raise SkipTest
call(['../../src/utils/track.py', '-o', 'poly'] +
glob.glob(''.join((pwd, '/track*'))))
poly = ''.join((pwd, '/poly.pvtp'))
@ -41,6 +55,7 @@ def test_outputs():
os.rename('poly.pvtp', 'error_poly.pvtp')
assert compare
def teardown():
temp_files = glob.glob(''.join((pwd, '/statepoint*')))
temp_files = temp_files + glob.glob(''.join((pwd, '/track*')))