Esempio n. 1
0
def test_relative_path():

    magicstring = '888777666'
    rsc_relative_path = "data/green.pl"
    resource_path = get_resource_path(rsc_relative_path)
    assert(os.path.isabs(resource_path))

    # test for the right file using magic number
    with open(resource_path, 'r') as rsc_file:
        magicstring_read = rsc_file.readline().split()[4]
    assert_equal(magicstring_read, magicstring)
Esempio n. 2
0
 def _build_materials(self):
     """
     Build 'self.materials' from 'materials' section in user_conf_dict.
     """
     self.materials = {}
     for material_data in self.user_conf_dict.pop("materials"):
         if material_data["name"] in self.materials:
             raise ValueError(
                 "Materialname {0} is already known."
                 "Every materialname has to be unique. "
                 "Did you name two materials the same?".format(material_data["name"])
             )
         if isinstance(material_data["nk"], str):
             material_data["nk"] = get_resource_path(material_data["nk"])
         m = Material(material_data["nk"])
         self.materials.update({material_data["name"]: m})