How to use _merge method in pytest-play

Best Python code snippet using pytest-play_python

test_methodbinder2.py

Source:test_methodbinder2.py Github

copy

Full Screen

...6970def _first(s): return _result_pair(s, 0)71def _second(s): return _result_pair(s, 100)7273def _merge(*args):74 ret = {}75 for arg in args:76 for (k, v) in arg.iteritems(): ret[k] = v77 return ret7879def _my_call(func, arg):80 if isinstance(arg, tuple):81 l = len(arg)82 if l == 0: func()83 elif l == 1: func(arg[0])84 elif l == 2: func(arg[0], arg[1])85 elif l == 3: func(arg[0], arg[1], arg[2])86 elif l == 4: func(arg[0], arg[1], arg[2], arg[3])87 elif l == 5: func(arg[0], arg[1], arg[2], arg[3], arg[4])88 elif l == 6: func(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5])89 else: func(*arg)90 else:91 func(arg)92 93def _try_arg(target, arg, mapping, funcTypeError, funcOverflowError, verbose=False):94 '''try the pass-in argument 'arg' on all methods 'target' has.95 mapping specifies (method-name, flag-value)96 funcOverflowError contains method-name, which will cause OverflowError when passing in 'arg'97 '''98 if verbose: print arg,99 for funcname in dir(target):100 if not _self_defined_method(funcname) : continue101 102 if verbose: print funcname,103 func = getattr(target, funcname)104105 if funcname in funcOverflowError: expectError = OverflowError106 elif funcname in funcTypeError: expectError = TypeError107 else: expectError = None108109 if isinstance(arg, types.lambdaType):110 arg = arg()111 try:112 _my_call(func, arg)113 except Exception, e:114 if expectError == None:115 Fail("unexpected exception %s when func %s with arg %s (%s)\n%s" % (e, funcname, arg, type(arg), func.__doc__))116117 if funcname in mapping.keys(): # No exception expected:118 Fail("unexpected exception %s when func %s with arg %s (%s)\n%s" % (e, funcname, arg, type(arg), func.__doc__))119120 if not isinstance(e, expectError):121 Fail("expect '%s', but got '%s' (flag %s) when func %s with arg %s (%s)\n%s" % (expectError, e, Flag.Value, funcname, arg, type(arg), func.__doc__))122 else:123 if not funcname in mapping.keys(): # Expecting exception124 Fail("expect %s, but got no exception (flag %s) when func %s with arg %s (%s)\n%s" % (expectError, Flag.Value, funcname, arg, type(arg), func.__doc__))125 126 left, right = Flag.Value, mapping[funcname]127 if left != right:128 Fail("left %s != right %s when func %s on arg %s (%s)\n%s" % (left, right, funcname, arg, type(arg), func.__doc__))129 Flag.Value = -99 # reset130 if verbose: print131 132def test_other_concerns():133 target = COtherOverloadConcern()134 135 # the one asking for Int32 is private136 target.M100(100)137 AreEqual(Flag.Value, 200); Flag.Value = 99138 139 # static / instance140 target.M110(target, 100)141 AreEqual(Flag.Value, 110); Flag.Value = 99142 COtherOverloadConcern.M110(100)143 AreEqual(Flag.Value, 210); Flag.Value = 99144 145 AssertError(TypeError, COtherOverloadConcern.M110, target, 100)146 147 # static / instance 2148 target.M111(100)149 AreEqual(Flag.Value, 111); Flag.Value = 99150 COtherOverloadConcern.M111(target, 100)151 AreEqual(Flag.Value, 211); Flag.Value = 99152 153 AssertError(TypeError, target.M111, target, 100)154 AssertError(TypeError, COtherOverloadConcern.M111, 100)155 156 # statics157 target.M120(target, 100)158 AreEqual(Flag.Value, 120); Flag.Value = 99159 target.M120(100)160 AreEqual(Flag.Value, 220); Flag.Value = 99161162 COtherOverloadConcern.M120(target, 100)163 AreEqual(Flag.Value, 120); Flag.Value = 99164 COtherOverloadConcern.M120(100)165 AreEqual(Flag.Value, 220); Flag.Value = 99166 167 # generic168 target.M130(100)169 AreEqual(Flag.Value, 130); Flag.Value = 99170171 target.M130(100.1234)172 AreEqual(Flag.Value, 230); Flag.Value = 99173174 target.M130(C1())175 AreEqual(Flag.Value, 230); Flag.Value = 99176177 for x in [100, 100.1234]:178 target.M130[int](x)179 AreEqual(Flag.Value, 230); Flag.Value = 99180 181 # narrowing levels and __int__ conversion182 target.M140(PT_C3_int(), PT_C3_int())183 AreEqual(Flag.Value, 140); Flag.Value = 99184185import clr186clrRefInt = clr.Reference[int](0)187188######### generated python code below #########189190def test_arg_ClrReference():191 target = COverloads_ClrReference()192 for (arg, mapping, funcTypeError, funcOverflowError) in [193(lambda : None, _merge(_first('M100 M101 M107 '), _second('M102 M104 M105 M106 ')), 'M103 ', '', ),194(lambda : clr.Reference[object](None), _second('M100 M104 M105 M107 '), 'M101 M102 M103 M104 M106 ', '', ),195(lambda : clr.Reference[object](None), _second('M100 M104 M105 M107 '), 'M101 M102 M103 M106 ', '', ),196(lambda : clr.Reference[int](9), _merge(_first('M100 M102 M103 M104 '), _second('M105 M107 ')), 'M101 M106 ', '', ),197(lambda : clr.Reference[bool](True), _merge(_first('M100 M105 '), _second('M101 M102 M104 M107 ')), 'M103 M106 ', '', ),198(lambda : clr.Reference[type](complex), _merge(_first('M100 '), _second('M104 M105 M107 ')), 'M101 M102 M103 M106 ', '', ),199(lambda : clr.Reference[C1](C1()), _merge(_first('M100 M106 M107 '), _second('M104 M105 ')), 'M101 M102 M103 ', '', ),200(lambda : clr.Reference[C1](C2()), _merge(_first('M100 M106 M107 '), _second('M104 M105 ')), 'M101 M102 M103 ', '', ),201 ]:202 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)203204def test_arg_NoArgNecessary():205 target = COverloads_NoArgNecessary()206 for (arg, mapping, funcTypeError, funcOverflowError) in [207( tuple(), _merge(_first('M100 M101 M102 M105 '), _second('M103 M104 M106 ')), '', '', ),208( 100, _merge(_first('M105 M106 '), _second('M101 M102 M103 M104 ')), 'M100 ', '', ),209( (100, 200), _second('M102 M104 M105 M106 '), 'M100 M101 M103 ', '', ),210( clrRefInt, _merge(_first('M103 M104 '), _second('M100 ')), 'M101 M102 M105 M106 ', '', ),211 ]:212 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)213214def test_arg_OneArg_NormalArg():215 target = COverloads_OneArg_NormalArg()216 for (arg, mapping, funcTypeError, funcOverflowError) in [217( tuple(), dict(), 'M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 ', '', ),218( 100, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 '), '', '', ),219( (100, 200), _second('M102 M107 M108 '), 'M100 M101 M103 M104 M105 M106 M109 ', '', ),220( clrRefInt, _second('M100 '), 'M101 M102 M103 M104 M105 M106 M107 M108 M109 ', '', ),221 ]:222 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)223224def test_arg_OneArg_RefArg():225 target = COverloads_OneArg_RefArg()226 for (arg, mapping, funcTypeError, funcOverflowError) in [227( tuple(), dict(), 'M100 M101 M102 M103 M104 M105 M106 M107 M108 ', '', ),228( 100, _merge(_first('M100 M101 M103 M105 M108 '), _second('M106 M107 ')), 'M102 M104 ', '', ),229( (100, 200), _second('M101 M106 M107 '), 'M100 M102 M103 M104 M105 M108 ', '', ),230( clrRefInt, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 '), '', '', ),231 ]:232 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)233234def test_arg_OneArg_NullableArg():235 target = COverloads_OneArg_NullableArg()236 for (arg, mapping, funcTypeError, funcOverflowError) in [237( tuple(), dict(), 'M100 M101 M102 M103 M104 M105 M106 M107 ', '', ),238( 100, _merge(_first('M100 M107 '), _second('M101 M102 M103 M104 M105 M106 ')), '', '', ),239( (100, 200), _second('M100 M105 M106 '), 'M101 M102 M103 M104 M107 ', '', ),240 ]:241 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)242243def test_arg_OneArg_TwoArgs():244 target = COverloads_OneArg_TwoArgs()245 for (arg, mapping, funcTypeError, funcOverflowError) in [246( tuple(), dict(), 'M100 M101 M102 M103 M104 M105 ', '', ),247( 100, _second('M100 M101 M102 M103 M104 '), 'M105 ', '', ),248( (100, 200), _first('M100 M101 M102 M103 M104 M105 '), '', '', ),249 ]:250 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)251252def test_arg_OneArg_NormalOut():253 target = COverloads_OneArg_NormalOut()254 for (arg, mapping, funcTypeError, funcOverflowError) in [255( tuple(), dict(), 'M100 M101 M102 M103 M104 M105 ', '', ),256( 100, _merge(_first('M100 M102 M105 '), _second('M103 M104 ')), 'M101 ', '', ),257( (100, 200), _second('M103 M104 '), 'M100 M101 M102 M105 ', '', ),258 ]:259 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)260261def test_arg_OneArg_RefOut():262 target = COverloads_OneArg_RefOut()263 for (arg, mapping, funcTypeError, funcOverflowError) in [264( tuple(), dict(), 'M100 M101 M102 M103 ', '', ),265( 100, _merge(_first('M103 '), _second('M100 M101 M102 ')), '', '', ),266( (100, 200), _second('M101 M102 '), 'M100 M103 ', '', ),267 ]:268 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)269270def test_arg_OneArg_OutNormal():271 target = COverloads_OneArg_OutNormal()272 for (arg, mapping, funcTypeError, funcOverflowError) in [273( tuple(), dict(), 'M100 M101 M102 M103 ', '', ),274( 100, _merge(_first('M100 M103 '), _second('M101 M102 ')), '', '', ),275( (100, 200), _second('M101 M102 '), 'M100 M103 ', '', ),276 ]:277 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)278279def test_arg_OneArg_OutRef():280 target = COverloads_OneArg_OutRef()281 for (arg, mapping, funcTypeError, funcOverflowError) in [282( tuple(), dict(), 'M100 M101 M102 ', '', ),283( 100, _merge(_first('M102 '), _second('M100 M101 ')), '', '', ),284( (100, 200), _second('M100 M101 '), 'M102 ', '', ),285 ]:286 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)287288def test_arg_OneArg_NormalDefault():289 target = COverloads_OneArg_NormalDefault()290 for (arg, mapping, funcTypeError, funcOverflowError) in [291( tuple(), dict(), 'M100 M101 ', '', ),292( 100, _first('M100 M101 '), '', '', ),293( (100, 200), _first('M100 M101 '), '', '', ),294 ]:295 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)296297def test_arg_String():298 target = COverloads_String()299 for (arg, mapping, funcTypeError, funcOverflowError) in [300( 'a', _merge(_first('M100 M101 '), _second('M102 ')), '', '', ),301( 'abc', _merge(_first('M100 M101 '), _second('M102 ')), '', '', ),302( mystr('a'), _merge(_first('M100 M101 '), _second('M102 ')), '', '', ),303(mystr('abc'), _merge(_first('M100 M101 '), _second('M102 ')), '', '', ),304( 1, _first('M101 M102 '), 'M100 ', '', ),305 ]:306 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)307308def test_arg_Enum():309 target = COverloads_Enum()310 for (arg, mapping, funcTypeError, funcOverflowError) in [311( E1.A, _first('M100 '), 'M101 ', '', ),312( E2.A, _first('M101 '), 'M100 ', '', ),313( 1, _second('M100 M101 '), '', '', ),314( UInt163, _second('M101 '), 'M100 ', '', ),315 ]:316 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)317318def test_arg_UserDefined():319 target = COverloads_UserDefined()320 for (arg, mapping, funcTypeError, funcOverflowError) in [321( C1(), _merge(_first('M101 M102 M103 M104 '), _second('M100 ')), 'M105 ', '', ),322( C2(), _merge(_first('M102 M103 '), _second('M100 M101 M104 ')), 'M105 ', '', ),323( C3(), _second('M103 '), 'M100 M101 M102 M104 M105 ', '', ),324( S1(), _first('M100 M101 M102 M103 '), 'M104 M105 ', '', ),325( C6(), _second('M103 M105 '), 'M100 M101 M102 M104 ', '', ),326( pt_i, _first('M100 M101 M102 M103 '), 'M104 M105 ', '', ),327( pt_c1, _merge(_first('M101 M102 M103 M104 '), _second('M100 ')), 'M105 ', '', ),328( pt_i_int, _first('M100 M101 M102 M103 '), 'M104 M105 ', '', ),329( pt_int_old, _second('M102 M103 '), 'M100 M101 M104 M105 ', '', ),330( pt_int_new, _second('M102 M103 '), 'M100 M101 M104 M105 ', '', ),331 ]:332 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)333334def test_arg_Derived_Number():335 target = COverloads_Derived_Number()336 for (arg, mapping, funcTypeError, funcOverflowError) in [337( None, _merge(_first('M106 '), _second('M102 M103 ')), 'M100 M101 M104 M105 ', '', ),338( True, _merge(_first('M100 M103 '), _second('M104 M105 M106 ')), 'M101 M102 ', '', ),339( -100, _merge(_first('M100 '), _second('M104 M105 M106 ')), 'M101 M102 M103 ', '', ),340( 200L, _merge(_first('M106 M105 '), _second('M100 M102 M101 ')), 'M103 M104 ', '', ),341( Byte10, _merge(_first('M103 '), _second('M100 M105 M106 ')), 'M101 M102 M104 ', '', ),342( 12.34, _merge(_first('M105 M106 '), _second('M101 M102 M100 ')), 'M103 M104 ', '', ),343 ]:344 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)345346def test_arg_Collections():347 target = COverloads_Collections()348 for (arg, mapping, funcTypeError, funcOverflowError) in [349( arrayInt, _merge(_first('M100 '), _second('M101 M102 M103 M104 ')), '', '', ),350( tupleInt, _merge(_first(''), _second('M100 M101 M102 M103 M104 ')), '', '', ),351( listInt, _merge(_first('M102 M104 '), _second('M100 M103 ')), 'M101 ', '', ),352( tupleLong1, _merge(_first(''), _second('M100 M101 M102 M103 M104 ')), '', '', ),353( tupleLong2, _merge(_first(''), _second('M100 M103 ')), '', 'M101 M102 M104 ', ),354( arrayByte, _first('M101 M103 M104 '), 'M100 M102 ', '', ),355( arrayObj, _merge(_first('M101 M102 M104 '), _second('M100 M103 ')), '', '', ),356 ]:357 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)358359#------------------------------------------------------------------------------360#--Boolean361def test_arg_boolean_overload():362 '''363 TODO:364 In addition to test_arg_boolean_overload, we need to split up test_arg_Boolean365 into two more functions as well - test_arg_boolean_overload_typeerror and366 test_arg_boolean_overload_overflowerror. This should be done for all of these367 types of tests to make them more readable and maintainable.368 '''369 o = COverloads_Boolean()370 371 param_method_map = {372 None : [ o.M100, o.M101, o.M102, o.M103, o.M104, o.M105, o.M106, 373 o.M107, o.M108, o.M109, o.M110, o.M111],374 True : [ o.M100, o.M101, o.M102, o.M103, o.M104, o.M105, o.M106, o.M107, o.M108, o.M109, o.M110, o.M111, o.M112],375 False : [ o.M100, o.M101, o.M102, o.M103, o.M104, o.M105, o.M106, o.M107, o.M108, o.M109, o.M110, o.M111, o.M112],376 100 : [ o.M100],377 myint(100): [ o.M100],378 -100 : [ o.M100],379 UInt32Max: [ o.M100, o.M106],380 200L : [ o.M100, o.M106, o.M109],381 -200L : [ o.M100, o.M106, o.M109],382 Byte10 : [ o.M100],383 SBytem10 : [ o.M100],384 Int1610 : [ o.M100],385 Int16m20 : [ o.M100],386 12.34 : [ o.M100, o.M101, o.M102, o.M103, o.M104, o.M105, o.M106, o.M107, o.M108, o.M109, o.M110],387 388 }389 390 for param in param_method_map.keys():391 for meth in param_method_map[param]:392 expected_flag = int(meth.__name__[1:])393 meth(param)394 AreEqual(expected_flag, Flag.Value)395 396397def test_arg_Boolean():398 target = COverloads_Boolean()399 for (arg, mapping, funcTypeError, funcOverflowError) in [400( None, _merge(_first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 '), _second('M112 ')), '', '', ),401( True, _merge(_first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), _second('')), '', '', ),402( False, _merge(_first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), _second('')), '', '', ),403( 100, _merge(_first('M100 '), _second('M106 M108 M109 M110 M111 M112 ')), 'M101 M102 M103 M104 M105 M107 ', '', ),404( myint(100), _merge(_first('M100 '), _second('M106 M108 M109 M110 M111 M112 ')), 'M101 M102 M103 M104 M105 M107 ', '', ),405( -100, _merge(_first('M100 '), _second('M106 M108 M109 M110 M111 M112 ')), 'M101 M102 M103 M104 M105 M107 ', '', ),406( UInt32Max, _merge(_first('M100 M106 '), _second('M105 M107 M108 M109 M110 M111 M112 ')), 'M101 M102 M103 M104 ', '', ),407( 200L, _merge(_first('M100 M106 M109 '), _second('M108 M112 M110 M111 ')), 'M101 M102 M103 M104 M105 M107 ', '', ),408( -200L, _merge(_first('M100 M106 M109 '), _second('M108 M112 M110 M111 ')), 'M101 M102 M103 M104 M105 M107 ', '', ),409( Byte10, _merge(_first('M100 '), _second('M101 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 ')), 'M102 ', '', ),410( SBytem10, _merge(_first('M100 '), _second('M102 M104 M106 M108 M109 M110 M111 M112 ')), 'M101 M103 M105 M107 ', '', ),411( Int1610, _merge(_first('M100 '), _second('M104 M106 M108 M109 M110 M111 M112 ')), 'M101 M102 M103 M105 M107 ', '', ),412( Int16m20, _merge(_first('M100 '), _second('M104 M106 M108 M109 M110 M111 M112 ')), 'M101 M102 M103 M105 M107 ', '', ),413( 12.34, _merge(_first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 '), _second('M111 M112 ')), '', '', ),414 ]:415 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)416417418def test_arg_Byte():419 target = COverloads_Byte()420 for (arg, mapping, funcTypeError, funcOverflowError) in [421( None, _merge(_first(''), _second('M100 M112 ')), 'M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 ', '', ),422( True, _merge(_first('M101 M102 M103 M104 M105 M107 '), _second('M100 M106 M108 M109 M110 M112 M111 ')), '', '', ),423( False, _merge(_first('M101 M102 M103 M104 M105 M107 '), _second('M100 M106 M108 M109 M110 M112 M111 ')), '', '', ),424( 100, _merge(_first('M101 M102 M103 M104 M105 M107 '), _second('M106 M108 M109 M110 M111 M112 ')), 'M100 ', '', ),425( myint(100), _merge(_first('M101 M102 M103 M104 M105 M107 '), _second('M106 M108 M109 M110 M111 M112 ')), 'M100 ', '', ),426( -100, _merge(_first(''), _second('M106 M108 M109 M110 M111 M112 ')), 'M100 ', 'M101 M102 M103 M104 M105 M107 ', ),427( UInt32Max, _merge(_first(''), _second('M105 M107 M108 M109 M110 M111 M112 ')), 'M100 ', 'M101 M102 M103 M104 M106 ', ),428( 200L, _merge(_first('M101 M102 M103 M104 M105 M106 M107 M109 '), _second('M108 M112 M110 M111 ')), 'M100 ', '', ),429( -200L, _merge(_first(''), _second('M108 M112 M110 M111 ')), 'M100 ', 'M101 M102 M103 M104 M105 M106 M107 M109 ', ),430( Byte10, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), '', '', ),431( SBytem10, _merge(_first(''), _second('M102 M104 M106 M108 M109 M110 M111 M112 ')), 'M100 ', 'M101 M103 M105 M107 ', ),432( Int1610, _merge(_first('M101 M102 M103 M105 M107 '), _second('M104 M106 M108 M109 M110 M111 M112 ')), 'M100 ', '', ),433( Int16m20, _merge(_first(''), _second('M104 M106 M108 M109 M110 M111 M112 ')), 'M100 ', 'M101 M102 M103 M105 M107 ', ),434( 12.34, _merge(_first('M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 '), _second('M100 M111 M112 ')), '', '', ),435 ]:436 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)437438def test_arg_Int16():439 target = COverloads_Int16()440 for (arg, mapping, funcTypeError, funcOverflowError) in [441( None, _merge(_first(''), _second('M100 M112 ')), 'M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 ', '', ),442( True, _merge(_first('M101 '), _second('M100 M102 M103 M104 M105 M107 M106 M108 M109 M110 M112 M111 ')), '', '', ),443( False, _merge(_first('M101 '), _second('M100 M102 M103 M104 M105 M107 M106 M108 M109 M110 M112 M111 ')), '', '', ),444( 100, _merge(_first('M101 '), _second('M102 M103 M104 M105 M107 M106 M108 M109 M110 M111 M112 ')), 'M100 ', '', ),445( myint(100), _merge(_first('M101 '), _second('M102 M103 M104 M105 M107 M106 M108 M109 M110 M111 M112 ')), 'M100 ', '', ),446( -100, _merge(_first('M101 '), _second('M103 M106 M108 M109 M110 M111 M112 ')), 'M100 ', 'M102 M104 M105 M107 ', ),447( UInt32Max, _merge(_first(''), _second('M105 M107 M108 M109 M110 M111 M112 ')), 'M100 ', 'M101 M102 M103 M104 M106 ', ),448( 200L, _merge(_first('M101 M106 M109 '), _second('M102 M104 M105 M107 M108 M110 M111 M112 ')), 'M100 ', 'M103 ', ),449( -200L, _merge(_first('M101 M106 M109 '), _second('M108 M110 M111 M112 ')), 'M100 ', 'M102 M103 M104 M105 M107 ', ),450( Byte10, _merge(_first('M100 M101 M103 M106 M108 M109 M110 M111 M112'), _second('M102 M104 M105 M107 ')), '', '', ),451( SBytem10, _merge(_first('M100 M101 M102 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), _second('M103 ')), '', '', ),452( Int1610, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), '', '', ),453( Int16m20, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), '', '', ),454( 12.34, _merge(_first('M101 M106 M108 M109 M110 '), _second('M100 M111 M112 M102 M103 M104 M105 M107 ')), '', '', ),455 ]:456 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)457458def test_arg_Int32():459 target = COverloads_Int32()460 for (arg, mapping, funcTypeError, funcOverflowError) in [461( None, _merge(_first(''), _second('M100 M112 ')), 'M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 ', '', ),462( True, _merge(_first('M101 M102 M103 M104 M105 M107 M106 M108 M109 M110 M112 M111 '), _second('M100 ')), '', '', ),463( False, _merge(_first('M101 M102 M103 M104 M105 M107 M106 M108 M109 M110 M112 M111 '), _second('M100 ')), '', '', ),464( 100, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), '', '', ),465( myint(100), _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), '', '', ),466( -100, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), '', '', ),467( UInt32Max, _merge(_first(''), _second('M100 M106 M107 M108 M109 M110 M111 M112 ')), '', 'M101 M102 M103 M104 M105 ', ),468( 200L, _merge(_first('M101 M109 '), _second('M100 M102 M104 M105 M106 M107 M108 M110 M111 M112 ')), '', 'M103 ', ),469( -200L, _merge(_first('M101 M109 '), _second('M100 M105 M108 M110 M111 M112 ')), '', 'M102 M103 M104 M106 M107 ', ),470( Byte10, _merge(_first('M100 M101 M103 M108 M109 M110 M111 M112'), _second('M102 M104 M105 M106 M107 ')), '', '', ),471( SBytem10, _merge(_first('M100 M101 M102 M104 M106 M107 M108 M109 M110 M111 M112 '), _second('M103 M105 ')), '', '', ),472( Int1610, _merge(_first('M100 M101 M102 M103 M104 M106 M107 M108 M109 M110 M111 M112 '), _second('M105 ')), '', '', ),473( Int16m20, _merge(_first('M100 M101 M102 M103 M104 M106 M107 M108 M109 M110 M111 M112 '), _second('M105 ')), '', '', ),474( 12.34, _merge(_first('M101 M108 M109 M110 '), _second('M100 M106 M111 M112 M102 M103 M104 M105 M107 ')), '', '', ),475 ]:476 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)477478def test_arg_Double():479 target = COverloads_Double()480 for (arg, mapping, funcTypeError, funcOverflowError) in [481( None, _merge(_first(''), _second('M100 M112 ')), 'M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 ', '', ),482( True, _merge(_first('M101 M102 M103 M104 M105 M106 M108 M112 '), _second('M100 M107 M109 M111 ')), 'M110 ', '', ),483( False, _merge(_first('M101 M102 M103 M104 M105 M106 M108 M112 '), _second('M100 M107 M109 M111 ')), 'M110 ', '', ),484( 100, _merge(_first('M100 M101 M102 M103 M104 M105 M106 M108 M112 '), _second('M107 M109 M111 ')), 'M110 ', '', ),485( myint(100), _merge(_first('M100 M101 M102 M103 M104 M105 M106 M108 M112 '), _second('M107 M109 M111 ')), 'M110 ', '', ),486( -100, _merge(_first('M100 M101 M102 M103 M104 M105 M106 M108 M112 '), _second('M107 M109 M111 ')), 'M110 ', '', ),487( UInt32Max, _merge(_first('M100 M101 M102 M103 M104 M105 M107 M112 '), _second('M106 M108 M109 M111 ')), 'M110 ', '', ),488( 200L, _merge(_first('M101 M100 M102 M103 M104 M105 M106 M107 M108 M109 M110 M112 '), _second('M111 ')), '', '', ),489( -200L, _merge(_first('M101 M100 M102 M103 M104 M105 M106 M107 M108 M109 M110 M112 '), _second('M111 ')), '', '', ),490( Byte10, _merge(_first('M100 M101 M103 M112 '), _second('M102 M104 M105 M106 M107 M108 M109 M111 ')), 'M110 ', '', ),491( SBytem10, _merge(_first('M100 M101 M102 M104 M106 M108 M112 '), _second('M103 M105 M107 M109 M111 ')), 'M110 ', '', ),492( Int1610, _merge(_first('M100 M101 M102 M103 M104 M106 M108 M112 '), _second('M105 M107 M109 M111 ')), 'M110 ', '', ),493( Int16m20, _merge(_first('M100 M101 M102 M103 M104 M106 M108 M112 '), _second('M105 M107 M109 M111 ')), 'M110 ', '', ),494( 12.34, _first('M100 M101 M102 M103 M104 M105 M106 M107 M108 M109 M110 M111 M112 '), '', '', ),495 ]:496 _try_arg(target, arg, mapping, funcTypeError, funcOverflowError)497 ...

