How to use _register method in gabbi

Best Python code snippet using gabbi_python

numerictypes.py

Source:numerictypes.py Github

copy

Full Screen

...64def IsType(rep):65 """Determines whether the given object or string, 'rep', represents66 a numarray type."""67 return isinstance(rep, NumericType) or rep in typeDict68def _register(name, type, force=0):69 """Register the type object. Raise an exception if it is already registered70 unless force is true.71 """72 if name in typeDict and not force:73 raise ValueError("Type %s has already been registered" % name)74 typeDict[name] = type75 return type76class NumericType(object):77 """Numeric type class78 Used both as a type identification and the repository of79 characteristics and conversion functions.80 """81 def __new__(type, name, bytes, default, typeno):82 """__new__() implements a 'quasi-singleton pattern because attempts83 to create duplicate types return the first created instance of that84 particular type parameterization, i.e. the second time you try to85 create "Int32", you get the original Int32, not a new one.86 """87 if name in typeDict:88 self = typeDict[name]89 if self.bytes != bytes or self.default != default or \90 self.typeno != typeno:91 raise ValueError("Redeclaration of existing NumericType "\92 "with different parameters.")93 return self94 else:95 self = object.__new__(type)96 self.name = "no name"97 self.bytes = None98 self.default = None99 self.typeno = -1100 return self101 def __init__(self, name, bytes, default, typeno):102 if not isinstance(name, str):103 raise TypeError("name must be a string")104 self.name = name105 self.bytes = bytes106 self.default = default107 self.typeno = typeno108 self._conv = None109 _register(self.name, self)110 def __getnewargs__(self):111 """support the pickling protocol."""112 return (self.name, self.bytes, self.default, self.typeno)113 def __getstate__(self):114 """support pickling protocol... no __setstate__ required."""115 False116class BooleanType(NumericType):117 pass118class SignedType:119 """Marker class used for signed type check"""120 pass121class UnsignedType:122 """Marker class used for unsigned type check"""123 pass124class IntegralType(NumericType):125 pass126class SignedIntegralType(IntegralType, SignedType):127 pass128class UnsignedIntegralType(IntegralType, UnsignedType):129 pass130class FloatingType(NumericType):131 pass132class ComplexType(NumericType):133 pass134class AnyType(NumericType):135 pass136class ObjectType(NumericType):137 pass138# C-API Type Any139Any = AnyType("Any", None, None, _tAny)140Object = ObjectType("Object", None, None, _tObject)141# Numeric Types:142Bool = BooleanType("Bool", 1, 0, _tBool)143Int8 = SignedIntegralType( "Int8", 1, 0, _tInt8)144Int16 = SignedIntegralType("Int16", 2, 0, _tInt16)145Int32 = SignedIntegralType("Int32", 4, 0, _tInt32)146Int64 = SignedIntegralType("Int64", 8, 0, _tInt64)147Float32 = FloatingType("Float32", 4, 0.0, _tFloat32)148Float64 = FloatingType("Float64", 8, 0.0, _tFloat64)149UInt8 = UnsignedIntegralType( "UInt8", 1, 0, _tUInt8)150UInt16 = UnsignedIntegralType("UInt16", 2, 0, _tUInt16)151UInt32 = UnsignedIntegralType("UInt32", 4, 0, _tUInt32)152UInt64 = UnsignedIntegralType("UInt64", 8, 0, _tUInt64)153Complex32 = ComplexType("Complex32", 8, complex(0.0), _tComplex32)154Complex64 = ComplexType("Complex64", 16, complex(0.0), _tComplex64)155Object.dtype = 'O'156Bool.dtype = '?'157Int8.dtype = 'i1'158Int16.dtype = 'i2'159Int32.dtype = 'i4'160Int64.dtype = 'i8'161UInt8.dtype = 'u1'162UInt16.dtype = 'u2'163UInt32.dtype = 'u4'164UInt64.dtype = 'u8'165Float32.dtype = 'f4'166Float64.dtype = 'f8'167Complex32.dtype = 'c8'168Complex64.dtype = 'c16'169# Aliases170Byte = _register("Byte", Int8)171Short = _register("Short", Int16)172Int = _register("Int", Int32)173if LP64:174 Long = _register("Long", Int64)175 if HasUInt64:176 _register("ULong", UInt64)177 MaybeLong = _register("MaybeLong", Int64)178 __all__.append('MaybeLong')179else:180 Long = _register("Long", Int32)181 _register("ULong", UInt32)182 MaybeLong = _register("MaybeLong", Int32)183 __all__.append('MaybeLong')184_register("UByte", UInt8)185_register("UShort", UInt16)186_register("UInt", UInt32)187Float = _register("Float", Float64)188Complex = _register("Complex", Complex64)189# short forms190_register("b1", Bool)191_register("u1", UInt8)192_register("u2", UInt16)193_register("u4", UInt32)194_register("i1", Int8)195_register("i2", Int16)196_register("i4", Int32)197_register("i8", Int64)198if HasUInt64:199 _register("u8", UInt64)200_register("f4", Float32)201_register("f8", Float64)202_register("c8", Complex32)203_register("c16", Complex64)204# NumPy forms205_register("1", Int8)206_register("B", Bool)207_register("c", Int8)208_register("b", UInt8)209_register("s", Int16)210_register("w", UInt16)211_register("i", Int32)212_register("N", Int64)213_register("u", UInt32)214_register("U", UInt64)215if LP64:216 _register("l", Int64)217else:218 _register("l", Int32)219_register("d", Float64)220_register("f", Float32)221_register("D", Complex64)222_register("F", Complex32)223# scipy.base forms224def _scipy_alias(scipy_type, numarray_type):225 _register(scipy_type, eval(numarray_type))226 globals()[scipy_type] = globals()[numarray_type]227_scipy_alias("bool_", "Bool")228_scipy_alias("bool8", "Bool")229_scipy_alias("int8", "Int8")230_scipy_alias("uint8", "UInt8")231_scipy_alias("int16", "Int16")232_scipy_alias("uint16", "UInt16")233_scipy_alias("int32", "Int32")234_scipy_alias("uint32", "UInt32")235_scipy_alias("int64", "Int64")236_scipy_alias("uint64", "UInt64")237_scipy_alias("float64", "Float64")238_scipy_alias("float32", "Float32")239_scipy_alias("complex128", "Complex64")...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...18 return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower()192021def register_known_commands(session):22 _register(session, Rpc('AclObjGetPermit', as_long, TypedObject, True))23 _register(session, Rpc('AclObjGetXPermit', as_long, TypedObject, True))24 _register(session, Rpc('ALLOW_BASE_AS_FEATURES', as_boolean, TypedObject))25 _register(session, Rpc('ALLOW_BASE_TYPE_CHANGES', as_boolean, TypedObject))26 _register(session, Rpc('AUDIT_ON', as_boolean, TypedObject))27 _register(session, Rpc('AUTHENTICATE_USER', as_object, TypedObject))28 _register(session, Rpc('CONVERT_ID', as_id, TypedObject, True))29 _register(session, Rpc('COUNT_SESSIONS', as_object, TypedObject))30 _register(session, Rpc('DB_STATS', as_object, TypedObject))31 _register(session, Rpc('DISABLE_TIMEOUT', as_boolean, TypedObject))32 _register(session, Rpc('DO_METHOD', as_object, TypedObject))33 _register(session, Rpc('DUMP_COUNTS', as_boolean, TypedObject))34 _register(session, Rpc('DUMP_CACHE', as_object, TypedObject))35 _register(session, Rpc('DUMP_JMS_CONFIG_LIST', as_object, TypedObject))36 _register(session, Rpc('ENABLE_TIMEOUT', as_boolean, TypedObject))37 _register(session, Rpc('ENCRYPT_PASSWORD', as_string, TypedObject))38 _register(session, Rpc('ENCRYPT_TEXT', as_string, TypedObject))39 _register(session, Rpc('END_PUSH_V2', as_object, TypedObject))40 _register(session, Rpc('ENTRY_POINTS', as_object, EntryPoints))41 _register(session, Rpc('EXEC', as_collection, Collection))42 _register(session, Rpc('EXEC_SELECT_SQL', as_collection, Collection))43 _register(session, Rpc('EXEC_SQL', as_boolean, Collection))44 _register(session, Rpc('FETCH', as_object, PersistentProxy, True))45 _register(session, Rpc('FETCH_TYPE', as_object, TypedObject))46 _register(session, Rpc('FTINDEX_AGENT_ADMIN', as_object, TypedObject))47 _register(session, Rpc('GET_ERRORS', as_collection, Collection))48 _register(session, Rpc('GET_DIST_CONTENT_MAP', as_object, TypedObject, True))49 _register(session, Rpc('GET_DOCBASE_CONFIG', as_object, TypedObject))50 _register(session, Rpc('GET_LAST_SQL', as_string, TypedObject))51 _register(session, Rpc('GET_LOGIN', as_string, TypedObject))52 _register(session, Rpc('GET_SERVER_CONFIG', as_object, TypedObject))53 _register(session, Rpc('GET_WORKFLOW_AGENT_STATUS', as_long, TypedObject))54 _register(session, Rpc('KILL_PULLER', as_boolean, TypedObject))55 _register(session, Rpc('LIST_SESSIONS', as_object, TypedObject))56 _register(session, Rpc('MAKE_PULLER', as_long, TypedObject))57 _register(session, Rpc('MAKE_PUSHER', as_long, TypedObject))58 _register(session, Rpc('SERVER_VERSION', as_string, TypedObject))59 _register(session, Rpc('SERVER_DIR', as_object, TypedObject))60 _register(session, Rpc('SET_LOCALE', as_boolean, TypedObject))61 _register(session, Rpc('SET_OPTIONS', as_boolean, TypedObject))62 _register(session, Rpc('SHOW_SESSIONS', as_collection, Collection))63 _register(session, Rpc('START_PUSH', as_boolean, TypedObject))64 _register(session, Rpc('TIME', as_time, TypedObject))65 _register(session, Rpc('SET_PUSH_OBJECT_STATUS', as_boolean, TypedObject))66 _register(session, Rpc('PUT_FILE', as_object, TypedObject))67 _register(session, Rpc('GET_TEMP_FILE', as_string, TypedObject))68 _register(session, Rpc('GET_FILE', as_string, TypedObject))69 _register(session, Rpc('NEXT_ID_LIST', as_next_id_list, TypedObject))70 _register(session, Rpc('CHECKOUT_LICENSE', as_object, TypedObject))71 _register(session, Rpc('SysObjSave', as_save_result, TypedObject, True))72 _register(session, Rpc('SAVE', as_save_result, TypedObject, True))73 _register(session, Rpc('SAVE_CONT_ATTRS', as_save_result, TypedObject, True))74 _register(session, Rpc('DQL_MATCH', as_collection, PersistentCollection))75 _register(session, Rpc('DUMP_COUNTS', as_object, TypedObject))76 _register(session, Rpc('FolderIdFindByPath', as_id, TypedObject))77 _register(session, Rpc('GETTYPE', as_string, TypedObject, True))78 _register(session, Rpc('GETTYPENAME', as_string, TypedObject, True))79 _register(session, Rpc('GET_LAST_SQL', as_string, TypedObject, True))80 _register(session, Rpc('GET_OBJECT_INFO', as_object, TypedObject))81 _register(session, Rpc('LOG_MESSAGE', as_boolean, TypedObject))82 _register(session, Rpc('STAMP_TRACE', as_boolean, TypedObject))83 _register(session, Rpc('LOG_OFF', as_boolean, TypedObject))84 _register(session, Rpc('LOG_ON', as_boolean, TypedObject))85 _register(session, Rpc('AUDIT_ON', as_boolean, TypedObject, True))86 _register(session, Rpc('AUDIT_SECURITY_FAILURE', as_boolean, TypedObject, True))87 _register(session, Rpc('AnyEvents', as_boolean, TypedObject))88 _register(session, Rpc('CLIENT_NAME', as_string, TypedObject))89 _register(session, Rpc('FIX_LINK_CNT', as_boolean, TypedObject, True))90 _register(session, Rpc('GET_ATTRIBUTE_DD_INFO', as_object, TypedObject))91 _register(session, Rpc('GET_ATTRIBUTE_NLS_INFO', as_object, TypedObject))92 _register(session, Rpc('GET_CONTENT_HASH', as_string, TypedObject, True))93 _register(session, Rpc('PROCESS_NEW_SERVER_MESSAGE', as_string, TypedObject, False))949596def _register(session, command):97 if command.command in session.entrypoints:98 session.known_commands[command.command] = command99100101def as_long(session, object_id, method, request=None, cls=None):102 if not object_id:103 object_id = NULL_ID104 return session.apply(RPC_APPLY_FOR_LONG, object_id, method, request, cls)105106107def as_save_result(session, object_id, method, request=None, cls=None):108 return as_long(session, object_id, method, request, cls) == 1109110 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run gabbi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful