Skip to content

Commit

Permalink
Test needs to performed in stages, so as to ensure full reload of the…
Browse files Browse the repository at this point in the history
… CPP data
  • Loading branch information
makeclean committed Mar 21, 2019
1 parent 023abaa commit d8b377d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
47 changes: 47 additions & 0 deletions tests/test_material_data_external.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#65;5403;1c"""PyNE Material expand elements test under the presence of data or no data tests"""
import os
import math
import warnings

import nose
from nose.tools import assert_equal, assert_in, assert_true, assert_almost_equal
import numpy as np
import numpy.testing as npt

from pyne.utils import QAWarning
from pyne.pyne_config import pyne_conf

warnings.simplefilter("ignore", QAWarning)

import pyne
from pyne.material import Material
from pyne import data, nucname
from pyne import utils

from pyne.nucname import id

if utils.use_warnings():
utils.toggle_warnings()

nucvec = {'H': 1.0,
'Fe': 60.0,
'Mn': 39.0
}
def test_with_external_data():

mat = Material(nucvec,density=7.8)
mat = mat.expand_elements()

assert_equal(id('He3') in mat.comp,False)
assert_equal(id('Co58') in mat.comp,False)
assert_equal(id('Ni58') in mat.comp,False)

assert_equal(id('H1') in mat.comp,True)
assert_equal(id('Fe56') in mat.comp,True)
assert_equal(id('Mn55') in mat.comp,True)


# Run as script
#
if __name__ == "__main__":
nose.runmodule()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""PyNE Material expand elements test under the presence of data or no data tests"""
#65;5403;1c"""PyNE Material expand elements test under the presence of data or no data tests"""
import os
import math
import warnings
Expand Down Expand Up @@ -28,7 +28,7 @@
'Mn': 39.0
}

def test_with_no_data():
def test_with_internal_data():
orig = pyne_conf.NUC_DATA_PATH
pyne_conf.NUC_DATA_PATH = b'thisisanonsensedatapath'

Expand All @@ -41,20 +41,8 @@ def test_with_no_data():
assert_equal(id('H1') in mat.comp,True)
assert_equal(id('Fe56') in mat.comp,True)
assert_equal(id('Mn55') in mat.comp,True)

pyne_conf.NUC_DATA_PATH = orig


def test_with_data():
mat = Material(nucvec,density=7.8)
mat = mat.expand_elements()

assert_equal(id('He3') in mat.comp,False)
assert_equal(id('Co58') in mat.comp,False)
assert_equal(id('Ni58') in mat.comp,False)

assert_equal(id('H1') in mat.comp,True)
assert_equal(id('Fe56') in mat.comp,True)
assert_equal(id('Mn55') in mat.comp,True)

# Run as script
#
Expand Down

0 comments on commit d8b377d

Please sign in to comment.