Full Screen

Full Screen

md_compare.py

Source:md_compare.py Github

copy

Full Screen

...22 #add all information missing tables23 only_tbl=_tbl_only(s_only_df=tbl_lf_only_df,both_df=tbl_both_df,chk_lvl_1=chk_lvl_1)24 only_tbl=only_tbl.append(_tbl_only(s_only_df=tbl_rg_only_df,both_df=tbl_both_df,chk_lvl_1=chk_lvl_1))25 only_tbl_df=df.merge(only_tbl, how='inner', on=chk_lvl_1)26 only_tbl_df=_coalesce_merge(common_tbl_col= only_tbl_df)27 only_tbl_df=only_tbl_df.astype({"_merge":"str"})28 only_tbl_df.loc[only_tbl_df['_merge'] == "right_only", '_merge'] = right_p29 only_tbl_df.loc[only_tbl_df['_merge'] == "left_only", '_merge'] = left_p30 return only_tbl_df3132def build_diff_files(left_p,right_p,df=None,chk_lvl_1=None):3334 only_tbl_df=chk_prj_tbl(left_p=left_p,right_p=right_p,df=df,chk_lvl_1=chk_lvl_1)35 #column check only for tables existing in both projects36 common_tbl_col=df[~df.physical_table_name.isin(only_tbl_df.physical_table_name)]37 #common_tbl_col.to_excel("common_tbl_col.xlsx")38 common_col=common_tbl_col.query('_merge !="both" ')39 common_tbl_diff_pd=_coalesce_merge(common_tbl_col=common_tbl_col)40 common_col=common_tbl_diff_pd.astype({"_merge":"str"})4142 common_col.loc[common_col['_merge'] == "right_only", '_merge'] = right_p43 common_col.loc[common_col['_merge'] == "left_only", '_merge'] = left_p44 diff_update_l=[]45 diff_update_l.append({"col_diff":common_col})46 diff_update_l.append({"tbl_diff":only_tbl_df})47 return diff_update_l4849def _coalesce_merge(common_tbl_col=None):50 select_str=""51 for col in common_tbl_col.columns:52 if "_x" in col:53 common_tbl_col[''+col[:-2]+'']=common_tbl_col[''+ col[:-2] +'_x'].mask(pd.isnull, common_tbl_col[''+ col[:-2] +'_y'])54 common_tbl_col=common_tbl_col.drop(columns=[col[:-2] +'_x', col[:-2] +'_y'])55 elif "_y" in col:56 pass5758 return common_tbl_col5960def get_cube_data(conn=None,project_id=None,mtdi_id=None):61 conn.headers["X-MSTR-ProjectID"] = project_id62 cbe=_Cube(connection=conn,id=mtdi_id)63 df_cbe=cbe.to_dataframe(multi_df=True) ...

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 pytest-play 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