예제 #1
0
    def test_function_type(self):
        def stringObj(c_ptr):
            char_ptr = ctypes.c_char_p(c_ptr)
            python_string = char_ptr.value
            return python_string.decode('ascii')

        Prototype.registerType("string_obj", stringObj)

        dateStamp  = TestUtilPrototype("string_obj util_alloc_date_stamp_utc()")
        date_stamp = dateStamp()
        self.assertIsInstance(date_stamp, string_types)
예제 #2
0
    def test_function_type(self):
        def stringObj(c_ptr):
            char_ptr = ctypes.c_char_p(c_ptr)
            python_string = char_ptr.value
            TestUtilPrototype.lib.free(c_ptr)
            return python_string

        Prototype.registerType("string_obj", stringObj)

        dateStamp = TestUtilPrototype("string_obj util_alloc_date_stamp_utc()")
        date_stamp = dateStamp()
        self.assertIsInstance(date_stamp, str)
예제 #3
0
from res.job_queue import QueueDriverEnum
from res.sched import HistorySourceEnum
from res.util.enums import MessageLevelEnum

# The res_config object should set the environment variable
# 'DATA_ROOT' to the root directory with the config
# file. Unfortunately the python methods to get environment variable,
# os.getenv() and os.environ[] do not reflect the:
#
#    setenv( "DATA_ROOT" , ...)
#
# call in the res_config C code. We therefore create a wrapper to the
# underlying libc getenv() function to be used for testing.

clib = load(None)
clib_getenv = Prototype(clib, "char* getenv( char* )", bind=False)

config_defines = {
    "<USER>": "TEST_USER",
    "<SCRATCH>": "scratch/ert",
    "<CASE_DIR>": "the_extensive_case",
    "<ECLIPSE_NAME>": "XYZ",
}

config_data = {
    "RUNPATH":
    "<SCRATCH>/<USER>/<CASE_DIR>/realization-%d/iter-%d",
    "NUM_REALIZATIONS":
    10,
    "MAX_RUNTIME":
    23400,
예제 #4
0
 def test_already_registered(self):
     with self.assertRaises(PrototypeError):
         Prototype.registerType("test_stringlist", None)
예제 #5
0
from ctypes import Structure, c_int
from cwrap import Prototype


class NodeId(Structure):
    """
    NodeId is specified in enkf_types.h
    """
    _fields_ = [("report_step", c_int), ("iens", c_int)]

    def __init__(self, report_step, realization_number):
        """
        @type report_step: int
        @type realization_number: int
        """
        super(NodeId, self).__init__(report_step, realization_number)

    def __repr__(self):
        rs = self.report_step
        ie = self.iens
        return 'NodeId(report_step = %d, iens = %d)' % (rs, ie)


Prototype.registerType("node_id", NodeId)
예제 #6
0
 def test_already_registered(self):
     with self.assertRaises(PrototypeError):
         Prototype.registerType("test_stringlist", None)
예제 #7
0
from ctypes import Structure, c_int
from cwrap import Prototype

class NodeId(Structure):
    """
    NodeId is specified in enkf_types.h
    """
    _fields_ = [("report_step", c_int),
                ("iens", c_int)]

    def __init__(self, report_step, realization_number):
        """
        @type report_step: int
        @type realization_number: int
        """
        super(NodeId, self).__init__(report_step, realization_number)

Prototype.registerType( "node_id" , NodeId )