Best Python code snippet using Kiwi_python
test_pylint_custom_plugins.py
Source:test_pylint_custom_plugins.py  
...15            def __init__(self, **kwargs): #@16                pass17        """)18        with self.assertNoMessages():19            self.checker.visit_functiondef(function_node)20    def test_ignores_private_method(self):21        class_node, function_node = astroid.extract_node("""22        class SomeClient(): #@23            def _private_method(self, **kwargs): #@24                pass25        """)26        with self.assertNoMessages():27            self.checker.visit_functiondef(function_node)28    def test_ignores_private_method_async(self):29        class_node, function_node = astroid.extract_node("""30        class SomeClient(): #@31            async def _private_method(self, **kwargs): #@32                pass33        """)34        with self.assertNoMessages():35            self.checker.visit_asyncfunctiondef(function_node)36    def test_ignores_methods_with_decorators(self):37        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""38        from azure.core.tracing.decorator import distributed_trace39        class SomeClient(): #@40            @distributed_trace41            def create_configuration(self, **kwargs): #@42                pass43            @distributed_trace44            def get_thing(self, **kwargs): #@45                pass46            @distributed_trace47            def list_thing(self, **kwargs): #@48                pass49        """)50        with self.assertNoMessages():51            self.checker.visit_functiondef(func_node_a)52            self.checker.visit_functiondef(func_node_b)53            self.checker.visit_functiondef(func_node_c)54    def test_ignores_async_methods_with_decorators(self):55        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""56        from azure.core.tracing.decorator_async import distributed_trace_async57        class SomeClient(): #@58            @distributed_trace_async59            async def create_configuration(self, **kwargs): #@60                pass61            @distributed_trace_async62            async def get_thing(self, **kwargs): #@63                pass64            @distributed_trace_async65            async def list_thing(self, **kwargs): #@66                pass67        """)68        with self.assertNoMessages():69            self.checker.visit_asyncfunctiondef(func_node_a)70            self.checker.visit_asyncfunctiondef(func_node_b)71            self.checker.visit_asyncfunctiondef(func_node_c)72    def test_finds_sync_decorator_on_async_method(self):73        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""74        from azure.core.tracing.decorator import distributed_trace75        class SomeClient(): #@76            @distributed_trace77            async def create_configuration(self, **kwargs): #@78                pass79            @distributed_trace80            async def get_thing(self, **kwargs): #@81                pass82            @distributed_trace83            async def list_thing(self, **kwargs): #@84                pass85        """)86        with self.assertAddsMessages(87            pylint.testutils.Message(88                msg_id="client-method-missing-tracing-decorator-async", node=func_node_a89            ),90            pylint.testutils.Message(91                msg_id="client-method-missing-tracing-decorator-async", node=func_node_b92            ),93            pylint.testutils.Message(94                msg_id="client-method-missing-tracing-decorator-async", node=func_node_c95            ),96        ):97            self.checker.visit_asyncfunctiondef(func_node_a)98            self.checker.visit_asyncfunctiondef(func_node_b)99            self.checker.visit_asyncfunctiondef(func_node_c)100    def test_finds_async_decorator_on_sync_method(self):101        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""102        from azure.core.tracing.decorator_async import distributed_trace_async103        class SomeClient(): #@104            @distributed_trace_async105            def create_configuration(self, **kwargs): #@106                pass107            @distributed_trace_async108            def get_thing(self, **kwargs): #@109                pass110            @distributed_trace_async111            def list_thing(self, **kwargs): #@112                pass113        """)114        with self.assertAddsMessages(115            pylint.testutils.Message(116                msg_id="client-method-missing-tracing-decorator", node=func_node_a117            ),118            pylint.testutils.Message(119                msg_id="client-method-missing-tracing-decorator", node=func_node_b120            ),121            pylint.testutils.Message(122                msg_id="client-method-missing-tracing-decorator", node=func_node_c123            ),124        ):125            self.checker.visit_functiondef(func_node_a)126            self.checker.visit_functiondef(func_node_b)127            self.checker.visit_functiondef(func_node_c)128    def test_ignores_other_decorators(self):129        class_node, func_node_a, func_node_b = astroid.extract_node(130            """131        from azure.core.tracing.decorator import distributed_trace132        class SomeClient(): #@133            @classmethod134            @distributed_trace135            def download_thing(self, some, **kwargs): #@136                pass137            @distributed_trace138            @decorator139            def do_thing(self, some, **kwargs): #@140                pass141        """142        )143        with self.assertNoMessages():144            self.checker.visit_functiondef(func_node_a)145            self.checker.visit_functiondef(func_node_b)146    def test_ignores_other_decorators_async(self):147        class_node, func_node_a, func_node_b = astroid.extract_node(148            """149        from azure.core.tracing.decorator_async import distributed_trace_async150        class SomeClient(): #@151            @classmethod152            @distributed_trace_async153            async def download_thing(self, some, **kwargs): #@154                pass155            @distributed_trace_async156            @decorator157            async def do_thing(self, some, **kwargs): #@158                pass159        """160        )161        with self.assertNoMessages():162            self.checker.visit_asyncfunctiondef(func_node_a)163            self.checker.visit_asyncfunctiondef(func_node_b)164    def test_ignores_non_client_method(self):165        class_node, func_node_a, func_node_b = astroid.extract_node(166            """167        class SomethingElse(): #@168            def download_thing(self, some, **kwargs): #@169                pass170            171            @classmethod172            async def do_thing(self, some, **kwargs): #@173                pass174        """175        )176        with self.assertNoMessages():177            self.checker.visit_functiondef(func_node_a)178            self.checker.visit_asyncfunctiondef(func_node_b)179    def test_guidelines_link_active(self):180        url = "https://azure.github.io/azure-sdk/python_implementation.html#distributed-tracing"181        config = Configuration()182        client = PipelineClient(url, config=config)183        request = client.get(url)184        response = client._pipeline.run(request)185        assert response.http_response.status_code == 200186class TestClientsDoNotUseStaticMethods(pylint.testutils.CheckerTestCase):187    CHECKER_CLASS = checker.ClientsDoNotUseStaticMethods188    def test_ignores_constructor(self):189        class_node, function_node = astroid.extract_node("""190        class SomeClient(): #@191            def __init__(self, **kwargs): #@192                pass193        """)194        with self.assertNoMessages():195            self.checker.visit_functiondef(function_node)196    def test_ignores_private_method(self):197        class_node, function_node = astroid.extract_node("""198        class SomeClient(): #@199            @staticmethod200            def _private_method(self, **kwargs): #@201                pass202        """)203        with self.assertNoMessages():204            self.checker.visit_functiondef(function_node)205    def test_ignores_private_method_async(self):206        class_node, function_node = astroid.extract_node("""207        class SomeClient(): #@208            @staticmethod209            async def _private_method(self, **kwargs): #@210                pass211        """)212        with self.assertNoMessages():213            self.checker.visit_asyncfunctiondef(function_node)214    def test_ignores_methods_with_other_decorators(self):215        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""216        class SomeClient(): #@217            @distributed_trace218            def create_configuration(self): #@219                pass220            @distributed_trace221            def get_thing(self): #@222                pass223            @distributed_trace224            def list_thing(self): #@225                pass226        """)227        with self.assertNoMessages():228            self.checker.visit_functiondef(func_node_a)229            self.checker.visit_functiondef(func_node_b)230            self.checker.visit_functiondef(func_node_c)231    def test_ignores_async_methods_with_other_decorators(self):232        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""233        class SomeClient(): #@234            @distributed_trace_async235            async def create_configuration(self): #@236                pass237            @distributed_trace_async238            async def get_thing(self): #@239                pass240            @distributed_trace_async241            async def list_thing(self): #@242                pass243        """)244        with self.assertNoMessages():245            self.checker.visit_asyncfunctiondef(func_node_a)246            self.checker.visit_asyncfunctiondef(func_node_b)247            self.checker.visit_asyncfunctiondef(func_node_c)248    def test_finds_staticmethod_on_async_method(self):249        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""250        class SomeClient(): #@251            @staticmethod252            async def create_configuration(self): #@253                pass254            @staticmethod255            async def get_thing(self): #@256                pass257            @staticmethod258            async def list_thing(self): #@259                pass260        """)261        with self.assertAddsMessages(262                pylint.testutils.Message(263                    msg_id="client-method-should-not-use-static-method", node=func_node_a264                ),265                pylint.testutils.Message(266                    msg_id="client-method-should-not-use-static-method", node=func_node_b267                ),268                pylint.testutils.Message(269                    msg_id="client-method-should-not-use-static-method", node=func_node_c270                ),271        ):272            self.checker.visit_asyncfunctiondef(func_node_a)273            self.checker.visit_asyncfunctiondef(func_node_b)274            self.checker.visit_asyncfunctiondef(func_node_c)275    def test_finds_staticmethod_on_sync_method(self):276        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""277        class SomeClient(): #@278            @staticmethod279            def create_configuration(self): #@280                pass281            @staticmethod282            def get_thing(self): #@283                pass284            @staticmethod285            def list_thing(self): #@286                pass287        """)288        with self.assertAddsMessages(289                pylint.testutils.Message(290                    msg_id="client-method-should-not-use-static-method", node=func_node_a291                ),292                pylint.testutils.Message(293                    msg_id="client-method-should-not-use-static-method", node=func_node_b294                ),295                pylint.testutils.Message(296                    msg_id="client-method-should-not-use-static-method", node=func_node_c297                ),298        ):299            self.checker.visit_functiondef(func_node_a)300            self.checker.visit_functiondef(func_node_b)301            self.checker.visit_functiondef(func_node_c)302    def test_ignores_other_multiple_decorators(self):303        class_node, func_node_a, func_node_b = astroid.extract_node(304            """305        class SomeClient(): #@306            @classmethod307            @distributed_trace308            def download_thing(self, some, **kwargs): #@309                pass310            @distributed_trace311            @decorator312            def do_thing(self, some, **kwargs): #@313                pass314        """315        )316        with self.assertNoMessages():317            self.checker.visit_functiondef(func_node_a)318            self.checker.visit_functiondef(func_node_b)319    def test_ignores_other_multiple_decorators_async(self):320        class_node, func_node_a, func_node_b = astroid.extract_node(321            """322        class SomeClient(): #@323            @classmethod324            @distributed_trace_async325            async def download_thing(self, some, **kwargs): #@326                pass327            @distributed_trace_async328            @decorator329            async def do_thing(self, some, **kwargs): #@330                pass331        """332        )333        with self.assertNoMessages():334            self.checker.visit_asyncfunctiondef(func_node_a)335            self.checker.visit_asyncfunctiondef(func_node_b)336    def test_ignores_non_client_method(self):337        class_node, func_node_a, func_node_b = astroid.extract_node(338            """339        class SomethingElse(): #@340            @staticmethod341            def download_thing(self, some, **kwargs): #@342                pass343            @staticmethod344            async def do_thing(self, some, **kwargs): #@345                pass346        """347        )348        with self.assertNoMessages():349            self.checker.visit_functiondef(func_node_a)350            self.checker.visit_asyncfunctiondef(func_node_b)351    def test_guidelines_link_active(self):352        url = "https://azure.github.io/azure-sdk/python_introduction.html#method-signatures"353        config = Configuration()354        client = PipelineClient(url, config=config)355        request = client.get(url)356        response = client._pipeline.run(request)357        assert response.http_response.status_code == 200358class TestClientHasApprovedMethodNamePrefix(pylint.testutils.CheckerTestCase):359    CHECKER_CLASS = checker.ClientHasApprovedMethodNamePrefix360    def test_ignores_constructor(self):361        class_node, function_node = astroid.extract_node("""362        class SomeClient(): #@363            def __init__(self, **kwargs): #@364                pass365        """)366        with self.assertNoMessages():367            self.checker.visit_classdef(class_node)368    def test_ignores_private_method(self):369        class_node, function_node = astroid.extract_node("""370        class SomeClient(): #@371            def _private_method(self, **kwargs): #@372                pass373        """)374        with self.assertNoMessages():375            self.checker.visit_classdef(class_node)376    def test_ignores_if_exists_suffix(self):377        class_node, function_node = astroid.extract_node("""378        class SomeClient(): #@379            def check_if_exists(self, **kwargs): #@380                pass381        """)382        with self.assertNoMessages():383            self.checker.visit_classdef(class_node)384    def test_ignores_from_prefix(self):385        class_node, function_node = astroid.extract_node("""386        class SomeClient(): #@387            def from_connection_string(self, **kwargs): #@388                pass389        """)390        with self.assertNoMessages():391            self.checker.visit_classdef(class_node)392    def test_ignores_approved_prefix_names(self):393        class_node, func_node_a, func_node_b, func_node_c, func_node_d, func_node_e, func_node_f, func_node_g, \394            func_node_h, func_node_i, func_node_j, func_node_k, func_node_l = astroid.extract_node("""395        class SomeClient(): #@396            def create_configuration(self): #@397                pass398            def get_thing(self): #@399                pass400            def list_thing(self): #@401                pass402            def upsert_thing(self): #@403                pass404            def set_thing(self): #@405                pass406            def update_thing(self): #@407                pass408            def replace_thing(self): #@409                pass410            def append_thing(self): #@411                pass412            def add_thing(self): #@413                pass414            def delete_thing(self): #@415                pass416            def remove_thing(self): #@417                pass418            def begin_thing(self): #@419                pass420        """)421        with self.assertNoMessages():422            self.checker.visit_classdef(class_node)423    def test_ignores_non_client_with_unapproved_prefix_names(self):424        class_node, function_node = astroid.extract_node(425            """426        class SomethingElse(): #@427            def download_thing(self, some, **kwargs): #@428                pass429        """430        )431        with self.assertNoMessages():432            self.checker.visit_classdef(class_node)433    def test_ignores_nested_function_with_unapproved_prefix_names(self):434        class_node, function_node = astroid.extract_node(435            """436            class SomeClient(): #@437                def create_configuration(self, **kwargs): #@438                    def nested(hello, world):439                        pass440            """441        )442        with self.assertNoMessages():443            self.checker.visit_classdef(class_node)444    def test_finds_unapproved_prefix_names(self):445        class_node, func_node_a, func_node_b, func_node_c, func_node_d, func_node_e, func_node_f, func_node_g, \446            func_node_h, func_node_i, func_node_j, func_node_k, func_node_l, func_node_m, func_node_n, func_node_o, \447            func_node_p = astroid.extract_node("""448        class SomeClient(): #@449            @distributed_trace450            def build_configuration(self): #@451                pass452            def generate_thing(self): #@453                pass454            def make_thing(self): #@455                pass456            def insert_thing(self): #@457                pass458            def put_thing(self): #@459                pass460            def creates_configuration(self): #@461                pass462            def gets_thing(self): #@463                pass464            def lists_thing(self): #@465                pass466            def upserts_thing(self): #@467                pass468            def sets_thing(self): #@469                pass470            def updates_thing(self): #@471                pass472            def replaces_thing(self): #@473                pass474            def appends_thing(self): #@475                pass476            def adds_thing(self): #@477                pass478            def deletes_thing(self): #@479                pass480            def removes_thing(self): #@481                pass482        """)483        with self.assertAddsMessages(484            pylint.testutils.Message(485                msg_id="unapproved-client-method-name-prefix", node=func_node_a486            ),487            pylint.testutils.Message(488                msg_id="unapproved-client-method-name-prefix", node=func_node_b489            ),490            pylint.testutils.Message(491                msg_id="unapproved-client-method-name-prefix", node=func_node_c492            ),493            pylint.testutils.Message(494                msg_id="unapproved-client-method-name-prefix", node=func_node_d495            ),496            pylint.testutils.Message(497                msg_id="unapproved-client-method-name-prefix", node=func_node_e498            ),499            pylint.testutils.Message(500                msg_id="unapproved-client-method-name-prefix", node=func_node_f501            ),502            pylint.testutils.Message(503                msg_id="unapproved-client-method-name-prefix", node=func_node_g504            ),505            pylint.testutils.Message(506                msg_id="unapproved-client-method-name-prefix", node=func_node_h507            ),508            pylint.testutils.Message(509                msg_id="unapproved-client-method-name-prefix", node=func_node_i510            ),511            pylint.testutils.Message(512                msg_id="unapproved-client-method-name-prefix", node=func_node_j513            ),514            pylint.testutils.Message(515                msg_id="unapproved-client-method-name-prefix", node=func_node_k516            ),517            pylint.testutils.Message(518                msg_id="unapproved-client-method-name-prefix", node=func_node_l519            ),520            pylint.testutils.Message(521                msg_id="unapproved-client-method-name-prefix", node=func_node_m522            ),523            pylint.testutils.Message(524                msg_id="unapproved-client-method-name-prefix", node=func_node_n525            ),526            pylint.testutils.Message(527                msg_id="unapproved-client-method-name-prefix", node=func_node_o528            ),529            pylint.testutils.Message(530                msg_id="unapproved-client-method-name-prefix", node=func_node_p531            )532        ):533            self.checker.visit_classdef(class_node)534    def test_guidelines_link_active(self):535        url = "https://azure.github.io/azure-sdk/python_design.html#service-operations"536        config = Configuration()537        client = PipelineClient(url, config=config)538        request = client.get(url)539        response = client._pipeline.run(request)540        assert response.http_response.status_code == 200541class TestClientConstructorTakesCorrectParameters(pylint.testutils.CheckerTestCase):542    CHECKER_CLASS = checker.ClientConstructorTakesCorrectParameters543    def test_finds_correct_params(self):544        class_node, function_node = astroid.extract_node("""545        class SomeClient(): #@546            def __init__(self, thing_url, credential, **kwargs): #@547                pass548        """)549        with self.assertNoMessages():550            self.checker.visit_functiondef(function_node)551    def test_ignores_non_constructor_methods(self):552        class_node, function_node = astroid.extract_node("""553        class SomeClient(): #@554            def create_configuration(self): #@555                pass556        """)557        with self.assertNoMessages():558            self.checker.visit_functiondef(function_node)559    def test_ignores_non_client_constructor_methods(self):560        class_node, function_node = astroid.extract_node("""561        class SomethingElse(): #@562            def __init__(self): #@563                pass564        """)565        with self.assertNoMessages():566            self.checker.visit_functiondef(function_node)567    def test_finds_constructor_without_kwargs(self):568        class_node, function_node = astroid.extract_node("""569        class SomeClient(): #@570            def __init__(self, thing_url, credential=None): #@571                pass572        """)573        with self.assertAddsMessages(574            pylint.testutils.Message(575                msg_id="missing-client-constructor-parameter-kwargs", node=function_node576            )577        ):578            self.checker.visit_functiondef(function_node)579    def test_finds_constructor_without_credentials(self):580        class_node, function_node = astroid.extract_node("""581        class SomeClient(): #@582            def __init__(self, thing_url, **kwargs): #@583                pass584        """)585        with self.assertAddsMessages(586            pylint.testutils.Message(587                msg_id="missing-client-constructor-parameter-credential", node=function_node588            )589        ):590            self.checker.visit_functiondef(function_node)591    def test_finds_constructor_with_no_params(self):592        class_node, function_node = astroid.extract_node("""593        class SomeClient(): #@594            def __init__(self): #@595                pass596        """)597        with self.assertAddsMessages(598            pylint.testutils.Message(599                msg_id="missing-client-constructor-parameter-credential", node=function_node600            ),601            pylint.testutils.Message(602                msg_id="missing-client-constructor-parameter-kwargs", node=function_node603            )604        ):605            self.checker.visit_functiondef(function_node)606    def test_guidelines_link_active(self):607        url = "https://azure.github.io/azure-sdk/python_design.html#constructors-and-factory-methods"608        config = Configuration()609        client = PipelineClient(url, config=config)610        request = client.get(url)611        response = client._pipeline.run(request)612        assert response.http_response.status_code == 200613class TestClientMethodsUseKwargsWithMultipleParameters(pylint.testutils.CheckerTestCase):614    CHECKER_CLASS = checker.ClientMethodsUseKwargsWithMultipleParameters615    def test_ignores_method_abiding_to_guidelines(self):616        class_node, function_node, function_node_a, function_node_b, function_node_c, function_node_d, \617            function_node_e, function_node_f, function_node_g, function_node_h, function_node_i, function_node_j, \618            function_node_k, function_node_l, function_node_m = astroid.extract_node("""619        class SomeClient(): #@620            @distributed_trace621            def do_thing(): #@622                pass623            def do_thing_a(self): #@624                pass625            def do_thing_b(self, one): #@626                pass627            def do_thing_c(self, one, two): #@628                pass629            def do_thing_d(self, one, two, three): #@630                pass631            def do_thing_e(self, one, two, three, four): #@632                pass633            def do_thing_f(self, one, two, three, four, five): #@634                pass635            def do_thing_g(self, one, two, three, four, five, six=6): #@636                pass637            def do_thing_h(self, one, two, three, four, five, six=6, seven=7): #@638                pass639            def do_thing_i(self, one, two, three, four, five, *, six=6, seven=7): #@640                pass641            def do_thing_j(self, one, two, three, four, five, *, six=6, seven=7): #@642                pass643            def do_thing_k(self, one, two, three, four, five, **kwargs): #@644                pass645            def do_thing_l(self, one, two, three, four, five, *args, **kwargs): #@646                pass647            def do_thing_m(self, one, two, three, four, five, *args, six, seven=7, **kwargs): #@648                pass649        """)650        with self.assertNoMessages():651            self.checker.visit_functiondef(function_node)652            self.checker.visit_functiondef(function_node_a)653            self.checker.visit_functiondef(function_node_b)654            self.checker.visit_functiondef(function_node_c)655            self.checker.visit_functiondef(function_node_d)656            self.checker.visit_functiondef(function_node_e)657            self.checker.visit_functiondef(function_node_f)658            self.checker.visit_functiondef(function_node_g)659            self.checker.visit_functiondef(function_node_h)660            self.checker.visit_functiondef(function_node_i)661            self.checker.visit_functiondef(function_node_j)662            self.checker.visit_functiondef(function_node_k)663            self.checker.visit_functiondef(function_node_l)664            self.checker.visit_functiondef(function_node_m)665    def test_ignores_method_abiding_to_guidelines_async(self):666        class_node, function_node, function_node_a, function_node_b, function_node_c, function_node_d, \667            function_node_e, function_node_f, function_node_g, function_node_h, function_node_i, function_node_j, \668            function_node_k, function_node_l, function_node_m = astroid.extract_node("""669        class SomeClient(): #@670            @distributed_trace_async671            async def do_thing(): #@672                pass673            async def do_thing_a(self): #@674                pass675            async def do_thing_b(self, one): #@676                pass677            async def do_thing_c(self, one, two): #@678                pass679            async def do_thing_d(self, one, two, three): #@680                pass681            async def do_thing_e(self, one, two, three, four): #@682                pass683            async def do_thing_f(self, one, two, three, four, five): #@684                pass685            async def do_thing_g(self, one, two, three, four, five, six=6): #@686                pass687            async def do_thing_h(self, one, two, three, four, five, six=6, seven=7): #@688                pass689            async def do_thing_i(self, one, two, three, four, five, *, six=6, seven=7): #@690                pass691            async def do_thing_j(self, one, two, three, four, five, *, six=6, seven=7): #@692                pass693            async def do_thing_k(self, one, two, three, four, five, **kwargs): #@694                pass695            async def do_thing_l(self, one, two, three, four, five, *args, **kwargs): #@696                pass697            async def do_thing_m(self, one, two, three, four, five, *args, six, seven=7, **kwargs): #@698                pass699        """)700        with self.assertNoMessages():701            self.checker.visit_asyncfunctiondef(function_node)702            self.checker.visit_asyncfunctiondef(function_node_a)703            self.checker.visit_asyncfunctiondef(function_node_b)704            self.checker.visit_asyncfunctiondef(function_node_c)705            self.checker.visit_asyncfunctiondef(function_node_d)706            self.checker.visit_asyncfunctiondef(function_node_e)707            self.checker.visit_asyncfunctiondef(function_node_f)708            self.checker.visit_asyncfunctiondef(function_node_g)709            self.checker.visit_asyncfunctiondef(function_node_h)710            self.checker.visit_asyncfunctiondef(function_node_i)711            self.checker.visit_asyncfunctiondef(function_node_j)712            self.checker.visit_asyncfunctiondef(function_node_k)713            self.checker.visit_asyncfunctiondef(function_node_l)714            self.checker.visit_asyncfunctiondef(function_node_m)715    def test_finds_methods_with_too_many_positional_args(self):716        class_node, function_node, function_node_a, function_node_b, function_node_c, function_node_d, \717            function_node_e, function_node_f = astroid.extract_node("""718        class SomeClient(): #@719            @distributed_trace720            def do_thing(self, one, two, three, four, five, six): #@721                pass722            def do_thing_a(self, one, two, three, four, five, six, seven=7): #@723                pass724            def do_thing_b(self, one, two, three, four, five, six, *, seven): #@725                pass726            def do_thing_c(self, one, two, three, four, five, six, *, seven, eight, nine): #@727                pass728            def do_thing_d(self, one, two, three, four, five, six, **kwargs): #@729                pass730            def do_thing_e(self, one, two, three, four, five, six, *args, seven, eight, nine): #@731                pass732            def do_thing_f(self, one, two, three, four, five, six, *args, seven=7, eight=8, nine=9): #@733                pass734        """)735        with self.assertAddsMessages(736            pylint.testutils.Message(737                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node738            ),739            pylint.testutils.Message(740                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_a741            ),742            pylint.testutils.Message(743                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_b744            ),745            pylint.testutils.Message(746                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_c747            ),748            pylint.testutils.Message(749                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_d750            ),751            pylint.testutils.Message(752                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_e753            ),754            pylint.testutils.Message(755                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_f756            )757        ):758            self.checker.visit_functiondef(function_node)759            self.checker.visit_functiondef(function_node_a)760            self.checker.visit_functiondef(function_node_b)761            self.checker.visit_functiondef(function_node_c)762            self.checker.visit_functiondef(function_node_d)763            self.checker.visit_functiondef(function_node_e)764            self.checker.visit_functiondef(function_node_f)765    def test_finds_methods_with_too_many_positional_args_async(self):766        class_node, function_node, function_node_a, function_node_b, function_node_c, function_node_d, \767            function_node_e, function_node_f = astroid.extract_node("""768        class SomeClient(): #@769            @distributed_trace_async770            async def do_thing(self, one, two, three, four, five, six): #@771                pass772            async def do_thing_a(self, one, two, three, four, five, six, seven=7): #@773                pass774            async def do_thing_b(self, one, two, three, four, five, six, *, seven): #@775                pass776            async def do_thing_c(self, one, two, three, four, five, six, *, seven, eight, nine): #@777                pass778            async def do_thing_d(self, one, two, three, four, five, six, **kwargs): #@779                pass780            async def do_thing_e(self, one, two, three, four, five, six, *args, seven, eight, nine): #@781                pass782            async def do_thing_f(self, one, two, three, four, five, six, *args, seven=7, eight=8, nine=9): #@783                pass784        """)785        with self.assertAddsMessages(786            pylint.testutils.Message(787                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node788            ),789            pylint.testutils.Message(790                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_a791            ),792            pylint.testutils.Message(793                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_b794            ),795            pylint.testutils.Message(796                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_c797            ),798            pylint.testutils.Message(799                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_d800            ),801            pylint.testutils.Message(802                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_e803            ),804            pylint.testutils.Message(805                msg_id="client-method-has-more-than-5-positional-arguments", node=function_node_f806            )807        ):808            self.checker.visit_asyncfunctiondef(function_node)809            self.checker.visit_asyncfunctiondef(function_node_a)810            self.checker.visit_asyncfunctiondef(function_node_b)811            self.checker.visit_asyncfunctiondef(function_node_c)812            self.checker.visit_asyncfunctiondef(function_node_d)813            self.checker.visit_asyncfunctiondef(function_node_e)814            self.checker.visit_asyncfunctiondef(function_node_f)815    def test_ignores_non_client_methods(self):816        class_node, function_node_a, function_node_b = astroid.extract_node("""817        class SomethingElse(): #@818            def do_thing(self, one, two, three, four, five, six): #@819                pass820            821            @distributed_trace_async822            async def do_thing(self, one, two, three, four, five, six): #@823                pass824        """)825        with self.assertNoMessages():826            self.checker.visit_functiondef(function_node_a)827            self.checker.visit_asyncfunctiondef(function_node_b)828    def test_guidelines_link_active(self):829        url = "https://azure.github.io/azure-sdk/python_introduction.html#method-signatures"830        config = Configuration()831        client = PipelineClient(url, config=config)832        request = client.get(url)833        response = client._pipeline.run(request)834        assert response.http_response.status_code == 200835class TestClientMethodsHaveTypeAnnotations(pylint.testutils.CheckerTestCase):836    CHECKER_CLASS = checker.ClientMethodsHaveTypeAnnotations837    def test_ignores_correct_type_annotations(self):838        class_node, function_node_a, function_node_b = astroid.extract_node("""839        class SomeClient(): #@840            def do_thing(self, one: str, two: int, three: bool, four: Union[str, thing], five: dict) -> int: #@841                pass842            async def do_thing(self, one: str, two: int, three: bool, four: Union[str, thing], five: dict) -> int: #@843                pass844        """)845        with self.assertNoMessages():846            self.checker.visit_functiondef(function_node_a)847            self.checker.visit_asyncfunctiondef(function_node_b)848    def test_ignores_correct_type_comments(self):849        class_node, function_node_a, function_node_b, function_node_c = astroid.extract_node("""850        class SomeClient(): #@851            def do_thing_a(self, one, two, three, four, five): #@852                # type: (str, str, str, str, str) -> None853                pass854            def do_thing_b(self, one, two):  # type: (str, str) -> int #@855                pass856            def do_thing_c(self, #@857                           one,  # type: str858                           two,  # type: str859                           three,  # type: str860                           four,  # type: str861                           five  # type: str862                           ):863                # type: (...) -> int864                pass865        """)866        with self.assertNoMessages():867            self.checker.visit_functiondef(function_node_a)868            self.checker.visit_functiondef(function_node_b)869            self.checker.visit_functiondef(function_node_c)870    def test_ignores_correct_type_comments_async(self):871        class_node, function_node_a, function_node_b, function_node_c = astroid.extract_node("""872        class SomeClient(): #@873            async def do_thing_a(self, one, two, three, four, five): #@874                # type: (str, str, str, str, str) -> None875                pass876            async def do_thing_b(self, one, two):  # type: (str, str) -> int #@877                pass878            async def do_thing_c(self, #@879                           one,  # type: str880                           two,  # type: str881                           three,  # type: str882                           four,  # type: str883                           five  # type: str884                           ):885                # type: (...) -> int886                pass887        """)888        with self.assertNoMessages():889            self.checker.visit_asyncfunctiondef(function_node_a)890            self.checker.visit_asyncfunctiondef(function_node_b)891            self.checker.visit_asyncfunctiondef(function_node_c)892    def test_ignores_no_parameter_method_with_annotations(self):893        class_node, function_node_a, function_node_b = astroid.extract_node("""894        class SomeClient(): #@895            def do_thing_a(self): #@896                # type: () -> None897                pass898            def do_thing_b(self) -> None: #@899                pass900        """)901        with self.assertNoMessages():902            self.checker.visit_functiondef(function_node_a)903            self.checker.visit_functiondef(function_node_b)904    def test_ignores_no_parameter_method_with_annotations_async(self):905        class_node, function_node_a, function_node_b = astroid.extract_node("""906        class SomeClient(): #@907            async def do_thing_a(self): #@908                # type: () -> None909                pass910            async def do_thing_b(self) -> None: #@911                pass912        """)913        with self.assertNoMessages():914            self.checker.visit_asyncfunctiondef(function_node_a)915            self.checker.visit_asyncfunctiondef(function_node_b)916    def test_finds_no_parameter_method_without_annotations(self):917        class_node, function_node_a, function_node_b = astroid.extract_node("""918        class SomeClient(): #@919            def do_thing(self): #@920                pass921            async def do_thing(self): #@922                pass923        """)924        with self.assertAddsMessages(925                pylint.testutils.Message(926                    msg_id="client-method-missing-type-annotations", node=function_node_a927                ),928                pylint.testutils.Message(929                msg_id="client-method-missing-type-annotations", node=function_node_b930                ),931        ):932            self.checker.visit_functiondef(function_node_a)933            self.checker.visit_functiondef(function_node_b)934    def test_finds_method_missing_annotations(self):935        class_node, function_node = astroid.extract_node("""936        class SomeClient(): #@937            def do_thing(self, one, two, three): #@938                pass939        """)940        with self.assertAddsMessages(941            pylint.testutils.Message(942                msg_id="client-method-missing-type-annotations", node=function_node943            )944        ):945            self.checker.visit_functiondef(function_node)946    def test_finds_method_missing_annotations_async(self):947        class_node, function_node = astroid.extract_node("""948        class SomeClient(): #@949            async def do_thing(self, one, two, three): #@950                pass951        """)952        with self.assertAddsMessages(953            pylint.testutils.Message(954                msg_id="client-method-missing-type-annotations", node=function_node955            )956        ):957            self.checker.visit_asyncfunctiondef(function_node)958    def test_finds_constructor_without_annotations(self):959        class_node, function_node = astroid.extract_node("""960        class SomeClient(): #@961            def __init__(self, one, two, three, four, five): #@962                pass963        """)964        with self.assertAddsMessages(965                pylint.testutils.Message(966                    msg_id="client-method-missing-type-annotations", node=function_node967                )968        ):969            self.checker.visit_functiondef(function_node)970    def test_finds_missing_return_annotation_but_has_type_hints(self):971        class_node, function_node_a, function_node_b = astroid.extract_node("""972        class SomeClient(): #@973            def do_thing_a(self, one: str, two: int, three: bool, four: Union[str, thing], five: dict): #@974                pass975            def do_thing_b(self, one, two, three, four, five): #@976                # type: (str, str, str, str, str)977                pass978        """)979        with self.assertAddsMessages(980            pylint.testutils.Message(981                msg_id="client-method-missing-type-annotations", node=function_node_a982            ),983            pylint.testutils.Message(984                msg_id="client-method-missing-type-annotations", node=function_node_b985            ),986        ):987            self.checker.visit_functiondef(function_node_a)988            self.checker.visit_functiondef(function_node_b)989    def test_finds_missing_return_annotation_but_has_type_hints_async(self):990        class_node, function_node_a, function_node_b = astroid.extract_node("""991        class SomeClient(): #@992            async def do_thing_a(self, one: str, two: int, three: bool, four: Union[str, thing], five: dict): #@993                pass994            async def do_thing_b(self, one, two, three, four, five): #@995                # type: (str, str, str, str, str)996                pass997        """)998        with self.assertAddsMessages(999            pylint.testutils.Message(1000                msg_id="client-method-missing-type-annotations", node=function_node_a1001            ),1002            pylint.testutils.Message(1003                msg_id="client-method-missing-type-annotations", node=function_node_b1004            ),1005        ):1006            self.checker.visit_asyncfunctiondef(function_node_a)1007            self.checker.visit_asyncfunctiondef(function_node_b)1008    def test_finds_missing_annotations_but_has_return_hint(self):1009        class_node, function_node_a, function_node_b = astroid.extract_node("""1010        class SomeClient(): #@1011            def do_thing_a(self, one, two, three, four, five) -> None: #@1012                pass1013            def do_thing_b(self, one, two, three, four, five): #@1014                # type: -> None1015                pass1016        """)1017        with self.assertAddsMessages(1018            pylint.testutils.Message(1019                msg_id="client-method-missing-type-annotations", node=function_node_a1020            ),1021            pylint.testutils.Message(1022                msg_id="client-method-missing-type-annotations", node=function_node_b1023            )1024        ):1025            self.checker.visit_functiondef(function_node_a)1026            self.checker.visit_functiondef(function_node_b)1027    def test_finds_missing_annotations_but_has_return_hint_async(self):1028        class_node, function_node_a, function_node_b = astroid.extract_node("""1029        class SomeClient(): #@1030            async def do_thing_a(self, one, two, three, four, five) -> None: #@1031                pass1032            async def do_thing_b(self, one, two, three, four, five): #@1033                # type: -> None1034                pass1035        """)1036        with self.assertAddsMessages(1037            pylint.testutils.Message(1038                msg_id="client-method-missing-type-annotations", node=function_node_a1039            ),1040            pylint.testutils.Message(1041                msg_id="client-method-missing-type-annotations", node=function_node_b1042            )1043        ):1044            self.checker.visit_asyncfunctiondef(function_node_a)1045            self.checker.visit_asyncfunctiondef(function_node_b)1046    def test_ignores_non_client_methods(self):1047        class_node, function_node = astroid.extract_node("""1048        class SomethingElse(): #@1049            def do_thing(self, one, two, three, four, five, six): #@1050                pass1051        """)1052        with self.assertNoMessages():1053            self.checker.visit_functiondef(function_node)1054    def test_ignores_private_methods(self):1055        class_node, function_node = astroid.extract_node("""1056        class SomethingElse(): #@1057            def _do_thing(self, one, two, three, four, five, six): #@1058                pass1059        """)1060        with self.assertNoMessages():1061            self.checker.visit_functiondef(function_node)1062    def test_guidelines_link_active(self):1063        url = "https://azure.github.io/azure-sdk/python_introduction.html#types-or-not"1064        config = Configuration()1065        client = PipelineClient(url, config=config)1066        request = client.get(url)1067        response = client._pipeline.run(request)1068        assert response.http_response.status_code == 2001069class TestClientHasKwargsInPoliciesForCreateConfigurationMethod(pylint.testutils.CheckerTestCase):1070    CHECKER_CLASS = checker.ClientHasKwargsInPoliciesForCreateConfigurationMethod1071    def test_ignores_config_policies_with_kwargs(self):1072        function_node_a, function_node_b = astroid.extract_node("""1073        def create_configuration(self, **kwargs): #@1074            config = Configuration(**kwargs)1075            config.headers_policy = StorageHeadersPolicy(**kwargs)1076            config.user_agent_policy = StorageUserAgentPolicy(**kwargs)1077            config.retry_policy = kwargs.get('retry_policy') or ExponentialRetry(**kwargs)1078            config.redirect_policy = RedirectPolicy(**kwargs)1079            config.logging_policy = StorageLoggingPolicy(**kwargs)1080            config.proxy_policy = ProxyPolicy(**kwargs)1081            return config1082        @staticmethod1083        def create_config(credential, api_version=None, **kwargs): #@1084            # type: (TokenCredential, Optional[str], Mapping[str, Any]) -> Configuration1085            if api_version is None:1086                api_version = KeyVaultClient.DEFAULT_API_VERSION1087            config = KeyVaultClient.get_configuration_class(api_version, aio=False)(credential, **kwargs)1088            config.authentication_policy = ChallengeAuthPolicy(credential, **kwargs)1089            return config1090        """)1091        with self.assertNoMessages():1092            self.checker.visit_functiondef(function_node_a)1093            self.checker.visit_functiondef(function_node_b)1094    def test_finds_config_policies_without_kwargs(self):1095        function_node_a, policy_a, policy_b, policy_c, function_node_b, policy_d = astroid.extract_node("""1096        def create_configuration(self, **kwargs): #@1097            config = Configuration(**kwargs)1098            config.headers_policy = StorageHeadersPolicy(**kwargs)1099            config.user_agent_policy = StorageUserAgentPolicy() #@1100            config.retry_policy = kwargs.get('retry_policy') or ExponentialRetry(**kwargs)1101            config.redirect_policy = RedirectPolicy(**kwargs)1102            config.logging_policy = StorageLoggingPolicy() #@1103            config.proxy_policy = ProxyPolicy() #@1104            return config1105        @staticmethod1106        def create_config(credential, api_version=None, **kwargs): #@1107            # type: (TokenCredential, Optional[str], Mapping[str, Any]) -> Configuration1108            if api_version is None:1109                api_version = KeyVaultClient.DEFAULT_API_VERSION1110            config = KeyVaultClient.get_configuration_class(api_version, aio=False)(credential, **kwargs)1111            config.authentication_policy = ChallengeAuthPolicy(credential) #@1112            return config1113        """)1114        with self.assertAddsMessages(1115            pylint.testutils.Message(1116                msg_id="config-missing-kwargs-in-policy", node=policy_a1117            ),1118            pylint.testutils.Message(1119                msg_id="config-missing-kwargs-in-policy", node=policy_b1120            ),1121            pylint.testutils.Message(1122                msg_id="config-missing-kwargs-in-policy", node=policy_c1123            ),1124            pylint.testutils.Message(1125                msg_id="config-missing-kwargs-in-policy", node=policy_d1126            )1127        ):1128            self.checker.visit_functiondef(function_node_a)1129            self.checker.visit_functiondef(function_node_b)1130    def test_ignores_policies_outside_create_config(self):1131        function_node_a, function_node_b = astroid.extract_node("""1132        def _configuration(self, **kwargs): #@1133            config = Configuration(**kwargs)1134            config.headers_policy = StorageHeadersPolicy(**kwargs)1135            config.user_agent_policy = StorageUserAgentPolicy(**kwargs)1136            config.retry_policy = kwargs.get('retry_policy') or ExponentialRetry()1137            config.redirect_policy = RedirectPolicy()1138            config.logging_policy = StorageLoggingPolicy()1139            config.proxy_policy = ProxyPolicy()1140            return config1141        @staticmethod1142        def some_other_method(credential, api_version=None, **kwargs): #@1143            # type: (TokenCredential, Optional[str], Mapping[str, Any]) -> Configuration1144            if api_version is None:1145                api_version = KeyVaultClient.DEFAULT_API_VERSION1146            config = KeyVaultClient.get_configuration_class(api_version, aio=False)(credential)1147            config.authentication_policy = ChallengeAuthPolicy(credential)1148            return config1149        """)1150        with self.assertNoMessages():1151            self.checker.visit_functiondef(function_node_a)1152            self.checker.visit_functiondef(function_node_b)1153    def test_guidelines_link_active(self):1154        url = "https://azure.github.io/azure-sdk/python_design.html#constructors-and-factory-methods"1155        config = Configuration()1156        client = PipelineClient(url, config=config)1157        request = client.get(url)1158        response = client._pipeline.run(request)1159        assert response.http_response.status_code == 2001160class TestClientUsesCorrectNamingConventions(pylint.testutils.CheckerTestCase):1161    CHECKER_CLASS = checker.ClientUsesCorrectNamingConventions1162    def test_ignores_constructor(self):1163        class_node, function_node = astroid.extract_node("""1164        class SomeClient(): #@1165            def __init__(self, **kwargs): #@1166                pass1167        """)1168        with self.assertNoMessages():1169            self.checker.visit_classdef(class_node)1170    def test_ignores_internal_client(self):1171        class_node, function_node = astroid.extract_node("""1172        class _BaseSomeClient(): #@1173            def __init__(self, **kwargs): #@1174                pass1175        """)1176        with self.assertNoMessages():1177            self.checker.visit_classdef(class_node)1178    def test_ignores_private_method(self):1179        class_node, function_node_a, function_node_b = astroid.extract_node("""1180        class SomeClient(): #@1181            def _private_method(self, **kwargs): #@1182                pass1183            async def _another_private_method(self, **kwargs): #@1184                pass1185        """)1186        with self.assertNoMessages():1187            self.checker.visit_classdef(class_node)1188    def test_ignores_correct_client(self):1189        class_node = astroid.extract_node("""1190        class SomeClient(): #@1191            pass1192        """)1193        with self.assertNoMessages():1194            self.checker.visit_classdef(class_node)1195    def test_ignores_non_client(self):1196        class_node, function_node = astroid.extract_node(1197            """1198        class SomethingElse(): #@1199            def download_thing(self, some, **kwargs): #@1200                pass1201        """1202        )1203        with self.assertNoMessages():1204            self.checker.visit_classdef(class_node)1205    def test_ignores_correct_method_names(self):1206        class_node, function_node_a, function_node_b, function_node_c = astroid.extract_node("""1207        class SomeClient(): #@1208            def from_connection_string(self, **kwargs): #@1209                pass1210            def get_thing(self, **kwargs): #@1211                pass1212            def delete_thing(self, **kwargs): #@1213                pass1214        """)1215        with self.assertNoMessages():1216            self.checker.visit_classdef(class_node)1217    def test_ignores_correct_method_names_async(self):1218        class_node, function_node_a, function_node_b, function_node_c = astroid.extract_node("""1219        class SomeClient(): #@1220            def from_connection_string(self, **kwargs): #@1221                pass1222            def get_thing(self, **kwargs): #@1223                pass1224            def delete_thing(self, **kwargs): #@1225                pass1226        """)1227        with self.assertNoMessages():1228            self.checker.visit_classdef(class_node)1229    def test_ignores_correct_class_constant(self):1230        class_node = astroid.extract_node("""1231        class SomeClient(): #@1232            MAX_SIZE = 141233            MIN_SIZE = 21234        """)1235        with self.assertNoMessages():1236            self.checker.visit_classdef(class_node)1237    def test_finds_incorrectly_named_client(self):1238        class_node_a, class_node_b, class_node_c = astroid.extract_node("""1239        class some_client(): #@1240            pass1241        class Some_Client(): #@1242            pass1243        class someClient(): #@1244            pass1245        """)1246        with self.assertAddsMessages(1247            pylint.testutils.Message(1248                msg_id="client-incorrect-naming-convention", node=class_node_a1249            ),1250            pylint.testutils.Message(1251                msg_id="client-incorrect-naming-convention", node=class_node_b1252            ),1253            pylint.testutils.Message(1254                msg_id="client-incorrect-naming-convention", node=class_node_c1255            ),1256        ):1257            self.checker.visit_classdef(class_node_a)1258            self.checker.visit_classdef(class_node_b)1259            self.checker.visit_classdef(class_node_c)1260    def test_finds_incorrectly_named_methods(self):1261        class_node, func_node_a, func_node_b, func_node_c, func_node_d, func_node_e, func_node_f \1262            = astroid.extract_node("""1263        class SomeClient(): #@1264            def Create_Config(self): #@1265                pass1266            def getThing(self): #@1267                pass1268            def List_thing(self): #@1269                pass1270            def UpsertThing(self): #@1271                pass1272            def set_Thing(self): #@1273                pass1274            def Updatething(self): #@1275                pass1276        """)1277        with self.assertAddsMessages(1278            pylint.testutils.Message(1279                msg_id="client-incorrect-naming-convention", node=func_node_a1280            ),1281            pylint.testutils.Message(1282                msg_id="client-incorrect-naming-convention", node=func_node_b1283            ),1284            pylint.testutils.Message(1285                msg_id="client-incorrect-naming-convention", node=func_node_c1286            ),1287            pylint.testutils.Message(1288                msg_id="client-incorrect-naming-convention", node=func_node_d1289            ),1290            pylint.testutils.Message(1291                msg_id="client-incorrect-naming-convention", node=func_node_e1292            ),1293            pylint.testutils.Message(1294                msg_id="client-incorrect-naming-convention", node=func_node_f1295            ),1296        ):1297            self.checker.visit_classdef(class_node)1298    def test_finds_incorrectly_named_methods_async(self):1299        class_node, func_node_a, func_node_b, func_node_c, func_node_d, func_node_e, func_node_f \1300            = astroid.extract_node("""1301        class SomeClient(): #@1302            async def Create_Config(self): #@1303                pass1304            async def getThing(self): #@1305                pass1306            async def List_thing(self): #@1307                pass1308            async def UpsertThing(self): #@1309                pass1310            async def set_Thing(self): #@1311                pass1312            async def Updatething(self): #@1313                pass1314        """)1315        with self.assertAddsMessages(1316            pylint.testutils.Message(1317                msg_id="client-incorrect-naming-convention", node=func_node_a1318            ),1319            pylint.testutils.Message(1320                msg_id="client-incorrect-naming-convention", node=func_node_b1321            ),1322            pylint.testutils.Message(1323                msg_id="client-incorrect-naming-convention", node=func_node_c1324            ),1325            pylint.testutils.Message(1326                msg_id="client-incorrect-naming-convention", node=func_node_d1327            ),1328            pylint.testutils.Message(1329                msg_id="client-incorrect-naming-convention", node=func_node_e1330            ),1331            pylint.testutils.Message(1332                msg_id="client-incorrect-naming-convention", node=func_node_f1333            ),1334        ):1335            self.checker.visit_classdef(class_node)1336    def test_finds_incorrectly_named_class_constant(self):1337        class_node, const_a, const_b = astroid.extract_node("""1338        class SomeClient(): #@1339            max_size = 14 #@1340            min_size = 2 #@1341        """)1342        with self.assertAddsMessages(1343            pylint.testutils.Message(1344                msg_id="client-incorrect-naming-convention", node=const_a1345            ),1346            pylint.testutils.Message(1347                msg_id="client-incorrect-naming-convention", node=const_b1348            ),1349        ):1350            self.checker.visit_classdef(class_node)1351    def test_guidelines_link_active(self):1352        url = "https://azure.github.io/azure-sdk/python_introduction.html#naming-conventions"1353        config = Configuration()1354        client = PipelineClient(url, config=config)1355        request = client.get(url)1356        response = client._pipeline.run(request)1357        assert response.http_response.status_code == 2001358class TestClientMethodsHaveKwargsParameter(pylint.testutils.CheckerTestCase):1359    CHECKER_CLASS = checker.ClientMethodsHaveKwargsParameter1360    def test_ignores_private_methods(self):1361        class_node, function_node = astroid.extract_node("""1362        class SomeClient(): #@1363            def _create_configuration(self): #@1364                pass1365        """)1366        with self.assertNoMessages():1367            self.checker.visit_functiondef(function_node)1368    def test_ignores_properties(self):1369        class_node, function_node = astroid.extract_node("""1370        class SomeClient(): #@1371            @property1372            def key_id(self): #@1373                pass1374        """)1375        with self.assertNoMessages():1376            self.checker.visit_functiondef(function_node)1377    def test_ignores_properties_async(self):1378        class_node, function_node = astroid.extract_node("""1379        class SomeClient(): #@1380            @property1381            async def key_id(self): #@1382                pass1383        """)1384        with self.assertNoMessages():1385            self.checker.visit_asyncfunctiondef(function_node)1386    def test_ignores_non_client_methods(self):1387        class_node, function_node = astroid.extract_node("""1388        class SomethingElse(): #@1389            def create_configuration(self): #@1390                pass1391        """)1392        with self.assertNoMessages():1393            self.checker.visit_functiondef(function_node)1394    def test_ignores_methods_with_kwargs(self):1395        class_node, function_node_a, function_node_b = astroid.extract_node("""1396        class SomeClient(): #@1397            def get_thing(self, **kwargs): #@1398                pass1399            @distributed_trace1400            def remove_thing(self, **kwargs): #@1401                pass1402        """)1403        with self.assertNoMessages():1404            self.checker.visit_functiondef(function_node_a)1405            self.checker.visit_functiondef(function_node_b)1406    def test_finds_missing_kwargs(self):1407        class_node, function_node_a, function_node_b = astroid.extract_node("""1408        from azure.core.tracing.decorator import distributed_trace1409        1410        class SomeClient(): #@1411            @distributed_trace1412            def get_thing(self): #@1413                pass1414            @distributed_trace1415            def remove_thing(self): #@1416                pass1417        """)1418        with self.assertAddsMessages(1419            pylint.testutils.Message(1420                msg_id="client-method-missing-kwargs", node=function_node_a1421            ),1422            pylint.testutils.Message(1423                msg_id="client-method-missing-kwargs", node=function_node_b1424            ),1425        ):1426            self.checker.visit_functiondef(function_node_a)1427            self.checker.visit_functiondef(function_node_b)1428    def test_ignores_methods_with_kwargs_async(self):1429        class_node, function_node_a, function_node_b = astroid.extract_node("""1430        class SomeClient(): #@1431            async def get_thing(self, **kwargs): #@1432                pass1433            async def remove_thing(self, **kwargs): #@1434                pass1435        """)1436        with self.assertNoMessages():1437            self.checker.visit_asyncfunctiondef(function_node_a)1438            self.checker.visit_asyncfunctiondef(function_node_b)1439    def test_finds_missing_kwargs_async(self):1440        class_node, function_node_a, function_node_b = astroid.extract_node("""1441        from azure.core.tracing.decorator_async import distributed_trace_async1442        1443        class SomeClient(): #@1444            @distributed_trace_async1445            async def get_thing(self): #@1446                pass1447            @distributed_trace_async1448            async def remove_thing(self): #@1449                pass1450        """)1451        with self.assertAddsMessages(1452            pylint.testutils.Message(1453                msg_id="client-method-missing-kwargs", node=function_node_a1454            ),1455            pylint.testutils.Message(1456                msg_id="client-method-missing-kwargs", node=function_node_b1457            ),1458        ):1459            self.checker.visit_asyncfunctiondef(function_node_a)1460            self.checker.visit_asyncfunctiondef(function_node_b)1461    def test_guidelines_link_active(self):1462        url = "https://azure.github.io/azure-sdk/python_design.html#constructors-and-factory-methods"1463        config = Configuration()1464        client = PipelineClient(url, config=config)1465        request = client.get(url)1466        response = client._pipeline.run(request)1467        assert response.http_response.status_code == 2001468class TestAsyncClientCorrectNaming(pylint.testutils.CheckerTestCase):1469    CHECKER_CLASS = checker.AsyncClientCorrectNaming1470    def test_ignores_private_client(self):1471        class_node = astroid.extract_node("""1472        class _AsyncBaseSomeClient(): #@1473            def create_configuration(self):1474                pass1475        """)1476        with self.assertNoMessages():1477            self.checker.visit_classdef(class_node)1478    def test_ignores_correct_client(self):1479        class_node, function_node = astroid.extract_node("""1480        class SomeClient(): #@1481            def create_configuration(self): #@1482                pass1483        """)1484        with self.assertNoMessages():1485            self.checker.visit_classdef(class_node)1486    def test_ignores_async_base_named_client(self):1487        class_node_a = astroid.extract_node("""1488        class AsyncSomeClientBase(): #@1489            def get_thing(self, **kwargs):1490                pass1491        """)1492        with self.assertNoMessages():1493            self.checker.visit_classdef(class_node_a)1494    def test_finds_incorrectly_named_client(self):1495        class_node_a = astroid.extract_node("""1496        class AsyncSomeClient(): #@1497            def get_thing(self, **kwargs):1498                pass1499        """)1500        with self.assertAddsMessages(1501            pylint.testutils.Message(1502                msg_id="async-client-bad-name", node=class_node_a1503            ),1504        ):1505            self.checker.visit_classdef(class_node_a)1506    def test_ignores_non_client(self):1507        class_node, function_node = astroid.extract_node("""1508        class SomethingElse(): #@1509            def create_configuration(self): #@1510                pass1511        """)1512        with self.assertNoMessages():1513            self.checker.visit_classdef(class_node)1514    def test_guidelines_link_active(self):1515        url = "https://azure.github.io/azure-sdk/python_design.html#async-support"1516        config = Configuration()1517        client = PipelineClient(url, config=config)1518        request = client.get(url)1519        response = client._pipeline.run(request)1520        assert response.http_response.status_code == 2001521class TestFileHasCopyrightHeader(pylint.testutils.CheckerTestCase):1522    CHECKER_CLASS = checker.FileHasCopyrightHeader1523    # Unable to use the astroid for this testcase.1524    def test_guidelines_link_active(self):1525        url = "https://azure.github.io/azure-sdk/policies_opensource.html"1526        config = Configuration()1527        client = PipelineClient(url, config=config)1528        request = client.get(url)1529        response = client._pipeline.run(request)1530        assert response.http_response.status_code == 2001531class TestSpecifyParameterNamesInCall(pylint.testutils.CheckerTestCase):1532    CHECKER_CLASS = checker.SpecifyParameterNamesInCall1533    def test_ignores_call_with_only_two_unnamed_params(self):1534        class_node, call_node = astroid.extract_node("""1535        class SomeClient(): #@1536            def do_thing(self):1537                self._client.thing(one, two) #@1538        """)1539        with self.assertNoMessages():1540            self.checker.visit_call(call_node)1541    def test_ignores_call_with_two_unnamed_params_and_one_named(self):1542        class_node, call_node = astroid.extract_node("""1543        class SomeClient(): #@1544            def do_thing(self):1545                self._client.thing(one, two, three=3) #@1546        """)1547        with self.assertNoMessages():1548            self.checker.visit_call(call_node)1549    def test_ignores_call_from_non_client(self):1550        class_node, call_node = astroid.extract_node("""1551        class SomethingElse(): #@1552            def do_thing(self):1553                self._other.thing(one, two, three) #@1554        """)1555        with self.assertNoMessages():1556            self.checker.visit_call(call_node)1557    def test_ignores_call_with_named_params(self):1558        class_node, call_node_a, call_node_b, call_node_c = astroid.extract_node("""1559        class SomethingElse(): #@1560            def do_thing_a(self):1561                self._other.thing(one=one, two=two, three=three) #@1562            def do_thing_b(self):1563                self._other.thing(zero, number, one=one, two=two, three=three) #@1564            def do_thing_c(self):1565                self._other.thing(zero, one=one, two=two, three=three) #@      1566        """)1567        with self.assertNoMessages():1568            self.checker.visit_call(call_node_a)1569            self.checker.visit_call(call_node_b)1570            self.checker.visit_call(call_node_c)1571    def test_ignores_non_client_function_call(self):1572        call_node = astroid.extract_node("""1573        def do_thing():1574            self._client.thing(one, two, three) #@1575        """)1576        with self.assertNoMessages():1577            self.checker.visit_call(call_node)1578    def test_finds_call_with_more_than_two_unnamed_params(self):1579        class_node, call_node = astroid.extract_node("""1580        class SomeClient(): #@1581            def do_thing(self):1582                self._client.thing(one, two, three) #@1583        """)1584        with self.assertAddsMessages(1585            pylint.testutils.Message(1586                msg_id="specify-parameter-names-in-call", node=call_node1587            ),1588        ):1589            self.checker.visit_call(call_node)1590    def test_finds_call_with_more_than_two_unnamed_params_and_some_named(self):1591        class_node, call_node = astroid.extract_node("""1592        class SomeClient(): #@1593            def do_thing(self):1594                self._client.thing(one, two, three, four=4, five=5) #@1595        """)1596        with self.assertAddsMessages(1597            pylint.testutils.Message(1598                msg_id="specify-parameter-names-in-call", node=call_node1599            ),1600        ):1601            self.checker.visit_call(call_node)1602    def test_guidelines_link_active(self):1603        url = "https://azure.github.io/azure-sdk/python_introduction.html#method-signatures"1604        config = Configuration()1605        client = PipelineClient(url, config=config)1606        request = client.get(url)1607        response = client._pipeline.run(request)1608        assert response.http_response.status_code == 2001609class TestClientListMethodsUseCorePaging(pylint.testutils.CheckerTestCase):1610    CHECKER_CLASS = checker.ClientListMethodsUseCorePaging1611    def test_ignores_private_methods(self):1612        class_node, function_node = astroid.extract_node("""1613        class SomeClient(): #@1614            def _list_thing(self): #@1615                pass1616        """)1617        with self.assertNoMessages():1618            self.checker.visit_functiondef(function_node)1619    def test_ignores_non_client_methods(self):1620        class_node, function_node = astroid.extract_node("""1621        class SomethingElse(): #@1622            def list_things(self): #@1623                pass1624        """)1625        with self.assertNoMessages():1626            self.checker.visit_functiondef(function_node)1627    def test_ignores_methods_return_ItemPaged(self):1628        class_node, function_node_a, function_node_b = astroid.extract_node("""1629        from azure.core.paging import ItemPaged1630        1631        class SomeClient(): #@1632            def list_thing(self): #@1633                return ItemPaged()1634            @distributed_trace1635            def list_thing2(self): #@1636                return ItemPaged(1637                    command, prefix=name_starts_with, results_per_page=results_per_page,1638                    page_iterator_class=BlobPropertiesPaged)1639        """)1640        with self.assertNoMessages():1641            self.checker.visit_functiondef(function_node_a)1642            self.checker.visit_functiondef(function_node_b)1643    def test_ignores_methods_return_AsyncItemPaged(self):1644        class_node, function_node_a, function_node_b = astroid.extract_node("""1645        from azure.core.async_paging import AsyncItemPaged1646        1647        class SomeClient(): #@1648            async def list_thing(self): #@1649                return AsyncItemPaged()1650            @distributed_trace1651            def list_thing2(self): #@1652                return AsyncItemPaged(1653                    command, prefix=name_starts_with, results_per_page=results_per_page,1654                    page_iterator_class=BlobPropertiesPaged)1655        """)1656        with self.assertNoMessages():1657            self.checker.visit_functiondef(function_node_a)1658            self.checker.visit_functiondef(function_node_b)1659    def test_finds_method_returning_something_else(self):1660        class_node, function_node_a, function_node_b = astroid.extract_node("""1661        from azure.core.polling import LROPoller1662        1663        class SomeClient(): #@1664            def list_thing(self): #@1665                return list()1666            def list_thing2(self): #@1667                return LROPoller()1668        """)1669        with self.assertAddsMessages(1670            pylint.testutils.Message(1671                msg_id="client-list-methods-use-paging", node=function_node_a1672            ),1673            pylint.testutils.Message(1674                msg_id="client-list-methods-use-paging", node=function_node_b1675            ),1676        ):1677            self.checker.visit_functiondef(function_node_a)1678            self.checker.visit_functiondef(function_node_b)1679    def test_finds_method_returning_something_else_async(self):1680        class_node, function_node_a, function_node_b = astroid.extract_node("""1681        from azure.core.polling import LROPoller1682        1683        class SomeClient(): #@1684            async def list_thing(self, **kwargs): #@1685                return list()1686            async def list_thing2(self, **kwargs): #@1687                from azure.core.polling import LROPoller1688                return LROPoller()1689        """)1690        with self.assertAddsMessages(1691            pylint.testutils.Message(1692                msg_id="client-list-methods-use-paging", node=function_node_a1693            ),1694            pylint.testutils.Message(1695                msg_id="client-list-methods-use-paging", node=function_node_b1696            ),1697        ):1698            self.checker.visit_functiondef(function_node_a)1699            self.checker.visit_functiondef(function_node_b)1700    def test_guidelines_link_active(self):1701        url = "https://azure.github.io/azure-sdk/python_design.html#response-formats"1702        config = Configuration()1703        client = PipelineClient(url, config=config)1704        request = client.get(url)1705        response = client._pipeline.run(request)1706        assert response.http_response.status_code == 2001707class TestClientLROMethodsUseCorePolling(pylint.testutils.CheckerTestCase):1708    CHECKER_CLASS = checker.ClientLROMethodsUseCorePolling1709    def test_ignores_private_methods(self):1710        class_node, function_node = astroid.extract_node("""1711        class SomeClient(): #@1712            def _begin_thing(self): #@1713                pass1714        """)1715        with self.assertNoMessages():1716            self.checker.visit_functiondef(function_node)1717    def test_ignores_non_client_methods(self):1718        class_node, function_node = astroid.extract_node("""1719        class SomethingElse(): #@1720            def begin_things(self): #@1721                pass1722        """)1723        with self.assertNoMessages():1724            self.checker.visit_functiondef(function_node)1725    def test_ignores_methods_return_LROPoller(self):1726        class_node, function_node_a, function_node_b = astroid.extract_node("""1727        from azure.core.polling import LROPoller1728        1729        class SomeClient(): #@1730            def begin_thing(self): #@1731                return LROPoller()1732            @distributed_trace1733            def begin_thing2(self): #@1734                return LROPoller(self._client, raw_result, get_long_running_output, polling_method)1735        """)1736        with self.assertNoMessages():1737            self.checker.visit_functiondef(function_node_a)1738            self.checker.visit_functiondef(function_node_b)1739    def test_finds_method_returning_something_else(self):1740        class_node, function_node_a, function_node_b = astroid.extract_node("""1741        class SomeClient(): #@1742            def begin_thing(self): #@1743                return list()1744            def begin_thing2(self): #@1745                return {}1746        """)1747        with self.assertAddsMessages(1748            pylint.testutils.Message(1749                msg_id="client-lro-methods-use-polling", node=function_node_a1750            ),1751            pylint.testutils.Message(1752                msg_id="client-lro-methods-use-polling", node=function_node_b1753            ),1754        ):1755            self.checker.visit_functiondef(function_node_a)1756            self.checker.visit_functiondef(function_node_b)1757    def test_guidelines_link_active(self):1758        url = "https://azure.github.io/azure-sdk/python_design.html#response-formats"1759        config = Configuration()1760        client = PipelineClient(url, config=config)1761        request = client.get(url)1762        response = client._pipeline.run(request)1763        assert response.http_response.status_code == 2001764class TestClientLROMethodsUseCorrectNaming(pylint.testutils.CheckerTestCase):1765    CHECKER_CLASS = checker.ClientLROMethodsUseCorrectNaming1766    def test_ignores_private_methods(self):1767        class_node, return_node = astroid.extract_node("""1768        from azure.core.polling import LROPoller1769        1770        class SomeClient(): #@1771            def _do_thing(self): 1772                return LROPoller(self._client, raw_result, get_long_running_output, polling_method) #@1773        """)1774        with self.assertNoMessages():1775            self.checker.visit_classdef(class_node)1776            self.checker.visit_return(return_node)1777    def test_ignores_non_client_methods(self):1778        class_node, return_node = astroid.extract_node("""1779        from azure.core.polling import LROPoller1780        1781        class SomethingElse(): #@1782            def begin_things(self):1783                return LROPoller(self._client, raw_result, get_long_running_output, polling_method) #@1784        """)1785        with self.assertNoMessages():1786            self.checker.visit_classdef(class_node)1787            self.checker.visit_return(return_node)1788    def test_ignores_methods_return_LROPoller_and_correctly_named(self):1789        class_node, return_node_a, return_node_b = astroid.extract_node("""1790        from azure.core.polling import LROPoller1791        1792        class SomeClient(): #@1793            def begin_thing(self):1794                return LROPoller() #@1795            @distributed_trace1796            def begin_thing2(self):1797                return LROPoller(self._client, raw_result, get_long_running_output, polling_method) #@1798        """)1799        with self.assertNoMessages():1800            self.checker.visit_classdef(class_node)1801            self.checker.visit_return(return_node_a)1802            self.checker.visit_return(return_node_b)1803    def test_finds_incorrectly_named_method_returning_LROPoller(self):1804        class_node, function_node_a, return_node_a, function_node_b, return_node_b = astroid.extract_node("""1805        from azure.core.polling import LROPoller1806        1807        class SomeClient(): #@1808            def poller_thing(self): #@1809                return LROPoller() #@1810            @distributed_trace1811            def start_thing2(self): #@1812                return LROPoller(self._client, raw_result, get_long_running_output, polling_method) #@1813        """)1814        with self.assertAddsMessages(1815            pylint.testutils.Message(1816                msg_id="lro-methods-use-correct-naming", node=function_node_a1817            ),1818            pylint.testutils.Message(1819                msg_id="lro-methods-use-correct-naming", node=function_node_b1820            ),1821        ):1822            self.checker.visit_classdef(class_node)1823            self.checker.visit_return(return_node_a)1824            self.checker.visit_return(return_node_b)1825    def test_guidelines_link_active(self):1826        url = "https://azure.github.io/azure-sdk/python_design.html#service-operations"1827        config = Configuration()1828        client = PipelineClient(url, config=config)1829        request = client.get(url)1830        response = client._pipeline.run(request)1831        assert response.http_response.status_code == 2001832class TestClientConstructorDoesNotHaveConnectionStringParam(pylint.testutils.CheckerTestCase):1833    CHECKER_CLASS = checker.ClientConstructorDoesNotHaveConnectionStringParam1834    def test_ignores_client_with_no_conn_str_in_constructor(self):1835        class_node = astroid.extract_node("""1836        class SomeClient(): #@1837            def __init__(self): 1838                pass1839        """)1840        with self.assertNoMessages():1841            self.checker.visit_classdef(class_node)1842    def test_ignores_non_client_methods(self):1843        class_node, function_node = astroid.extract_node("""1844        class SomethingElse(): #@1845            def __init__(self): #@1846                pass1847        """)1848        with self.assertNoMessages():1849            self.checker.visit_classdef(class_node)1850    def test_finds_client_method_using_conn_str_in_constructor_a(self):1851        class_node = astroid.extract_node("""1852        class SomeClient(): #@1853            def __init__(self, connection_string):1854                return list()1855        """)1856        with self.assertAddsMessages(1857                pylint.testutils.Message(1858                    msg_id="connection-string-should-not-be-constructor-param", node=class_node1859                ),1860        ):1861            self.checker.visit_classdef(class_node)1862    def test_finds_client_method_using_conn_str_in_constructor_b(self):1863        class_node = astroid.extract_node("""1864        class SomeClient(): #@1865            def __init__(self, conn_str):1866                return list()1867        """)1868        with self.assertAddsMessages(1869                pylint.testutils.Message(1870                    msg_id="connection-string-should-not-be-constructor-param", node=class_node1871                ),1872        ):1873            self.checker.visit_classdef(class_node)1874    def test_guidelines_link_active(self):1875        url = "https://azure.github.io/azure-sdk/python_design.html#constructors-and-factory-methods"1876        config = Configuration()1877        client = PipelineClient(url, config=config)1878        request = client.get(url)1879        response = client._pipeline.run(request)1880        assert response.http_response.status_code == 2001881class TestClientMethodNamesDoNotUseDoubleUnderscorePrefix(pylint.testutils.CheckerTestCase):1882    CHECKER_CLASS = checker.ClientMethodNamesDoNotUseDoubleUnderscorePrefix1883    def test_ignores_repr(self):1884        class_node, function_node = astroid.extract_node("""1885        class SomeClient(): #@1886            def __repr__(self): #@1887                pass1888        """)1889        with self.assertNoMessages():1890            self.checker.visit_functiondef(function_node)1891    def test_ignores_constructor(self):1892        class_node, function_node = astroid.extract_node("""1893        class SomeClient(): #@1894            def __init__(self, **kwargs): #@1895                pass1896        """)1897        with self.assertNoMessages():1898            self.checker.visit_functiondef(function_node)1899    def test_ignores_other_dunder(self):1900        class_node, function_node_a, function_node_b, function_node_c, function_node_d = astroid.extract_node("""1901        class SomeClient(): #@1902            def __enter__(self): #@1903                pass1904            def __exit__(self): #@1905                pass1906            def __aenter__(self): #@1907                pass1908            def __aexit__(self): #@1909                pass1910        """)1911        with self.assertNoMessages():1912            self.checker.visit_functiondef(function_node_a)1913            self.checker.visit_functiondef(function_node_b)1914            self.checker.visit_functiondef(function_node_c)1915            self.checker.visit_functiondef(function_node_d)1916    def test_ignores_private_method(self):1917        class_node, function_node = astroid.extract_node("""1918        class SomeClient(): #@1919            @staticmethod1920            def _private_method(self, **kwargs): #@1921                pass1922        """)1923        with self.assertNoMessages():1924            self.checker.visit_functiondef(function_node)1925    def test_ignores_private_method_async(self):1926        class_node, function_node = astroid.extract_node("""1927        class SomeClient(): #@1928            @staticmethod1929            async def _private_method(self, **kwargs): #@1930                pass1931        """)1932        with self.assertNoMessages():1933            self.checker.visit_asyncfunctiondef(function_node)1934    def test_ignores_methods_with_decorators(self):1935        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""1936        class SomeClient(): #@1937            @distributed_trace1938            def create_configuration(self): #@1939                pass1940            @distributed_trace1941            def get_thing(self): #@1942                pass1943            @distributed_trace1944            def list_thing(self): #@1945                pass1946        """)1947        with self.assertNoMessages():1948            self.checker.visit_functiondef(func_node_a)1949            self.checker.visit_functiondef(func_node_b)1950            self.checker.visit_functiondef(func_node_c)1951    def test_ignores_async_methods_with_decorators(self):1952        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""1953        class SomeClient(): #@1954            @distributed_trace_async1955            async def create_configuration(self): #@1956                pass1957            @distributed_trace_async1958            async def get_thing(self): #@1959                pass1960            @distributed_trace_async1961            async def list_thing(self): #@1962                pass1963        """)1964        with self.assertNoMessages():1965            self.checker.visit_asyncfunctiondef(func_node_a)1966            self.checker.visit_asyncfunctiondef(func_node_b)1967            self.checker.visit_asyncfunctiondef(func_node_c)1968    def test_finds_double_underscore_on_async_method(self):1969        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""1970        class SomeClient(): #@1971            @staticmethod1972            async def __create_configuration(self): #@1973                pass1974            @staticmethod1975            async def __get_thing(self): #@1976                pass1977            @staticmethod1978            async def __list_thing(self): #@1979                pass1980        """)1981        with self.assertAddsMessages(1982                pylint.testutils.Message(1983                    msg_id="client-method-name-no-double-underscore", node=func_node_a1984                ),1985                pylint.testutils.Message(1986                    msg_id="client-method-name-no-double-underscore", node=func_node_b1987                ),1988                pylint.testutils.Message(1989                    msg_id="client-method-name-no-double-underscore", node=func_node_c1990                ),1991        ):1992            self.checker.visit_asyncfunctiondef(func_node_a)1993            self.checker.visit_asyncfunctiondef(func_node_b)1994            self.checker.visit_asyncfunctiondef(func_node_c)1995    def test_finds_double_underscore_on_sync_method(self):1996        class_node, func_node_a, func_node_b, func_node_c = astroid.extract_node("""1997        class SomeClient(): #@1998            @staticmethod1999            def __create_configuration(self): #@2000                pass2001            @staticmethod2002            def __get_thing(self): #@2003                pass2004            @staticmethod2005            def __list_thing(self): #@2006                pass2007        """)2008        with self.assertAddsMessages(2009                pylint.testutils.Message(2010                    msg_id="client-method-name-no-double-underscore", node=func_node_a2011                ),2012                pylint.testutils.Message(2013                    msg_id="client-method-name-no-double-underscore", node=func_node_b2014                ),2015                pylint.testutils.Message(2016                    msg_id="client-method-name-no-double-underscore", node=func_node_c2017                ),2018        ):2019            self.checker.visit_functiondef(func_node_a)2020            self.checker.visit_functiondef(func_node_b)2021            self.checker.visit_functiondef(func_node_c)2022    def test_ignores_non_client_method(self):2023        class_node, func_node_a, func_node_b = astroid.extract_node(2024            """2025        class SomethingElse(): #@2026            @staticmethod2027            def __download_thing(self, some, **kwargs): #@2028                pass2029            @staticmethod2030            async def __do_thing(self, some, **kwargs): #@2031                pass2032        """2033        )2034        with self.assertNoMessages():2035            self.checker.visit_functiondef(func_node_a)2036            self.checker.visit_asyncfunctiondef(func_node_b)2037    def test_guidelines_link_active(self):2038        url = "https://azure.github.io/azure-sdk/python_introduction.html#public-vs-private"2039        config = Configuration()2040        client = PipelineClient(url, config=config)2041        request = client.get(url)2042        response = client._pipeline.run(request)2043        assert response.http_response.status_code == 2002044class TestCheckDocstringAdmonitionNewline(pylint.testutils.CheckerTestCase):2045    CHECKER_CLASS = checker.CheckDocstringAdmonitionNewline2046    def test_ignores_correct_admonition_statement_in_function(self):2047        function_node = astroid.extract_node(2048            """2049            def function_foo(x, y, z):2050                '''docstring2051                .. admonition:: Example:2052                    .. literalinclude:: ../samples/sample_detect_language.py2053                '''2054            """2055        )2056        with self.assertNoMessages():2057            self.checker.visit_functiondef(function_node)2058    def test_ignores_correct_admonition_statement_in_function_with_comments(self):2059        function_node = astroid.extract_node(2060            """2061            def function_foo(x, y, z):2062                '''docstring2063                .. admonition:: Example:2064                    This is Example content.2065                    Should support multi-line.2066                    Can also include file:2067                    .. literalinclude:: ../samples/sample_detect_language.py2068                '''2069            """2070        )2071        with self.assertNoMessages():2072            self.checker.visit_functiondef(function_node)2073    def test_bad_admonition_statement_in_function(self):2074        function_node = astroid.extract_node(2075            """2076            def function_foo(x, y, z):2077                '''docstring2078                .. admonition:: Example:2079                    .. literalinclude:: ../samples/sample_detect_language.py2080                '''2081            """2082        )2083        with self.assertAddsMessages(2084                pylint.testutils.Message(2085                    msg_id="docstring-admonition-needs-newline", node=function_node2086                )2087        ):2088            self.checker.visit_functiondef(function_node)2089    def test_bad_admonition_statement_in_function_with_comments(self):2090        function_node = astroid.extract_node(2091            """2092            def function_foo(x, y, z):2093                '''docstring2094                .. admonition:: Example:2095                    This is Example content.2096                    Should support multi-line.2097                    Can also include file:2098                    .. literalinclude:: ../samples/sample_detect_language.py2099                '''2100            """2101        )2102        with self.assertAddsMessages(2103                pylint.testutils.Message(2104                    msg_id="docstring-admonition-needs-newline", node=function_node2105                )2106        ):2107            self.checker.visit_functiondef(function_node)2108    def test_ignores_correct_admonition_statement_in_function_async(self):2109        function_node = astroid.extract_node(2110            """2111            async def function_foo(x, y, z):2112                '''docstring2113                .. admonition:: Example:2114                    .. literalinclude:: ../samples/sample_detect_language.py2115                '''2116            """2117        )2118        with self.assertNoMessages():2119            self.checker.visit_asyncfunctiondef(function_node)2120    def test_ignores_correct_admonition_statement_in_function_with_comments_async(self):2121        function_node = astroid.extract_node(...test_function_order_checker.py
Source:test_function_order_checker.py  
...12                first() #@13            """)14        with self.assertAddsMessages(pylint.testutils.Message(msg_id='wrong-function-order', node=first_node,15                                                              ),):16            self.checker.visit_functiondef(first_node)17            self.checker.leave_functiondef(first_node)18            self.checker.visit_functiondef(second_node)19            self.checker.visit_call(call_node)20            self.checker.leave_functiondef(second_node)21    def test_function_order_when_caller_before_callee(self):22        first_node, call_node, second_node = astroid.extract_node("""23            def first(): #@24                second() #@25            def second(): #@26                pass27            """)28        with self.assertNoMessages():29            self.checker.visit_functiondef(first_node)30            self.checker.visit_call(call_node)31            self.checker.leave_functiondef(first_node)32            self.checker.visit_functiondef(second_node)33            self.checker.leave_functiondef(second_node)34    def test_method_order_when_caller_after_callee(self):35        first_node, second_node, call_node = astroid.extract_node("""36            class Foo:37                def first(self): #@38                    pass39                def second(self): #@40                    self.first() #@ """)41        with self.assertAddsMessages(pylint.testutils.Message(msg_id='wrong-method-order', node=first_node,42                                                              ),):43            self.checker.visit_functiondef(first_node)44            self.checker.leave_functiondef(first_node)45            self.checker.visit_functiondef(second_node)46            self.checker.visit_call(call_node)47            self.checker.leave_functiondef(second_node)48    def test_method_order_when_caller_before_callee(self):49        first_node, call_node, second_node = astroid.extract_node("""50            class Foo:51                def first(self): #@52                    self.second() #@53                def second(self): #@54                    pass""")55        with self.assertNoMessages():56            self.checker.visit_functiondef(first_node)57            self.checker.visit_call(call_node)58            self.checker.leave_functiondef(first_node)59            self.checker.visit_functiondef(second_node)60            self.checker.leave_functiondef(second_node)61    def test_method_order_ignored_when_inner_function(self):62        first_node, second_node, call_node = astroid.extract_node("""63            class Foo:64                def outer(self): #@65                    def inner(): #@66                        return True67                    inner() #@68            """)69        with self.assertNoMessages():70            self.checker.visit_functiondef(first_node)71            self.checker.visit_functiondef(second_node)72            self.checker.leave_functiondef(second_node)73            self.checker.visit_call(call_node)74            self.checker.leave_functiondef(first_node)75if __name__ == "__main__":...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!!
