Best Python code snippet using hypothesis
transaction_test.py
Source:transaction_test.py  
1import unittest2import pymongo3import mongo_driver4from mongo_driver import Document, connect, clear_all5from mongo_driver.fields import *6from mongo_driver.session import DEFAULT_READ_CONCERN, DEFAULT_READ_PREFERENCE, DEFAULT_WRITE_CONCERN7from mongo_driver.errors import TransactionError8from mongo_driver.slave_ok_setting import SlaveOkSetting9class Doc(Document):10    meta = {11        'db_name': 'test'12    }13    test_int = IntField()14    name = StringField()15    test_push = ListField(IntField())16    test_set = ListField(IntField())17    test_pull = ListField(IntField())18class TransactionTests(unittest.TestCase):19    def setUp(self):20        try:21            connect(db_names=['test'])22        except ConnectionError:23            self.skipTest('Mongo service is not started localhost')24    def tearDown(self):25        clear_all()26    def test_configuration(self):27        class DocTest(Document):28            meta = {29                'db_name': 'test',30                # the following configuration will be ignored in transaction context31                'write_concern': 10,32                'wtimeout': 1000,33            }34            test_int = IntField()35            name = StringField()36        connection = DocTest.get_connection()37        session = connection.start_session()38        transaction_context = session.start_transaction()39        self.assertEqual(40            transaction_context._transaction.opts.read_concern, DEFAULT_READ_CONCERN)41        self.assertEqual(42            transaction_context._transaction.opts.write_concern, DEFAULT_WRITE_CONCERN)43        self.assertEqual(44            transaction_context._transaction.opts.read_preference, DEFAULT_READ_PREFERENCE)45        doc = DocTest(test_int=1)46        with connection.start_session() as session:47            self.assertRaises(mongo_driver.errors.OperationError, doc.save)48            self.assertRaises(mongo_driver.errors.OperationError,49                              doc.save, session=session)50            with session.start_transaction():51                self.assertRaises(mongo_driver.errors.OperationError, doc.save)52                DocTest.remove({}, session=session)53                doc.save(session=session)54                self.assertEqual(DocTest.count({}, session=session), 1)55            self.assertEqual(DocTest.count({}, session=session), 1)56    def test_exception(self):57        connection = Doc.get_connection()58        session = connection.start_session()59        session.start_transaction()60        self.assertRaises(TransactionError, session.start_transaction)61        session.abort_transaction()62        self.assertRaises(TransactionError, session.abort_transaction)63    def test_read_in_or_out_transaction(self):64        Doc.remove({})65        def test_func(session, raise_exception=False):66            Doc.update({67                'test_int': 168            }, {69                '$set': {70                    'test_int': 271                }72            }, upsert=True, session=session)73            # find74            result_1, result_2 = Doc.find(75                {}), Doc.find({}, session=session)76            # aggregate77            result_3, result_4 = list(Doc.aggregate(78                [])), list(Doc.aggregate([], session=session))79            self.assertEqual(len(result_1), 0)80            self.assertEqual(len(result_2), 1)81            # count82            self.assertEqual(Doc.count({}), 0)83            self.assertEqual(Doc.count({}, session=session), 1)84            self.assertEqual(len(result_3), 0)85            self.assertEqual(len(result_4), 1)86            self.assertEqual(result_4[0]['_id'], result_2[0].id)87            doc = result_2[0]88            Doc.update({89                'test_int': 290            }, {91                '$set': {92                    'test_int': 393                }94            }, session=session)95            if raise_exception:96                raise Exception()97            # reload, without session, won't get anything98            doc.reload()99            self.assertEqual(doc.test_int, 2)100            doc.reload(session=session)101            self.assertEqual(doc.test_int, 3)102            # by_ids103            result_1, result_2 = Doc.by_ids(104                [doc.id]), Doc.by_ids([doc.id], session=session)105            self.assertEqual(len(result_1), 0)106            self.assertEqual(len(result_2), 1)107            # by_id108            result_1, result_2 = Doc.by_id(109                doc.id), Doc.by_id(doc.id, session=session)110            self.assertEqual(result_2.id, doc.id)111            self.assertEqual(result_1, None)112            # find_one113            result_1, result_2 = Doc.find_one(114                {}), Doc.find_one({}, session=session)115            self.assertEqual(result_2.id, doc.id)116            self.assertEqual(result_1, None)117            # distinct118            result_1, result_2 = Doc.distinct({}, 'test_int'), Doc.distinct(119                {}, 'test_int', session=session)120            self.assertEqual(result_1, [])121            self.assertEqual(result_2, [3])122            # find_iter123            iter_1, iter_2 = Doc.find_iter(124                {}), Doc.find_iter({}, session=session)125            self.assertEqual(len(list(iter_1)), 0)126            self.assertEqual(len(list(iter_2)), 1)127        with Doc.get_connection().start_session() as session:128            # test case when exception raised in transaction, we shall get nothing129            try:130                with session.start_transaction():131                    test_func(session, raise_exception=True)132            except Exception:133                pass134            self.assertEqual(Doc.count({}), 0)135            self.assertEqual(Doc.count({}, session=session), 0)136            # test case when exception raised in non-transaction mode, we will get first result137            try:138                test_func(session, raise_exception=True)139            except Exception:140                pass141            self.assertEqual(Doc.count({}), 1)142            self.assertEqual(Doc.count({}, session=session), 1)143            doc = Doc.find_one({}, session=session)144            self.assertEqual(doc.test_int, 2)145            Doc.remove({})146            with session.start_transaction():147                test_func(session)148            doc = Doc.find_one({}, session=session)149            self.assertEqual(doc.test_int, 3)150            Doc.remove({})151            # test case not using 'with' keyword with transaction152            # will abort transaction after session ended153            session.start_transaction()154            test_func(session)155        self.assertEqual(Doc.count(), 0)156        def test_func2(session, raise_exception=False):157            A = Doc.find_one({'name': 'A'}, session=session)158            B = Doc.find_one({'name': 'B'}, session=session)159            A.inc(test_int=-50, _session=session)160            if raise_exception:161                raise Exception()162            B.inc(test_int=50, _session=session)163        with Doc.get_connection().start_session() as session:164            Doc.update({165                'name': 'A'166            }, {167                '$set': {168                    'test_int': 100169                }170            }, upsert=True, session=session)171            Doc.update({172                'name': 'B'173            }, {174                '$set': {175                    'test_int': 0176                }177            }, upsert=True, session=session)178            A = Doc.find_one({'name': 'A'}, session=session)179            B = Doc.find_one({'name': 'B'}, session=session)180            try:181                with session.start_transaction():182                    test_func2(session, raise_exception=True)183            except Exception:184                pass185            A.reload(session=session)186            B.reload(session=session)187            self.assertEqual(A.test_int, 100)188            self.assertEqual(B.test_int, 0)189            with session.start_transaction():190                test_func2(session)191            A.reload(session=session)192            B.reload(session=session)193            self.assertEqual((A.test_int, B.test_int), (50, 50))194    def test_update(self):195        def test_func(session, raise_exception=False):196            Doc.update({197                'test_int': 1198            }, {199                '$inc': {200                    'test_int': 1201                }202            }, session=session)203            Doc.update({204                'test_int': 2205            }, {206                '$inc': {207                    'test_int': 1208                }209            }, session=session)210            if raise_exception:211                raise Exception()212            Doc.update({213                'test_int': 3214            }, {215                '$inc': {216                    'test_int': 1217                }218            }, session=session)219        Doc.drop_collection()220        Doc(test_int=1).save()221        Doc(test_int=1).save()222        Doc(test_int=1).save()223        with Doc.get_connection().start_session() as session:224            try:225                with session.start_transaction():226                    test_func(session, raise_exception=True)227            except Exception:228                pass229            self.assertEqual(Doc.count({}, session=session), 3)230            self.assertEqual(Doc.count({'test_int': 1}, session=session), 3)231            with session.start_transaction():232                test_func(session)233            self.assertEqual(Doc.count({}, session=session), 3)234            self.assertEqual(Doc.count({'test_int': 4}, session=session), 3)235        self.assertEqual(Doc.count(), 3)236        self.assertEqual(Doc.count({'test_int': 4}), 3)237    def test_find_and_modify(self):238        def test_func(session, raise_exception=False):239            Doc.find_and_modify({240                'test_int': 1241            }, {242                '$inc': {'test_int': 1}243            }, session=session)244            Doc.find_and_modify({245                'test_int': 2246            }, {247                '$inc': {'test_int': 1}248            }, session=session)249            if raise_exception:250                raise Exception()251            Doc.find_and_modify({252                'test_int': 3253            }, {254                '$inc': {'test_int': 1}255            }, session=session)256        Doc.drop_collection()257        Doc(test_int=1).save()258        Doc(test_int=1).save()259        Doc(test_int=1).save()260        with Doc.get_connection().start_session() as session:261            try:262                with session.start_transaction():263                    test_func(session, raise_exception=True)264            except Exception:265                pass266            self.assertEqual(Doc.count({}, session=session), 3)267            self.assertEqual(Doc.count({'test_int': 1}, session=session), 3)268            with session.start_transaction():269                test_func(session)270            self.assertEqual(Doc.count({}, session=session), 3)271            self.assertEqual(Doc.count({'test_int': 4}, session=session), 1)272        self.assertEqual(Doc.count(), 3)273        self.assertEqual(Doc.count({'test_int': 4}), 1)274    def test_remove(self):275        Doc.drop_collection()276        Doc(test_int=1, test_list1=[]).save()277        Doc(test_int=1).save()278        Doc(test_int=1).save()279        def test_func(session, raise_exception=False):280            Doc.remove({'test_int': 1}, multi=False, session=session)281            Doc.remove({'test_int': 1}, multi=False, session=session)282            if raise_exception:283                raise Exception()284            Doc.remove({'test_int': 1}, multi=False, session=session)285        with Doc.get_connection().start_session() as session:286            try:287                with session.start_transaction():288                    test_func(session, raise_exception=True)289            except Exception:290                pass291            self.assertEqual(Doc.count({}, session=session), 3)292            with session.start_transaction():293                test_func(session)294            self.assertEqual(Doc.count({}, session=session), 0)295        self.assertEqual(Doc.count(), 0)296    def test_save(self):297        Doc.drop_collection()298        # transaction must run while collection exists299        Doc.create_collection_if_not_exists()300        def test_func(session, raise_exception=False):301            id1 = Doc(test_int=1).save(session=session)302            id2 = Doc(test_int=1).save(session=session)303            if raise_exception:304                raise Exception()305            id3 = Doc(test_int=1).save(session=session)306            return [id1, id2, id3]307        with Doc.get_connection().start_session() as session:308            try:309                with session.start_transaction():310                    test_func(session, raise_exception=True)311            except Exception:312                pass313            self.assertEqual(Doc.count({}, session=session), 0)314            with session.start_transaction():315                id1, id2, id3 = test_func(session)316            self.assertEqual(Doc.count({}, session=session), 3)317            for doc_id in [id1, id2, id3]:318                self.assertEqual(Doc.by_id(doc_id, session=session).id, doc_id)319        self.assertEqual(Doc.count(), 3)320    def test_delete(self):321        Doc.drop_collection()322        doc1 = Doc(test_int=1)323        doc2 = Doc(test_int=1)324        doc3 = Doc(test_int=1)325        doc1.save()326        doc2.save()327        doc3.save()328        def test_func(session, raise_exception=False):329            doc1.delete(session=session)330            doc2.delete(session=session)331            if raise_exception:332                raise Exception()333            doc3.delete(session=session)334        with Doc.get_connection().start_session() as session:335            try:336                with session.start_transaction():337                    test_func(session, raise_exception=True)338            except Exception:339                pass340            self.assertEqual(Doc.count({}, session=session), 3)341            with session.start_transaction():342                test_func(session)343            self.assertEqual(Doc.count({}, session=session), 0)344        self.assertEqual(Doc.count(), 0)345    def test_update_one(self):346        Doc.drop_collection()347        doc1 = Doc(test_int=1, name='A', test_pull=[1, 2, 3], test_set=[2, 3])348        doc2 = Doc(test_int=1, name='B', test_pull=[1, 2, 3], test_set=[2, 3])349        doc3 = Doc(test_int=1, name='C', test_pull=[1, 2, 3], test_set=[2, 3])350        doc1.save()351        doc2.save()352        doc3.save()353        def test_func(session, raise_exception=False):354            doc1.unset(name=True, _session=session)355            doc2.unset(name=True, _session=session)356            doc3.unset(name=True, _session=session)357            if raise_exception:358                raise Exception()359            # set360            doc1.set(test_int=-1, _session=session)361            doc2.set(test_int=-2, _session=session)362            doc3.set(test_int=-3, _session=session)363            # push364            doc1.push(test_push=1, _session=session)365            doc2.push(test_push=2, _session=session)366            doc3.push(test_push=3, _session=session)367            # pull368            doc1.pull(test_pull=1, _session=session)369            doc2.pull(test_pull=2, _session=session)370            doc3.pull(test_pull=3, _session=session)371            # add_to_set372            doc1.add_to_set(test_set=1, _session=session)373            doc2.add_to_set(test_set=2, _session=session)374            doc3.add_to_set(test_set=3, _session=session)375        with Doc.get_connection().start_session() as session:376            try:377                with session.start_transaction():378                    test_func(session, raise_exception=True)379            except Exception:380                pass381            self.assertEqual(382                Doc.count({'name': {'$exists': True}}, session=session), 3)383            self.assertEqual(Doc.count({'test_int': 1}, session=session), 3)384            self.assertEqual(385                Doc.count({'test_pull': [1, 2, 3]}, session=session), 3)386            self.assertEqual(387                Doc.count({'test_set': [2, 3]}, session=session), 3)388            self.assertEqual(389                Doc.count({'test_push': []}, session=session), 3)390            with session.start_transaction():391                test_func(session)392            self.assertEqual(393                Doc.count({'name': {'$exists': True}}, session=session), 0)394            for int_val in[-1, -2, -3]:395                self.assertEqual(396                    Doc.count({'test_int': int_val}, session=session), 1)397            self.assertEqual(398                Doc.count({'test_pull': {"$size": 2}}, session=session), 3)399            self.assertEqual(400                Doc.count({'test_set': {'$size': 3}}, session=session), 1)401            self.assertEqual(402                Doc.count({'test_set': {'$size': 2}}, session=session), 2)403            for int_val in [1, 2, 3]:404                self.assertEqual(405                    Doc.count({'test_push': [int_val]}, session=session), 1)406        self.assertEqual(Doc.count({'name': {'$exists': True}}), 0)407    def test_cross_collection_and_db(self):408        class CollA(Document):409            meta = {410                'db_name': 'test1'411            }412            test_int = IntField()413        class CollB(Document):414            meta = {415                'db_name': 'test2'416            }417            test_int = IntField()418        def test_func(session, raise_exception=False):419            CollA.update({}, {'$inc': {'test_int': 50}}, session=session)420            if raise_exception:421                raise Exception()422            CollB.update({}, {'$inc': {'test_int': -50}}, session=session)423        def check_consistency(test_instance, session=None):424            doc1 = CollA.find_one({}, session=session)425            doc2 = CollB.find_one({}, session=session)426            test_instance.assertEqual(doc1.test_int+doc2.test_int, 300)427        clear_all()428        connection = connect(db_names=['test1', 'test2'])429        CollA.drop_collection()430        CollB.drop_collection()431        CollA(test_int=100).save()432        CollB(test_int=200).save()433        with connection.start_session() as session:434            try:435                with session.start_transaction():436                    test_func(session, raise_exception=True)437            except Exception:438                pass439            check_consistency(self, session=session)440            with session.start_transaction():441                test_func(session)442            check_consistency(self, session=session)443        check_consistency(self)444        self.assertEqual(CollA.find_one({}).test_int, 150)445        self.assertEqual(CollB.find_one({}).test_int, 150)446    def test_bulk(self):447        Doc.drop_collection()448        def test_func(session, raise_exception=False):449            doc1 = Doc(test_int=1)450            doc2 = Doc(test_int=2)451            doc3 = Doc(test_int=3)452            with Doc.bulk(session=session) as ctx:453                doc1.bulk_save(ctx)454                doc2.bulk_save(ctx)455                doc3.bulk_save(ctx)456            if raise_exception:457                raise Exception()458            doc1 = Doc.find_one({'test_int': 1}, session=session)459            doc2 = Doc.find_one({'test_int': 2}, session=session)460            doc3 = Doc.find_one({'test_int': 3}, session=session)461            with Doc.bulk(session=session) as ctx:462                doc1.bulk_set(ctx, name='A')463                doc2.bulk_set(ctx, name='B')464                doc3.bulk_set(ctx, name='C')465        with Doc.get_connection().start_session() as session:466            with self.assertRaises(Exception):467                test_func(session, raise_exception=True)468            self.assertEqual(Doc.count(session=session), 3)469            for int_val in [1, 2, 3]:470                self.assertEqual(471                    Doc.count({'test_int': int_val, 'name': {'$exists': False}}, session=session), 1)472            Doc.remove({}, session=session)473            try:474                with session.start_transaction():475                    test_func(session, raise_exception=True)476            except Exception:477                pass478            self.assertEqual(Doc.count(session=session), 0)479            with session.start_transaction():480                test_func(session=session)481            self.assertEqual(Doc.count(session=session), 3)482            for val in [(1, 'A'), (2, 'B'), (3, 'C')]:483                self.assertEqual(...test_int.py
Source:test_int.py  
1import struct2import pytest3from msgpack.core.base import Payload4from msgpack.codec.int import Encoder as IntEncoder5from msgpack.codec.int import Decoder as IntDecoder6class TestEncode:7    @classmethod8    def setup_class(cls):9        cls.encoder = IntEncoder()10    def test_fixint_positive(self):11        # Min12        test_int = 013        self.encoder.encode(test_int)14        assert self.encoder.get_payload() == (15            struct.pack(">B", test_int)16        )17        # Max18        test_int = 0x7f19        self.encoder.encode(test_int)20        assert self.encoder.get_payload() == (21            struct.pack(">B", test_int)22        )23    def test_fixint_negative(self):24        # Min25        test_int = -3226        self.encoder.encode(test_int)27        assert self.encoder.get_payload() == (28            struct.pack(">b", test_int)29        )30        # Max31        test_int = -132        self.encoder.encode(test_int)33        assert self.encoder.get_payload() == (34            struct.pack(">b", test_int)35        )36    def test_uint_8(self):37        # Min38        test_int = -12839        self.encoder.encode(test_int)40        assert self.encoder.get_payload() == (41            struct.pack(">B", 0xd0) + struct.pack(">b", test_int)42        )43        # Max44        test_int = -3345        self.encoder.encode(test_int)46        assert self.encoder.get_payload() == (47            struct.pack(">B", 0xd0) + struct.pack(">b", test_int)48        )49    def test_int_8(self):50        # Min51        test_int = 12852        self.encoder.encode(test_int)53        assert self.encoder.get_payload() == (54            struct.pack(">B", 0xcc) + struct.pack(">B", test_int)55        )56        # Max57        test_int = 25558        self.encoder.encode(test_int)59        assert self.encoder.get_payload() == (60            struct.pack(">B", 0xcc) + struct.pack(">B", test_int)61        )62    def test_uint_16(self):63        # Min64        test_int = -3276865        self.encoder.encode(test_int)66        assert self.encoder.get_payload() == (67            struct.pack(">B", 0xd1) + struct.pack(">h", test_int)68        )69        # Max70        test_int = 3276771        self.encoder.encode(test_int)72        assert self.encoder.get_payload() == (73            struct.pack(">B", 0xd1) + struct.pack(">h", test_int)74        )75    def test_int_16(self):76        # Min77        test_int = 3276878        self.encoder.encode(test_int)79        assert self.encoder.get_payload() == (80            struct.pack(">B", 0xcd) + struct.pack(">H", test_int)81        )82        # Max83        test_int = 6553584        self.encoder.encode(test_int)85        assert self.encoder.get_payload() == (86            struct.pack(">B", 0xcd) + struct.pack(">H", test_int)87        )88    def test_uint_32(self):89        # Min90        test_int = -214748364891        self.encoder.encode(test_int)92        assert self.encoder.get_payload() == (93            struct.pack(">B", 0xd2) + struct.pack(">i", test_int)94        )95        # Max96        test_int = 214748364797        self.encoder.encode(test_int)98        assert self.encoder.get_payload() == (99            struct.pack(">B", 0xd2) + struct.pack(">i", test_int)100        )101    def test_int_32(self):102        # Min103        test_int = 2147483648104        self.encoder.encode(test_int)105        assert self.encoder.get_payload() == (106            struct.pack(">B", 0xce) + struct.pack(">I", test_int)107        )108        # Max109        test_int = 4294967295110        self.encoder.encode(test_int)111        assert self.encoder.get_payload() == (112            struct.pack(">B", 0xce) + struct.pack(">I", test_int)113        )114    def test_uint_64(self):115        # Min116        test_int = -9223372036854775808117        self.encoder.encode(test_int)118        assert self.encoder.get_payload() == (119            struct.pack(">B", 0xd3) + struct.pack(">q", test_int)120        )121        # Max122        test_int = 9223372036854775807123        self.encoder.encode(test_int)124        assert self.encoder.get_payload() == (125            struct.pack(">B", 0xd3) + struct.pack(">q", test_int)126        )127    def test_int_64(self):128        # Min129        test_int = 9223372036854775808130        self.encoder.encode(test_int)131        assert self.encoder.get_payload() == (132            struct.pack(">B", 0xcf) + struct.pack(">Q", test_int)133        )134        # Max135        test_int = 18446744073709551615136        self.encoder.encode(test_int)137        assert self.encoder.get_payload() == (138            struct.pack(">B", 0xcf) + struct.pack(">Q", test_int)139        )140class TestDecode:141    @classmethod142    def setup_class(cls):143        cls.encoder = IntEncoder()144        cls.decoder = IntDecoder()145    146    def compare(self, test_int: int):147        self.encoder.encode(test_int)148        payload = Payload(self.encoder.get_payload().strip())149        first_byte = struct.unpack(">B", payload.byte())[0]150        self.decoder.decode(first_byte, payload)151        assert self.decoder.get_elem() == test_int152    def test_fixint_positive(self):153        # Min154        test_int = 0155        self.compare(test_int)156        # Max157        test_int = 0x7f158        self.compare(test_int)159    def test_fixint_negative(self):160        # Min161        test_int = -32162        self.compare(test_int)163        # Max164        test_int = -1165        self.compare(test_int)166    def test_uint_8(self):167        # Min168        test_int = -128169        self.compare(test_int)170        # Max171        test_int = -33172        self.compare(test_int)173    def test_int_8(self):174        # Min175        test_int = 128176        self.compare(test_int)177        # Max178        test_int = 255179        self.compare(test_int)180    def test_uint_16(self):181        # Min182        test_int = -32768183        self.compare(test_int)184        # Max185        test_int = 32767186        self.compare(test_int)187    def test_int_16(self):188        # Min189        test_int = 32768190        self.compare(test_int)191        # Max192        test_int = 65535193        self.compare(test_int)194    def test_uint_32(self):195        # Min196        test_int = -2147483648197        self.compare(test_int)198        # Max199        test_int = 2147483647200        self.compare(test_int)201    def test_int_32(self):202        # Min203        test_int = 2147483648204        self.compare(test_int)205        # Max206        test_int = 4294967295207        self.compare(test_int)208    def test_uint_64(self):209        # Min210        test_int = -9223372036854775808211        self.compare(test_int)212        # Max213        test_int = 9223372036854775807214        self.compare(test_int)215    def test_int_64(self):216        # Min217        test_int = 9223372036854775808218        self.compare(test_int)219        # Max220        test_int = 18446744073709551615...id_test.py
Source:id_test.py  
1# syft absolute2from syft.lib.python.int import Int3test_int = Int(10)4other = Int(2)5python_int = 106def test_id_abs():7    res = test_int.__abs__()8    py_res = python_int.__abs__()9    assert res == py_res10    assert res.id11    assert res.id != test_int.id12def test_id_add():13    res = test_int.__add__(other)14    py_res = python_int.__add__(other)15    assert res == py_res16    assert res.id17    assert res.id != test_int.id18def test_id_and():19    res = test_int.__and__(other)20    py_res = python_int.__and__(other)21    assert res == py_res22    assert res.id23    assert res.id != test_int.id24def test_id_ceil():25    res = test_int.__ceil__()26    py_res = python_int.__ceil__()27    assert res == py_res28    assert res.id29    assert res.id != test_int.id30def test_id_divmod():31    q, r = test_int.__divmod__(other)32    assert q.id33    assert r.id34def test_id_eq():35    res = test_int.__eq__(other)36    py_res = python_int.__eq__(other)37    assert res == py_res38    assert res.id39    assert res.id != test_int.id40def test_id_float():41    res = test_int.__float__()42    py_res = python_int.__float__()43    assert res == py_res44    assert res.id45    assert res.id != test_int.id46def test_id_floor():47    res = test_int.__floor__()48    py_res = python_int.__floor__()49    assert res == py_res50    assert res.id51    assert res.id != test_int.id52def test_id_floordiv():53    res = test_int.__floordiv__(other)54    py_res = python_int.__floordiv__(other)55    assert res == py_res56    assert res.id57    assert res.id != test_int.id58def test_id_ge():59    res = test_int.__ge__(other)60    py_res = python_int.__ge__(other)61    assert res == py_res62    assert res.id63    assert res.id != test_int.id64def test_id_gt():65    res = test_int.__gt__(other)66    py_res = python_int.__gt__(other)67    assert res == py_res68    assert res.id69    assert res.id != test_int.id70def test_id_hash():71    res = test_int.__hash__()72    py_res = python_int.__hash__()73    assert res == py_res74    assert res.id75    assert res.id != test_int.id76def test_id_iadd():77    res = test_int.__iadd__(other)78    assert res.id79    assert res.id == test_int.id80def test_id_ifloordiv():81    res = test_int.__ifloordiv__(other)82    assert res.id83    assert res.id == test_int.id84def test_id_imod():85    res = test_int.__imod__(other)86    assert res.id87    assert res.id == test_int.id88def test_id_imul():89    res = test_int.__imul__(other)90    assert res.id91    assert res.id == test_int.id92def test_id_invert():93    res = test_int.__invert__()94    py_res = python_int.__invert__()95    assert res == py_res96    assert res.id97    assert res.id != test_int.id98def test_id_ipow():99    res = test_int.__ipow__(other)100    assert res.id101    assert res.id == test_int.id102def test_id_isub():103    res = test_int.__isub__(other)104    assert res.id105    assert res.id == test_int.id106def test_id_itruediv():107    res = test_int.__itruediv__(other)108    assert res.id109    assert res.id == test_int.id110def test_id_le():111    res = test_int.__le__(other)112    py_res = python_int.__le__(other)113    assert res == py_res114    assert res.id115    assert res.id != test_int.id116def test_id_lshift():117    res = test_int.__lshift__(other)118    py_res = python_int.__lshift__(other)119    assert res == py_res120    assert res.id121    assert res.id != test_int.id122def test_id_lt():123    res = test_int.__lt__(other)124    py_res = python_int.__lt__(other)125    assert res == py_res126    assert res.id127    assert res.id != test_int.id128def test_id_mod():129    res = test_int.__mod__(other)130    py_res = python_int.__mod__(other)131    assert res == py_res132    assert res.id133    assert res.id != test_int.id134def test_id_mul():135    res = test_int.__mul__(other)136    py_res = python_int.__mul__(other)137    assert res == py_res138    assert res.id139    assert res.id != test_int.id140def test_id_ne():141    res = test_int.__ne__(other)142    py_res = python_int.__ne__(other)143    assert res == py_res144    assert res.id...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
