diff --git a/tests/test_output/results.py b/tests/test_output/results.py new file mode 100644 index 0000000000..8d51105462 --- /dev/null +++ b/tests/test_output/results.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import sys + +# import statepoint +sys.path.append('../../src/utils') +import statepoint + +# read in statepoint file +sp = statepoint.StatePoint('statepoint.10.binary') +sp.read_results() + +# set up output string +outstr = '' + +# write out k-combined +outstr += 'k-combined:\n' +outstr += "{0:10.8f} {1:10.8f}".format(sp.k_combined[0], sp.k_combined[1]) + +# write results to file +with open('results_test.dat','w') as fh: + fh.write(outstr) diff --git a/tests/test_output/results_true.dat b/tests/test_output/results_true.dat new file mode 100644 index 0000000000..c4825f272a --- /dev/null +++ b/tests/test_output/results_true.dat @@ -0,0 +1,2 @@ +k-combined: +0.30078030 0.00343315 \ No newline at end of file diff --git a/tests/test_output/test_output.py b/tests/test_output/test_output.py index 2a0f0433f5..64d6d988eb 100644 --- a/tests/test_output/test_output.py +++ b/tests/test_output/test_output.py @@ -2,6 +2,7 @@ import os from subprocess import Popen, STDOUT, PIPE +import filecmp pwd = os.path.dirname(__file__) @@ -24,9 +25,16 @@ def test_cross_sections_exists(): def test_statepoint_exists(): assert os.path.exists(pwd + '/statepoint.10.binary') +def test_results(): + os.system('python results.py') + compare = filecmp.cmp('results_test.dat', 'results_true.dat') + if not compare: + os.system('cp results_test.dat results_error.dat') + assert compare + def teardown(): output = [pwd + i for i in ['/statepoint.10.binary', '/summary.out', - '/cross_sections.out']] + '/cross_sections.out', '/results_test.dat']] for f in output: if os.path.exists(f): os.remove(f)