Best Python code snippet using playwright-python
opcodes.py
Source:opcodes.py
...10# some useful instruction patterns11Not = ['ldc.i4.0', 'ceq']12DoNothing = [PushAllArgs]13Ignore = []14def _not(op):15 return [PushAllArgs, op]+Not16def _abs(type_):17 return [PushAllArgs, 'call %s class [mscorlib]System.Math::Abs(%s)' % (type_, type_), StoreResult]18def _check_ovf(op):19 mapping = [('[mscorlib]System.OverflowException', 'exceptions.OverflowError')]20 return [MapException(op, mapping)]21def _check_zer(op):22 mapping = [('[mscorlib]System.DivideByZeroException', 'exceptions.ZeroDivisionError')]23 return [MapException(op, mapping)]24# __________ object oriented & misc operations __________25misc_ops = {26 'new': [New],27 'runtimenew': [RuntimeNew],28 'oosetfield': [SetField],29 'oogetfield': [GetField],30 'oosend': [CallMethod],31 'ooupcast': DoNothing,32 'oodowncast': [DownCast],33 'clibox': [Box],34 'cliunbox': [Unbox],35 'cli_newarray': [NewArray],36 'cli_getelem': [GetArrayElem],37 'cli_setelem': [SetArrayElem],38 'cli_typeof': [TypeOf],39 'cli_arraylength': 'ldlen',40 'cli_eventhandler': [EventHandler],41 'cli_getstaticfield': [GetStaticField],42 'cli_setstaticfield': [SetStaticField],43 'cli_fieldinfo_for_const': [FieldInfoForConst],44 'oois': 'ceq',45 'oononnull': [PushAllArgs, 'ldnull', 'ceq']+Not,46 'classof': [PushAllArgs, 'callvirt instance class [mscorlib]System.Type object::GetType()'],47 'instanceof': [CastTo, 'ldnull', 'cgt.un'],48 'subclassof': [PushAllArgs, 'call bool [pypylib]pypy.runtime.Utils::SubclassOf(class [mscorlib]System.Type, class[mscorlib]System.Type)'],49 'ooidentityhash': [PushAllArgs, 'callvirt instance int32 object::GetHashCode()'],50 'oohash': [PushAllArgs, 'callvirt instance int32 object::GetHashCode()'], 51 'oostring': [OOString],52 'oounicode': [OOUnicode],53 'ooparse_int': [PushAllArgs, 'call int32 [pypylib]pypy.runtime.Utils::OOParseInt(string, int32)'],54 'ooparse_float': [PushAllArgs, 'call float64 [pypylib]pypy.runtime.Utils::OOParseFloat(string)'],55 'oonewcustomdict': [NewCustomDict],56 'oonewarray': [OONewArray, StoreResult],57 58 'hint': [PushArg(0), StoreResult],59 'direct_call': [Call],60 'indirect_call': [IndirectCall],61 'cast_ptr_to_weakadr': [PushAllArgs, 'newobj instance void class %s::.ctor(object)' % WEAKREF],62 'gc__collect': 'call void class [mscorlib]System.GC::Collect()',63 'gc_set_max_heap_size': Ignore,64 'resume_point': Ignore,65 'debug_assert': Ignore,66 'keepalive': Ignore,67 'is_early_constant': [PushPrimitive(ootype.Bool, False)],68 }69# __________ numeric operations __________70unary_ops = {71 'same_as': DoNothing,72 73 'bool_not': [PushAllArgs]+Not,74 'int_is_true': [PushAllArgs, 'ldc.i4.0', 'cgt.un'],75 'int_neg': 'neg',76 'int_neg_ovf': _check_ovf(['ldc.i4.0', PushAllArgs, 'sub.ovf', StoreResult]),77 'int_abs': _abs('int32'),78 'int_abs_ovf': _check_ovf(_abs('int32')),79 'int_invert': 'not',80 'uint_is_true': [PushAllArgs, 'ldc.i4.0', 'cgt.un'],81 'uint_invert': 'not',82 'float_is_true': [PushAllArgs, 'ldc.r8 0', 'ceq']+Not,83 'float_neg': 'neg',84 'float_abs': _abs('float64'),85 'llong_is_true': [PushAllArgs, 'ldc.i8 0', 'cgt.un'],86 'llong_neg': 'neg',87 'llong_neg_ovf': _check_ovf(['ldc.i8 0', PushAllArgs, 'sub.ovf', StoreResult]),88 'llong_abs': _abs('int64'),89 'llong_abs_ovf': _check_ovf(_abs('int64')),90 'llong_invert': 'not',91 'ullong_is_true': [PushAllArgs, 'ldc.i8 0', 'cgt.un'],92 'ullong_invert': 'not',93 # when casting from bool we want that every truth value is casted94 # to 1: we can't simply DoNothing, because the CLI stack could95 # contains a truth value not equal to 1, so we should use the !=096 # trick.97 'cast_bool_to_int': [PushAllArgs, 'ldc.i4.0', 'ceq']+Not,98 'cast_bool_to_uint': [PushAllArgs, 'ldc.i4.0', 'ceq']+Not,99 'cast_bool_to_float': [PushAllArgs, 'ldc.i4.0', 'ceq']+Not+['conv.r8'],100 'cast_char_to_int': DoNothing,101 'cast_unichar_to_int': DoNothing,102 'cast_int_to_char': DoNothing,103 'cast_int_to_unichar': DoNothing,104 'cast_int_to_uint': DoNothing,105 'cast_int_to_float': 'conv.r8',106 'cast_int_to_longlong': 'conv.i8',107 'cast_uint_to_int': DoNothing,108 'cast_uint_to_float': [PushAllArgs, 'conv.u8', 'conv.r8'],109 'cast_float_to_int': 'conv.i4',110 'cast_float_to_uint': 'conv.u4',111 'cast_longlong_to_float': 'conv.r8',112 'cast_float_to_longlong': 'conv.i8',113 'cast_primitive': [PushAllArgs, CastPrimitive],114 'truncate_longlong_to_int': 'conv.i4',115 }116binary_ops = {117 'char_lt': 'clt',118 'char_le': _not('cgt'),119 'char_eq': 'ceq',120 'char_ne': _not('ceq'),121 'char_gt': 'cgt',122 'char_ge': _not('clt'),123 'unichar_eq': 'ceq',124 'unichar_ne': _not('ceq'),125 'int_add': 'add',126 'int_sub': 'sub',127 'int_mul': 'mul',128 'int_floordiv': 'div',129 'int_floordiv_zer': _check_zer('div'),130 'int_mod': 'rem',131 'int_lt': 'clt',132 'int_le': _not('cgt'),133 'int_eq': 'ceq',134 'int_ne': _not('ceq'),135 'int_gt': 'cgt',136 'int_ge': _not('clt'),137 'int_and': 'and',138 'int_or': 'or',139 'int_lshift': 'shl',140 'int_rshift': 'shr',141 'int_xor': 'xor',142 'int_add_ovf': _check_ovf('add.ovf'),143 'int_add_nonneg_ovf': _check_ovf('add.ovf'),144 'int_sub_ovf': _check_ovf('sub.ovf'),145 'int_mul_ovf': _check_ovf('mul.ovf'),146 'int_floordiv_ovf': 'div', # these can't overflow!147 'int_mod_ovf': 'rem',148 'int_lt_ovf': 'clt',149 'int_le_ovf': _not('cgt'),150 'int_eq_ovf': 'ceq',151 'int_ne_ovf': _not('ceq'),152 'int_gt_ovf': 'cgt',153 'int_ge_ovf': _not('clt'),154 'int_and_ovf': 'and',155 'int_or_ovf': 'or',156 'int_lshift_ovf': _check_ovf([PushArg(0),'conv.i8',PushArg(1), 'shl',157 'conv.ovf.i4', StoreResult]),158 'int_lshift_ovf_val': _check_ovf([PushArg(0),'conv.i8',PushArg(1), 'shl',159 'conv.ovf.i4', StoreResult]),160 'int_rshift_ovf': 'shr', # these can't overflow!161 'int_xor_ovf': 'xor',162 'int_floordiv_ovf_zer': _check_zer('div'),163 'int_mod_ovf_zer': _check_zer('rem'),164 'int_mod_zer': _check_zer('rem'),165 'uint_add': 'add',166 'uint_sub': 'sub',167 'uint_mul': 'mul',168 'uint_div': 'div.un',169 'uint_floordiv': 'div.un',170 'uint_mod': 'rem.un',171 'uint_lt': 'clt.un',172 'uint_le': _not('cgt.un'),173 'uint_eq': 'ceq',174 'uint_ne': _not('ceq'),175 'uint_gt': 'cgt.un',176 'uint_ge': _not('clt.un'),177 'uint_and': 'and',178 'uint_or': 'or',179 'uint_lshift': 'shl',180 'uint_rshift': 'shr.un',181 'uint_xor': 'xor',182 'float_add': 'add',183 'float_sub': 'sub',184 'float_mul': 'mul',185 'float_truediv': 'div', 186 'float_lt': 'clt',187 'float_le': _not('cgt'),188 'float_eq': 'ceq',189 'float_ne': _not('ceq'),190 'float_gt': 'cgt',191 'float_ge': _not('clt'),192 'llong_add': 'add',193 'llong_sub': 'sub',194 'llong_mul': 'mul',195 'llong_div': 'div',196 'llong_floordiv': 'div',197 'llong_floordiv_zer': _check_zer('div'),198 'llong_mod': 'rem',199 'llong_mod_zer': _check_zer('rem'),200 'llong_lt': 'clt',201 'llong_le': _not('cgt'),202 'llong_eq': 'ceq',203 'llong_ne': _not('ceq'),204 'llong_gt': 'cgt',205 'llong_ge': _not('clt'),206 'llong_and': 'and',207 'llong_or': 'or',208 'llong_lshift': 'shl',209 'llong_rshift': [PushAllArgs, 'conv.i4', 'shr'],210 'llong_xor': 'xor',211 'ullong_add': 'add',212 'ullong_sub': 'sub',213 'ullong_mul': 'mul',214 'ullong_div': 'div.un',215 'ullong_floordiv': 'div.un',216 'ullong_mod': 'rem.un',217 'ullong_lt': 'clt.un',218 'ullong_le': _not('cgt.un'),219 'ullong_eq': 'ceq',220 'ullong_ne': _not('ceq'),221 'ullong_gt': 'cgt.un',222 'ullong_ge': _not('clt.un'),223 'ullong_lshift': [PushAllArgs, 'conv.u4', 'shl'],224 'ullong_rshift': [PushAllArgs, 'conv.i4', 'shr'],225}226opcodes = misc_ops.copy()227opcodes.update(unary_ops)228opcodes.update(binary_ops)229for key, value in opcodes.iteritems():230 if type(value) is str:231 value = InstructionList([PushAllArgs, value, StoreResult])232 elif value is not None:233 if value is not Ignore and StoreResult not in value and not isinstance(value[0], MapException):234 value.append(StoreResult)235 value = InstructionList(value)236 opcodes[key] = value
flow_falcon_filter.py
Source:flow_falcon_filter.py
...62 :type: int63 """64 self._field = field65 @property66 def _not(self):67 """Gets the _not of this FlowFalconFilter. # noqa: E50168 :return: The _not of this FlowFalconFilter. # noqa: E50169 :rtype: bool70 """71 return self.__not72 @_not.setter73 def _not(self, _not):74 """Sets the _not of this FlowFalconFilter.75 :param _not: The _not of this FlowFalconFilter. # noqa: E50176 :type: bool77 """78 self.__not = _not79 @property80 def operator(self):81 """Gets the operator of this FlowFalconFilter. # noqa: E50182 :return: The operator of this FlowFalconFilter. # noqa: E50183 :rtype: str84 """85 return self._operator86 @operator.setter87 def operator(self, operator):...
contain_test.py
Source:contain_test.py
1from array import array2import pytest3def test_should_contain(should):4 'hello world' | should.contain('world') | should.contain('hello')5 'hello world' | should.contain('w') | should.contain('o')6 [1, 2, 3] | should.contain(1) | should.contain(3)7 ('foo', 'bar', 123) | should.contain('bar') | should.contain(123)8 {'foo', 'bar', 123} | should.contain('bar') | should.contain(123)9 [{'foo': 1}] | should.contain({'foo': 1})10 array('i', [1, 2, 3]) | should.contain(1) | should.contain(2)11 {'foo': 'bar', 'fuu': 2} | should.contain('bar') | should.contain(2)12 with pytest.raises(AssertionError):13 'hello world' | should.contain('planet')14 with pytest.raises(AssertionError):15 'hello world' | should.contain('t')16 with pytest.raises(AssertionError):17 [1, 2, 3] | should.contain(4)18 with pytest.raises(AssertionError):19 ('foo', 'bar', 123) | should.contain('baz')20 with pytest.raises(AssertionError):21 {'foo', 'bar', 123} | should.contain('baz')22 with pytest.raises(AssertionError):23 [{'foo': 1}] | should.contain({'foo': 2})24 with pytest.raises(AssertionError):25 array('i', [1, 2, 3]) | should.contain(4)26 with pytest.raises(AssertionError):27 {'foo': 'bar', 'fuu': 2} | should.contain('baz')28def test_should_contain_any(should):29 'hello world' | should.contain('world', 'hello')30 'hello world' | should.contain(('world', 'hello'))31 'hello world' | should.contain(['world', 'hello'])32 'hello world' | should.contain({'world', 'hello'})33 'hello world' | should.contain('w', 'o')34 'hello world' | should.contain(('w', 'o'))35 'hello world' | should.contain(['w', 'o'])36 'hello world' | should.contain({'w', 'o'})37 [1, 2, 3] | should.contain(1, 3)38 [1, 2, 3] | should.contain((1, 3))39 [1, 2, 3] | should.contain([1, 3])40 [1, 2, 3] | should.contain({1, 3})41 ('foo', 'bar', 123) | should.contain('bar', 123)42 {'foo', 'bar', 123} | should.contain(('bar', 123))43 {'foo', 'bar', 123} | should.contain({'bar', 123})44 {'foo', 'bar', 123} | should.contain(['bar', 123])45 [{'foo': 1}, {'bar': 2}] | should.contain({'foo': 1}, {'bar': 2})46 [{'foo': 1}, {'bar': 2}] | should.contain(({'foo': 1}, {'bar': 2}))47 [{'foo': 1}, {'bar': 2}] | should.contain([{'foo': 1}, {'bar': 2}])48 array('i', [1, 2, 3]) | should.contain(1, 2)49 array('i', [1, 2, 3]) | should.contain((1, 2))50 array('i', [1, 2, 3]) | should.contain({1, 2})51 array('i', [1, 2, 3]) | should.contain([1, 2])52 {'foo': 'bar', 'fuu': 'bor'} | should.contain('bar', 'bor')53 {'foo': 'bar', 'fuu': 'bor'} | should.contain(('bar', 'bor'))54 {'foo': 'bar', 'fuu': 'bor'} | should.contain(['bar', 'bor'])55 {'foo': 'bar', 'fuu': 'bor'} | should.contain({'bar', 'bor'})56def test_should_not_contain_any(should):57 'hello planet' | should._not.contain('world', 'hello')58 'hello planet' | should._not.contain(('world', 'hello'))59 'hello planet' | should._not.contain(['world', 'hello'])60 'hello planet' | should._not.contain({'world', 'hello'})61 'hello planet' | should._not.contain('w', 'o')62 'hello planet' | should._not.contain(('w', 'o'))63 'hello planet' | should._not.contain(['w', 'o'])64 'hello planet' | should._not.contain({'w', 'o'})65 [1, 2, 3] | should._not.contain(1, 4)66 [1, 2, 3] | should._not.contain((1, 4))67 [1, 2, 3] | should._not.contain([1, 4])68 [1, 2, 3] | should._not.contain({1, 4})69 ('foo', 'bar', 123) | should._not.contain('baz', 123)70 {'foo', 'bar', 123} | should._not.contain(('baz', 123))71 {'foo', 'bar', 123} | should._not.contain({'baz', 123})72 {'foo', 'bar', 123} | should._not.contain(['baz', 123])73 [{'foo': 1}, {'bar': 2}] | should._not.contain({'foo': 1}, {'baz': 2})74 [{'foo': 1}, {'bar': 2}] | should._not.contain(({'foo': 1}, {'baz': 2}))75 [{'foo': 1}, {'bar': 2}] | should._not.contain([{'foo': 1}, {'baz': 2}])76 array('i', [1, 2, 3]) | should._not.contain(1, 4)77 array('i', [1, 2, 3]) | should._not.contain((1, 4))78 array('i', [1, 2, 3]) | should._not.contain({1, 4})79 array('i', [1, 2, 3]) | should._not.contain([1, 4])80 {'foo': 'bar', 'fuu': 'bor'} | should._not.contain('baz', 'bor')81 {'foo': 'bar', 'fuu': 'bor'} | should._not.contain(('baz', 'bor'))82 {'foo': 'bar', 'fuu': 'bor'} | should._not.contain(['baz', 'bor'])83 {'foo': 'bar', 'fuu': 'bor'} | should._not.contain({'baz', 'bor'})84def test_should_contain_failures(should):85 with pytest.raises(AssertionError):86 () | should.contain('bar')87 with pytest.raises(AssertionError):...
simpleob_mod.py
Source:simpleob_mod.py
...16 Dout = [0 for i in range(len(Din))] 17 18 Dout[31] = Din[30]19 Dout[30] = Din[31]20 Dout[29] = _not(Din[29])21 Dout[28] = _xor([Din[28], Din[27]])22 Dout[27] = _and([Din[28], Din[27]])23 Dout[26] = _or([Din[26], Din[25]])24 Dout[25] = _and([Din[26], _not(Din[25])])25 Dout[24] = _or([Din[24], _not(Din[23])])26 Dout[23] = _nor([Din[24], _not(Din[23])])27 Dout[22] = _nand([Din[24], _not(Din[23])])28 Dout[21] = _nor([Din[22], Din[21], Din[20]])29 Dout[20] = _and([Din[22], _not(Din[21]), _not(Din[20])])30 Dout[19] = _nand([Din[22], Din[21], _not(Din[20])])31 Dout[18] = _or([Din[19], Din[18], _not(Din[17])])32 Dout[17] = _nand([_not(Din[19]), _not(Din[18]), _not(Din[16])])33 Dout[16] = _nor([_not(Din[19]), _not(Din[18]), _not(Din[16])])34 Dout[15] = _and([_not(Din[15]), _not(Din[14])])35 Dout[14] = _nand([(Din[15]), _not(Din[14])])36 Dout[13] = _nor([(Din[15]), _not(Din[14])])37 Dout[12] = _xor([Din[13], Din[12]])38 Dout[11] = _xnor([Din[13], Din[12]])39 Dout[10] = _switch(Din[11], Din[10], Din[9])40 Dout[9] = _switch(_not(Din[9]), Din[11], Din[10])41 Dout[8] = _nand([Din[11], _not(Din[10]), _not(Din[9])])42 Dout[7] = _xor([Din[8], Din[7], Din[6]])43 Dout[6] = _nand([Din[8], Din[7], _not(Din[6])])44 Dout[5] = Din[4]45 Dout[4] = Din[3]46 Dout[3] = Din[5]47 Dout[2] = _not(Din[0])48 Dout[1] = _not(Din[2])49 Dout[0] = _not(Din[1])50 return Dout51def convertBitArrayToInt(inbits):52 outbits_str = "0b"53 index = len(inbits) - 154 for i in range(len(inbits)):55 outbits_str += "{}".format(inbits[index])56 index -= 157 58 val = int(outbits_str, 2)59 return val60def convertBitArrayToHex(inbits):61 outbits_str = "0b"62 index = len(inbits) - 163 for i in range(len(inbits)):...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!