diff --git a/src/Makefile b/src/Makefile index 6107c37adc..433095c211 100644 --- a/src/Makefile +++ b/src/Makefile @@ -27,7 +27,7 @@ PETSC = no MPI_DIR = /opt/mpich/3.0.4-$(COMPILER) HDF5_DIR = /opt/hdf5/1.8.11-$(COMPILER) PHDF5_DIR = /opt/phdf5/1.8.11-$(COMPILER) -PETSC_DIR = /opt/petsc/3.3-p6-$(COMPILER) +PETSC_DIR = /opt/petsc/3.4.2-$(COMPILER) #=============================================================================== # Add git SHA-1 hash diff --git a/tests/run_tests.py b/tests/run_tests.py old mode 100644 new mode 100755 index ec0d02c16a..70df188ff9 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -17,7 +17,7 @@ for exe in openmc_exe: # run compile test result = nose.run(argv=['run_tests.py','-v','test_compile']) if not result: - sys.stdout('Did not pass compile tests.') + sys.stdout.write('Did not pass compile tests.') # run gfortran tests print '\n--------------' @@ -25,87 +25,96 @@ print 'gfortran tests' print '--------------\n' os.chdir(pwd) os.rename(pwd + '/../src/openmc-gfortran', pwd + '/../src/openmc') -result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic']) +result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile']) if not result: - sys.stdout('Did not pass gfortran tests') + sys.stdout.write('Did not pass gfortran tests') # run gfortran-dbg tests print '\n--------------' print 'gfortran-dbg tests' print '--------------\n' +os.chdir(pwd) os.rename(pwd + '/../src/openmc-gfortran-dbg', pwd + '/../src/openmc') -result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic']) +result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile']) if not result: - sys.stdout('Did not pass gfortran-dbg tests') + sys.stdout.write('Did not pass gfortran-dbg tests') # run gfortran-opt tests print '\n--------------' print 'gfortran-opt tests' print '--------------\n' +os.chdir(pwd) os.rename(pwd + '/../src/openmc-gfortran-opt', pwd + '/../src/openmc') -result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic']) +result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile']) if not result: - sys.stdout('Did not pass gfortran-opt tests') + sys.stdout.write('Did not pass gfortran-opt tests') # run gfortran-hdf5 tests print '\n--------------' print 'gfortran-hdf5 tests' print '--------------\n' -#os.rename(pwd + '/../src/openmc-gfortran-hdf5', pwd + '/../src/openmc') -#result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic']) -#if not result: -# sys.stdout('Did not pass gfortran-hdf5 tests') +os.chdir(pwd) +os.rename(pwd + '/../src/openmc-gfortran-hdf5', pwd + '/../src/openmc') +result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile']) +if not result: + sys.stdout.write('Did not pass gfortran-hdf5 tests') # run gfortran-mpi tests print '\n--------------' print 'gfortran-mpi tests' print '--------------\n' +os.chdir(pwd) os.rename(pwd + '/../src/openmc-gfortran-mpi', pwd + '/../src/openmc') result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile', '--mpi-np','3','--mpi-exec', - '/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic']) + '/opt/mpich/3.0.4-gnu/bin/mpiexec']) if not result: - sys.stdout('Did not pass gfortran-mpi tests') + sys.stdout.write('Did not pass gfortran-mpi tests') # run gfortran-phdf5 tests print '\n--------------' print 'gfortran-phdf5 tests' print '--------------\n' -#result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile', -# '--mpi-np','3','--mpi-exec', -# '/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic']) -#if not result: -# sys.stdout('Did not pass gfortran-phdf5 tests') +os.chdir(pwd) +os.rename(pwd + '/../src/openmc-gfortran-phdf5', pwd + '/../src/openmc') +result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile', + '--mpi-np','3','--mpi-exec', + '/opt/mpich/3.0.4-gnu/bin/mpiexec']) +if not result: + sys.stdout.write('Did not pass gfortran-phdf5 tests') # run gfortran-petsc tests print '\n--------------' print 'gfortran-petsc tests' print '--------------\n' +os.chdir(pwd) os.rename(pwd + '/../src/openmc-gfortran-petsc', pwd + '/../src/openmc') result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile', '--mpi-np','3','--mpi-exec', - '/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic']) + '/opt/mpich/3.0.4-gnu/bin/mpiexec']) if not result: - sys.stdout('Did not pass gfortran-petsc tests') + sys.stdout.write('Did not pass gfortran-petsc tests') # run gfortran-phdf5-petsc tests print '\n--------------' print 'gfortran-phdf5-petsc tests' print '--------------\n' +os.chdir(pwd) os.rename(pwd + '/../src/openmc-gfortran-phdf5-petsc', pwd + '/../src/openmc') result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile', '--mpi-np','3','--mpi-exec', - '/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic']) + '/opt/mpich/3.0.4-gnu/bin/mpiexec']) if not result: - sys.stdout('Did not pass gfortran-phdf5-petsc tests') + sys.stdout.write('Did not pass gfortran-phdf5-petsc tests') # run gfortran-phdf5-petsc-opt tests print '\n--------------' print 'gfortran-phdf5-petsc-opt tests' print '--------------\n' +os.chdir(pwd) os.rename(pwd + '/../src/openmc-gfortran-phdf5-petsc-opt', pwd + '/../src/openmc') result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile', '--mpi-np','3','--mpi-exec', - '/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic']) + '/opt/mpich/3.0.4-gnu/bin/mpiexec']) if not result: - sys.stdout('Did not pass gfortran-phdf5-petsc-opt tests') + sys.stdout.write('Did not pass gfortran-phdf5-petsc-opt tests') diff --git a/tests/test_basic/results.py b/tests/test_basic/results.py index eeb6ed27ec..36c3dfad28 100644 --- a/tests/test_basic/results.py +++ b/tests/test_basic/results.py @@ -8,9 +8,9 @@ import statepoint # read in statepoint file if len(sys.argv) > 1: - sp = statepoint.StatePoint(sys.argv[1]) + sp = statepoint.StatePoint(sys.argv[1]) else: - sp = statepoint.StatePoint('statepoint.10.binary') + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_basic/test_basic.py b/tests/test_basic/test_basic.py index c4595085cd..fe8344c15c 100644 --- a/tests/test_basic/test_basic.py +++ b/tests/test_basic/test_basic.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp from nose_mpi import NoseMPI import glob @@ -24,21 +24,21 @@ def test_run(): assert returncode == 0 def test_created_statepoint(): - statepoint = glob.glob('statepoint.10.*') + statepoint = glob.glob(pwd + '/statepoint.10.*') assert len(statepoint) == 1 assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - statepoint = glob.glob('statepoint.10.*') - os.system('python results.py {0}'.format(statepoint[0])) + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - statepoint = glob.glob('statepoint.10.*') - output = [pwd + '/{0}'.format(statepoint[0]), pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_confidence_intervals/results.py b/tests/test_confidence_intervals/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_confidence_intervals/results.py +++ b/tests/test_confidence_intervals/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_confidence_intervals/test_confidence_intervals.py b/tests/test_confidence_intervals/test_confidence_intervals.py index bb7f430615..a0dda8b468 100644 --- a/tests/test_confidence_intervals/test_confidence_intervals.py +++ b/tests/test_confidence_intervals/test_confidence_intervals.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,27 +13,36 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_created_output(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') + output.append(pwd + '/tallies.out') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_density_atombcm/results.py b/tests/test_density_atombcm/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_density_atombcm/results.py +++ b/tests/test_density_atombcm/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_density_atombcm/test_density_atombcm.py b/tests/test_density_atombcm/test_density_atombcm.py index 44e8b681c2..d13f404722 100644 --- a/tests/test_density_atombcm/test_density_atombcm.py +++ b/tests/test_density_atombcm/test_density_atombcm.py @@ -1,33 +1,44 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_density_atomcm3/results.py b/tests/test_density_atomcm3/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_density_atomcm3/results.py +++ b/tests/test_density_atomcm3/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_density_atomcm3/test_density_atomcm3.py b/tests/test_density_atomcm3/test_density_atomcm3.py index 44e8b681c2..860f858d34 100644 --- a/tests/test_density_atomcm3/test_density_atomcm3.py +++ b/tests/test_density_atomcm3/test_density_atomcm3.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob('statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_density_kgm3/results.py b/tests/test_density_kgm3/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_density_kgm3/results.py +++ b/tests/test_density_kgm3/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_density_kgm3/test_density_kgm3.py b/tests/test_density_kgm3/test_density_kgm3.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_density_kgm3/test_density_kgm3.py +++ b/tests/test_density_kgm3/test_density_kgm3.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_density_sum/results.py b/tests/test_density_sum/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_density_sum/results.py +++ b/tests/test_density_sum/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_density_sum/test_density_sum.py b/tests/test_density_sum/test_density_sum.py index 44e8b681c2..d1bc7d3a69 100644 --- a/tests/test_density_sum/test_density_sum.py +++ b/tests/test_density_sum/test_density_sum.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob('statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_eigenvalue_genperbatch/results.py b/tests/test_eigenvalue_genperbatch/results.py index 8591730a8e..9df94f76df 100644 --- a/tests/test_eigenvalue_genperbatch/results.py +++ b/tests/test_eigenvalue_genperbatch/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.7.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.7.binary') sp.read_results() # set up output string diff --git a/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py b/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py index 042586c38b..eb4e206c1b 100644 --- a/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py +++ b/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.7.binary') + statepoint = glob.glob(pwd + '/statepoint.7.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.7.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.7.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.7.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_eigenvalue_no_inactive/results.py b/tests/test_eigenvalue_no_inactive/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_eigenvalue_no_inactive/results.py +++ b/tests/test_eigenvalue_no_inactive/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py b/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py +++ b/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_energy_grid/results.py b/tests/test_energy_grid/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_energy_grid/results.py +++ b/tests/test_energy_grid/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_energy_grid/test_energy_grid.py b/tests/test_energy_grid/test_energy_grid.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_energy_grid/test_energy_grid.py +++ b/tests/test_energy_grid/test_energy_grid.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_entropy/results.py b/tests/test_entropy/results.py index d4fa17d4e1..87ccd0fd32 100644 --- a/tests/test_entropy/results.py +++ b/tests/test_entropy/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_entropy/test_entropy.py b/tests/test_entropy/test_entropy.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_entropy/test_entropy.py +++ b/tests/test_entropy/test_entropy.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_cell/results.py b/tests/test_filter_cell/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_cell/results.py +++ b/tests/test_filter_cell/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_cell/test_filter_cell.py b/tests/test_filter_cell/test_filter_cell.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_cell/test_filter_cell.py +++ b/tests/test_filter_cell/test_filter_cell.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_cellborn/results.py b/tests/test_filter_cellborn/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_cellborn/results.py +++ b/tests/test_filter_cellborn/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_cellborn/test_filter_cellborn.py b/tests/test_filter_cellborn/test_filter_cellborn.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_cellborn/test_filter_cellborn.py +++ b/tests/test_filter_cellborn/test_filter_cellborn.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_energy/results.py b/tests/test_filter_energy/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_energy/results.py +++ b/tests/test_filter_energy/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_energy/test_filter_energy.py b/tests/test_filter_energy/test_filter_energy.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_energy/test_filter_energy.py +++ b/tests/test_filter_energy/test_filter_energy.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_energyout/results.py b/tests/test_filter_energyout/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_energyout/results.py +++ b/tests/test_filter_energyout/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_energyout/test_filter_energyout.py b/tests/test_filter_energyout/test_filter_energyout.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_energyout/test_filter_energyout.py +++ b/tests/test_filter_energyout/test_filter_energyout.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_group_transfer/results.py b/tests/test_filter_group_transfer/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_group_transfer/results.py +++ b/tests/test_filter_group_transfer/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_group_transfer/test_filter_group_transfer.py b/tests/test_filter_group_transfer/test_filter_group_transfer.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_group_transfer/test_filter_group_transfer.py +++ b/tests/test_filter_group_transfer/test_filter_group_transfer.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_material/results.py b/tests/test_filter_material/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_material/results.py +++ b/tests/test_filter_material/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_material/test_filter_material.py b/tests/test_filter_material/test_filter_material.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_material/test_filter_material.py +++ b/tests/test_filter_material/test_filter_material.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_mesh_2d/results.py b/tests/test_filter_mesh_2d/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_mesh_2d/results.py +++ b/tests/test_filter_mesh_2d/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_mesh_2d/test_filter_mesh_2d.py b/tests/test_filter_mesh_2d/test_filter_mesh_2d.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_mesh_2d/test_filter_mesh_2d.py +++ b/tests/test_filter_mesh_2d/test_filter_mesh_2d.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_mesh_3d/results.py b/tests/test_filter_mesh_3d/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_mesh_3d/results.py +++ b/tests/test_filter_mesh_3d/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_mesh_3d/test_filter_mesh_3d.py b/tests/test_filter_mesh_3d/test_filter_mesh_3d.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_mesh_3d/test_filter_mesh_3d.py +++ b/tests/test_filter_mesh_3d/test_filter_mesh_3d.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_filter_universe/results.py b/tests/test_filter_universe/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_filter_universe/results.py +++ b/tests/test_filter_universe/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_filter_universe/test_filter_universe.py b/tests/test_filter_universe/test_filter_universe.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_filter_universe/test_filter_universe.py +++ b/tests/test_filter_universe/test_filter_universe.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_fixed_source/results.py b/tests/test_fixed_source/results.py index 5f68ab742c..c843a70a63 100644 --- a/tests/test_fixed_source/results.py +++ b/tests/test_fixed_source/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_fixed_source/test_fixed_source.py b/tests/test_fixed_source/test_fixed_source.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_fixed_source/test_fixed_source.py +++ b/tests/test_fixed_source/test_fixed_source.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_lattice/results.py b/tests/test_lattice/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_lattice/results.py +++ b/tests/test_lattice/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_lattice/test_lattice.py b/tests/test_lattice/test_lattice.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_lattice/test_lattice.py +++ b/tests/test_lattice/test_lattice.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_lattice_multiple/results.py b/tests/test_lattice_multiple/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_lattice_multiple/results.py +++ b/tests/test_lattice_multiple/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_lattice_multiple/test_lattice_multiple.py b/tests/test_lattice_multiple/test_lattice_multiple.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_lattice_multiple/test_lattice_multiple.py +++ b/tests/test_lattice_multiple/test_lattice_multiple.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_natural_element/results.py b/tests/test_natural_element/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_natural_element/results.py +++ b/tests/test_natural_element/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_natural_element/test_natural_element.py b/tests/test_natural_element/test_natural_element.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_natural_element/test_natural_element.py +++ b/tests/test_natural_element/test_natural_element.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_output/results.py b/tests/test_output/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_output/results.py +++ b/tests/test_output/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_output/test_output.py b/tests/test_output/test_output.py index 820f15f0f6..0d74bd4955 100644 --- a/tests/test_output/test_output.py +++ b/tests/test_output/test_output.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,7 +13,12 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 @@ -23,18 +30,23 @@ def test_cross_sections_exists(): assert os.path.exists(pwd + '/cross_sections.out') def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + i for i in ['/statepoint.10.binary', '/summary.out', - '/cross_sections.out', '/results_test.dat']] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/summary.out') + output.append(pwd + '/cross_sections.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_particle_restart/results.py b/tests/test_particle_restart/results.py index 9361357e7e..3ba0bc7d42 100644 --- a/tests/test_particle_restart/results.py +++ b/tests/test_particle_restart/results.py @@ -7,7 +7,11 @@ sys.path.append('../../src/utils') import particle_restart as pr # read in particle restart file -p = pr.Particle('particle_10_903.binary') +if len(sys.argv) > 1: + p = pr.Particle(sys.argv[1]) +else: + p = pr.Particle('particle_10_903.binary') + # set up output string outstr = '' diff --git a/tests/test_particle_restart/test_particle_restart.py b/tests/test_particle_restart/test_particle_restart.py index 17e4690f46..64ac2f8a70 100644 --- a/tests/test_particle_restart/test_particle_restart.py +++ b/tests/test_particle_restart/test_particle_restart.py @@ -1,8 +1,9 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI import glob pwd = os.path.dirname(__file__) @@ -12,22 +13,36 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=PIPE, stdout=PIPE) + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path], + stderr=PIPE, stdout=PIPE) + else: + proc = Popen([openmc_path], stderr=PIPE, stdout=PIPE) stdout, stderr = proc.communicate() - assert stderr != '' + assert stderr != '' def test_created_restart(): - assert os.path.exists(pwd + '/particle_10_903.binary') + particle = glob.glob(pwd + '/particle_10_903.*') + assert len(particle) == 1 + assert particle[0].endswith('binary') or \ + particle[0].endswith('h5') + particle = glob.glob(pwd + '/particle_8_777.*') + assert len(particle) == 1 + assert particle[0].endswith('binary') or \ + particle[0].endswith('h5') def test_results(): - os.system('python results.py') + particle = glob.glob(pwd + '/particle_10_903.*') + call(['python', 'results.py', particle[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def test_run_restart(): - proc = Popen([pwd + '/../../src/openmc -r particle_10_903.binary'], + particle = glob.glob(pwd + '/particle_10_903.*') + proc = Popen([pwd + '/../../src/openmc -r ' + particle[0]], stderr=PIPE, stdout=PIPE, shell=True) stdout, stderr = proc.communicate() assert stderr == '' diff --git a/tests/test_plot_background/test_plot_background.py b/tests/test_plot_background/test_plot_background.py index 21977eaacb..a34b5bbfb7 100644 --- a/tests/test_plot_background/test_plot_background.py +++ b/tests/test_plot_background/test_plot_background.py @@ -2,6 +2,7 @@ import os from subprocess import Popen, STDOUT, PIPE +from nose_mpi import NoseMPI pwd = os.path.dirname(__file__) @@ -10,7 +11,12 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc', '-p'], stderr=STDOUT, stdout=PIPE) + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 diff --git a/tests/test_plot_basis/test_plot_basis.py b/tests/test_plot_basis/test_plot_basis.py index 3ae72c9981..fe0a13ccac 100644 --- a/tests/test_plot_basis/test_plot_basis.py +++ b/tests/test_plot_basis/test_plot_basis.py @@ -2,6 +2,7 @@ import os from subprocess import Popen, STDOUT, PIPE +from nose_mpi import NoseMPI pwd = os.path.dirname(__file__) @@ -10,7 +11,12 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc', '-p'], stderr=STDOUT, stdout=PIPE) + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 diff --git a/tests/test_plot_colspec/test_plot_colspec.py b/tests/test_plot_colspec/test_plot_colspec.py index 21977eaacb..a34b5bbfb7 100644 --- a/tests/test_plot_colspec/test_plot_colspec.py +++ b/tests/test_plot_colspec/test_plot_colspec.py @@ -2,6 +2,7 @@ import os from subprocess import Popen, STDOUT, PIPE +from nose_mpi import NoseMPI pwd = os.path.dirname(__file__) @@ -10,7 +11,12 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc', '-p'], stderr=STDOUT, stdout=PIPE) + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 diff --git a/tests/test_plot_mask/test_plot_mask.py b/tests/test_plot_mask/test_plot_mask.py index 3ae72c9981..fe0a13ccac 100644 --- a/tests/test_plot_mask/test_plot_mask.py +++ b/tests/test_plot_mask/test_plot_mask.py @@ -2,6 +2,7 @@ import os from subprocess import Popen, STDOUT, PIPE +from nose_mpi import NoseMPI pwd = os.path.dirname(__file__) @@ -10,7 +11,12 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc', '-p'], stderr=STDOUT, stdout=PIPE) + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 diff --git a/tests/test_ptables_off/results.py b/tests/test_ptables_off/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_ptables_off/results.py +++ b/tests/test_ptables_off/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_ptables_off/test_ptables_off.py b/tests/test_ptables_off/test_ptables_off.py index 44e8b681c2..5194a209f8 100644 --- a/tests/test_ptables_off/test_ptables_off.py +++ b/tests/test_ptables_off/test_ptables_off.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + 'statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_reflective_cone/results.py b/tests/test_reflective_cone/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_reflective_cone/results.py +++ b/tests/test_reflective_cone/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_reflective_cone/test_reflective_cone.py b/tests/test_reflective_cone/test_reflective_cone.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_reflective_cone/test_reflective_cone.py +++ b/tests/test_reflective_cone/test_reflective_cone.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_reflective_cylinder/results.py b/tests/test_reflective_cylinder/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_reflective_cylinder/results.py +++ b/tests/test_reflective_cylinder/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_reflective_cylinder/test_reflective_cylinder.py b/tests/test_reflective_cylinder/test_reflective_cylinder.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_reflective_cylinder/test_reflective_cylinder.py +++ b/tests/test_reflective_cylinder/test_reflective_cylinder.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_reflective_plane/results.py b/tests/test_reflective_plane/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_reflective_plane/results.py +++ b/tests/test_reflective_plane/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_reflective_plane/test_reflective_plane.py b/tests/test_reflective_plane/test_reflective_plane.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_reflective_plane/test_reflective_plane.py +++ b/tests/test_reflective_plane/test_reflective_plane.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_reflective_sphere/results.py b/tests/test_reflective_sphere/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_reflective_sphere/results.py +++ b/tests/test_reflective_sphere/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_reflective_sphere/test_reflective_sphere.py b/tests/test_reflective_sphere/test_reflective_sphere.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_reflective_sphere/test_reflective_sphere.py +++ b/tests/test_reflective_sphere/test_reflective_sphere.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_rotation/results.py b/tests/test_rotation/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_rotation/results.py +++ b/tests/test_rotation/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_rotation/test_rotation.py b/tests/test_rotation/test_rotation.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_rotation/test_rotation.py +++ b/tests/test_rotation/test_rotation.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_salphabeta/results.py b/tests/test_salphabeta/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_salphabeta/results.py +++ b/tests/test_salphabeta/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_salphabeta/test_salphabeta.py b/tests/test_salphabeta/test_salphabeta.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_salphabeta/test_salphabeta.py +++ b/tests/test_salphabeta/test_salphabeta.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_salphabeta_multiple/results.py b/tests/test_salphabeta_multiple/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_salphabeta_multiple/results.py +++ b/tests/test_salphabeta_multiple/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_salphabeta_multiple/test_salphabeta_multiple.py b/tests/test_salphabeta_multiple/test_salphabeta_multiple.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_salphabeta_multiple/test_salphabeta_multiple.py +++ b/tests/test_salphabeta_multiple/test_salphabeta_multiple.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_MT/results.py b/tests/test_score_MT/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_MT/results.py +++ b/tests/test_score_MT/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_MT/test_score_MT.py b/tests/test_score_MT/test_score_MT.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_MT/test_score_MT.py +++ b/tests/test_score_MT/test_score_MT.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_absorption/results.py b/tests/test_score_absorption/results.py index d6ab485d95..917eedad6b 100644 --- a/tests/test_score_absorption/results.py +++ b/tests/test_score_absorption/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_absorption/test_score_absorption.py b/tests/test_score_absorption/test_score_absorption.py index cf8b2e51ce..b49faa8177 100644 --- a/tests/test_score_absorption/test_score_absorption.py +++ b/tests/test_score_absorption/test_score_absorption.py @@ -1,37 +1,49 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) + diff --git a/tests/test_score_current/results.py b/tests/test_score_current/results.py index d6ab485d95..917eedad6b 100644 --- a/tests/test_score_current/results.py +++ b/tests/test_score_current/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_current/test_score_current.py b/tests/test_score_current/test_score_current.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_current/test_score_current.py +++ b/tests/test_score_current/test_score_current.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_events/results.py b/tests/test_score_events/results.py index d6ab485d95..917eedad6b 100644 --- a/tests/test_score_events/results.py +++ b/tests/test_score_events/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_events/test_score_events.py b/tests/test_score_events/test_score_events.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_events/test_score_events.py +++ b/tests/test_score_events/test_score_events.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_fission/results.py b/tests/test_score_fission/results.py index d6ab485d95..917eedad6b 100644 --- a/tests/test_score_fission/results.py +++ b/tests/test_score_fission/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_fission/test_score_fission.py b/tests/test_score_fission/test_score_fission.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_fission/test_score_fission.py +++ b/tests/test_score_fission/test_score_fission.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_flux/results.py b/tests/test_score_flux/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_flux/results.py +++ b/tests/test_score_flux/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_flux/test_score_flux.py b/tests/test_score_flux/test_score_flux.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_flux/test_score_flux.py +++ b/tests/test_score_flux/test_score_flux.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_kappafission/results.py b/tests/test_score_kappafission/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_kappafission/results.py +++ b/tests/test_score_kappafission/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_kappafission/test_score_kappafission.py b/tests/test_score_kappafission/test_score_kappafission.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_kappafission/test_score_kappafission.py +++ b/tests/test_score_kappafission/test_score_kappafission.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_nufission/results.py b/tests/test_score_nufission/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_nufission/results.py +++ b/tests/test_score_nufission/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_nufission/test_score_nufission.py b/tests/test_score_nufission/test_score_nufission.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_nufission/test_score_nufission.py +++ b/tests/test_score_nufission/test_score_nufission.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_nuscatter/results.py b/tests/test_score_nuscatter/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_nuscatter/results.py +++ b/tests/test_score_nuscatter/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_nuscatter/test_score_nuscatter.py b/tests/test_score_nuscatter/test_score_nuscatter.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_nuscatter/test_score_nuscatter.py +++ b/tests/test_score_nuscatter/test_score_nuscatter.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_scatter/results.py b/tests/test_score_scatter/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_scatter/results.py +++ b/tests/test_score_scatter/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_scatter/test_score_scatter.py b/tests/test_score_scatter/test_score_scatter.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_scatter/test_score_scatter.py +++ b/tests/test_score_scatter/test_score_scatter.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_scatter_n/results.py b/tests/test_score_scatter_n/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_scatter_n/results.py +++ b/tests/test_score_scatter_n/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_scatter_n/test_score_scatter_n.py b/tests/test_score_scatter_n/test_score_scatter_n.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_scatter_n/test_score_scatter_n.py +++ b/tests/test_score_scatter_n/test_score_scatter_n.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_scatter_pn/results.py b/tests/test_score_scatter_pn/results.py index d6ab485d95..917eedad6b 100644 --- a/tests/test_score_scatter_pn/results.py +++ b/tests/test_score_scatter_pn/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_scatter_pn/test_score_scatter_pn.py b/tests/test_score_scatter_pn/test_score_scatter_pn.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_scatter_pn/test_score_scatter_pn.py +++ b/tests/test_score_scatter_pn/test_score_scatter_pn.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_score_total/results.py b/tests/test_score_total/results.py index f2f03137bf..9f404aad3c 100644 --- a/tests/test_score_total/results.py +++ b/tests/test_score_total/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_score_total/test_score_total.py b/tests/test_score_total/test_score_total.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_score_total/test_score_total.py +++ b/tests/test_score_total/test_score_total.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_seed/results.py b/tests/test_seed/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_seed/results.py +++ b/tests/test_seed/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_seed/test_seed.py b/tests/test_seed/test_seed.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_seed/test_seed.py +++ b/tests/test_seed/test_seed.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_source_angle_mono/results.py b/tests/test_source_angle_mono/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_source_angle_mono/results.py +++ b/tests/test_source_angle_mono/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_source_angle_mono/test_source_angle_mono.py b/tests/test_source_angle_mono/test_source_angle_mono.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_source_angle_mono/test_source_angle_mono.py +++ b/tests/test_source_angle_mono/test_source_angle_mono.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_source_energy_maxwell/results.py b/tests/test_source_energy_maxwell/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_source_energy_maxwell/results.py +++ b/tests/test_source_energy_maxwell/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_source_energy_maxwell/test_source_energy_maxwell.py b/tests/test_source_energy_maxwell/test_source_energy_maxwell.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_source_energy_maxwell/test_source_energy_maxwell.py +++ b/tests/test_source_energy_maxwell/test_source_energy_maxwell.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_source_energy_mono/results.py b/tests/test_source_energy_mono/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_source_energy_mono/results.py +++ b/tests/test_source_energy_mono/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_source_energy_mono/test_source_energy_mono.py b/tests/test_source_energy_mono/test_source_energy_mono.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_source_energy_mono/test_source_energy_mono.py +++ b/tests/test_source_energy_mono/test_source_energy_mono.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_source_point/results.py b/tests/test_source_point/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_source_point/results.py +++ b/tests/test_source_point/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_source_point/test_source_point.py b/tests/test_source_point/test_source_point.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_source_point/test_source_point.py +++ b/tests/test_source_point/test_source_point.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_statepoint_batch/results.py b/tests/test_statepoint_batch/results.py index f6ea70d44b..35cc0490de 100644 --- a/tests/test_statepoint_batch/results.py +++ b/tests/test_statepoint_batch/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.9.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.9.binary') sp.read_results() # set up output string diff --git a/tests/test_statepoint_batch/test_statepoint_batch.py b/tests/test_statepoint_batch/test_statepoint_batch.py index d6d290e780..57d00dbe8f 100644 --- a/tests/test_statepoint_batch/test_statepoint_batch.py +++ b/tests/test_statepoint_batch/test_statepoint_batch.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,28 +13,38 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_statepoints_exist(): - assert os.path.exists(pwd + '/statepoint.3.binary') - assert os.path.exists(pwd + '/statepoint.6.binary') - assert os.path.exists(pwd + '/statepoint.9.binary') + statepoint = glob.glob(pwd + '/statepoint.3.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + statepoint = glob.glob(pwd + '/statepoint.6.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + statepoint = glob.glob(pwd + '/statepoint.9.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.9.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + i for i in ['/statepoint.3.binary', - '/statepoint.6.binary', - '/statepoint.9.binary', - '/results_test.dat']] + output = glob.glob(pwd + '/statepoint*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_statepoint_interval/results.py b/tests/test_statepoint_interval/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_statepoint_interval/results.py +++ b/tests/test_statepoint_interval/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_statepoint_interval/test_statepoint_interval.py b/tests/test_statepoint_interval/test_statepoint_interval.py index 0dcd339f00..4e9410856d 100644 --- a/tests/test_statepoint_interval/test_statepoint_interval.py +++ b/tests/test_statepoint_interval/test_statepoint_interval.py @@ -4,6 +4,8 @@ import os import glob from subprocess import Popen, STDOUT, PIPE import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -12,17 +14,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_statepoints_exist(): - assert os.path.exists(pwd + '/statepoint.2.binary') - assert os.path.exists(pwd + '/statepoint.4.binary') - assert os.path.exists(pwd + '/statepoint.6.binary') - assert os.path.exists(pwd + '/statepoint.8.binary') - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.2.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + statepoint = glob.glob(pwd + '/statepoint.4.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + statepoint = glob.glob(pwd + '/statepoint.6.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + statepoint = glob.glob(pwd + '/statepoint.8.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): os.system('python results.py') @@ -32,7 +49,7 @@ def test_results(): assert compare def teardown(): - output = glob.glob(pwd + '/statepoint.*.binary') + output = glob.glob(pwd + '/statepoint.*') output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): diff --git a/tests/test_statepoint_restart/results.py b/tests/test_statepoint_restart/results.py index 1ece75ed8b..917eedad6b 100644 --- a/tests/test_statepoint_restart/results.py +++ b/tests/test_statepoint_restart/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.7.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_statepoint_restart/test_statepoint_restart.py b/tests/test_statepoint_restart/test_statepoint_restart.py index 8e9e8d1d73..7a880d59b0 100644 --- a/tests/test_statepoint_restart/test_statepoint_restart.py +++ b/tests/test_statepoint_restart/test_statepoint_restart.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,51 +13,108 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 - assert os.path.exists(pwd + '/statepoint.7.binary') + +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.7.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.7.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def test_restart_form1(): - proc = Popen([pwd + '/../../src/openmc', '-r', - pwd + '/statepoint.7.binary'], - stderr=STDOUT, stdout=PIPE) + statepoint = glob.glob(pwd + '/statepoint.7.*') + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, + '-r', statepoint[0]], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path, '-r', statepoint[0]], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 +def test_created_statepoint_form1(): + statepoint = glob.glob(pwd + '/statepoint.7.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + def test_results_form1(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.7.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def test_restart_form2(): - proc = Popen([pwd + '/../../src/openmc', '--restart', - pwd + '/statepoint.7.binary'], - stderr=STDOUT, stdout=PIPE) + statepoint = glob.glob(pwd + '/statepoint.7.*') + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, + '--restart', statepoint[0]], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path, '--restart', statepoint[0]], + stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 +def test_created_statepoint_form2(): + statepoint = glob.glob(pwd + '/statepoint.7.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + def test_results_form2(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.7.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare +def test_restart_serial(): + statepoint = glob.glob(pwd + '/statepoint.7.*') + openmc_path = pwd + '/../../src/openmc' + proc = Popen([openmc_path, '--restart', statepoint[0]], + stderr=STDOUT, stdout=PIPE) + returncode = proc.wait() + print(proc.communicate()[0]) + assert returncode == 0 + +def test_created_statepoint_serial(): + statepoint = glob.glob(pwd + '/statepoint.7.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + +def test_results_serial(): + statepoint = glob.glob(pwd + '/statepoint.7.*') + call(['python', 'results.py', statepoint[0]]) + compare = filecmp.cmp('results_test.dat', 'results_true.dat') + if not compare: + os.rename('results_test.dat', 'results_error.dat') + assert compare + + def teardown(): - output = [pwd + '/statepoint.7.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.7.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_statepoint_sourcesep/results.py b/tests/test_statepoint_sourcesep/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_statepoint_sourcesep/results.py +++ b/tests/test_statepoint_sourcesep/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py index 82b4a051bb..821492dea5 100644 --- a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py +++ b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,25 +13,36 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') - assert os.path.exists(pwd + '/source.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + source = glob.glob(pwd + '/source.10.*') + assert len(statepoint) == 1 + assert source[0].endswith('binary') or source[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/source.10.binary', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/source.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_survival_biasing/results.py b/tests/test_survival_biasing/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_survival_biasing/results.py +++ b/tests/test_survival_biasing/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_survival_biasing/test_survival_biasing.py b/tests/test_survival_biasing/test_survival_biasing.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_survival_biasing/test_survival_biasing.py +++ b/tests/test_survival_biasing/test_survival_biasing.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_tally_assumesep/results.py b/tests/test_tally_assumesep/results.py index 36ecc08c6e..a8ef259d83 100644 --- a/tests/test_tally_assumesep/results.py +++ b/tests/test_tally_assumesep/results.py @@ -8,7 +8,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # extract tally results and convert to vector diff --git a/tests/test_tally_assumesep/test_tally_assumesep.py b/tests/test_tally_assumesep/test_tally_assumesep.py index cf8b2e51ce..62c4d7316a 100644 --- a/tests/test_tally_assumesep/test_tally_assumesep.py +++ b/tests/test_tally_assumesep/test_tally_assumesep.py @@ -1,37 +1,48 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) -def setup(): +def setup(): os.putenv('PWD', pwd) os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 -def test_statepoint_exists(): - assert os.path.exists(pwd + '/statepoint.10.binary') +def test_created_statepoint(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_output_exists(): assert os.path.exists(pwd + '/tallies.out') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out', - pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/tallies.out') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_trace/results.py b/tests/test_trace/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_trace/results.py +++ b/tests/test_trace/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_trace/test_trace.py b/tests/test_trace/test_trace.py index c708108256..d618dfc5e8 100644 --- a/tests/test_trace/test_trace.py +++ b/tests/test_trace/test_trace.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,7 +13,12 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() stdout = proc.communicate()[0] print(stdout) @@ -19,17 +26,21 @@ def test_run(): assert stdout.find('Simulating Particle 453') != -1 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_translation/results.py b/tests/test_translation/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_translation/results.py +++ b/tests/test_translation/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_translation/test_translation.py b/tests/test_translation/test_translation.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_translation/test_translation.py +++ b/tests/test_translation/test_translation.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_uniform_fs/results.py b/tests/test_uniform_fs/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_uniform_fs/results.py +++ b/tests/test_uniform_fs/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_uniform_fs/test_uniform_fs.py b/tests/test_uniform_fs/test_uniform_fs.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_uniform_fs/test_uniform_fs.py +++ b/tests/test_uniform_fs/test_uniform_fs.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_universe/results.py b/tests/test_universe/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_universe/results.py +++ b/tests/test_universe/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_universe/test_universe.py b/tests/test_universe/test_universe.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_universe/test_universe.py +++ b/tests/test_universe/test_universe.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f) diff --git a/tests/test_void/results.py b/tests/test_void/results.py index f7c8a47fb6..36c3dfad28 100644 --- a/tests/test_void/results.py +++ b/tests/test_void/results.py @@ -7,7 +7,10 @@ sys.path.append('../../src/utils') import statepoint # read in statepoint file -sp = statepoint.StatePoint('statepoint.10.binary') +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.10.binary') sp.read_results() # set up output string diff --git a/tests/test_void/test_void.py b/tests/test_void/test_void.py index 44e8b681c2..fe8344c15c 100644 --- a/tests/test_void/test_void.py +++ b/tests/test_void/test_void.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import os -from subprocess import Popen, STDOUT, PIPE +from subprocess import Popen, STDOUT, PIPE, call import filecmp +from nose_mpi import NoseMPI +import glob pwd = os.path.dirname(__file__) @@ -11,23 +13,32 @@ def setup(): os.chdir(pwd) def test_run(): - proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE) + 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) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() print(proc.communicate()[0]) assert returncode == 0 def test_created_statepoint(): - assert os.path.exists(pwd + '/statepoint.10.binary') + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') def test_results(): - os.system('python results.py') + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare def teardown(): - output = [pwd + '/statepoint.10.binary', pwd + '/results_test.dat'] + output = glob.glob(pwd + '/statepoint.10.*') + output.append(pwd + '/results_test.dat') for f in output: if os.path.exists(f): os.remove(f)