(self)
| 365 | self.assertEqual(self.Mine.get_name(), "Mine") |
| 366 | |
| 367 | def test_class_get_methods(self): |
| 368 | deprecation_mess = ( |
| 369 | re.escape('symtable.Class.get_methods() is deprecated ' |
| 370 | 'and will be removed in Python 3.16.') |
| 371 | ) |
| 372 | |
| 373 | with self.assertWarnsRegex(DeprecationWarning, deprecation_mess): |
| 374 | self.assertEqual(self.Mine.get_methods(), ('a_method',)) |
| 375 | |
| 376 | top = symtable.symtable(TEST_COMPLEX_CLASS_CODE, "?", "exec") |
| 377 | this = find_block(top, "ComplexClass") |
| 378 | |
| 379 | with self.assertWarnsRegex(DeprecationWarning, deprecation_mess): |
| 380 | self.assertEqual(this.get_methods(), ( |
| 381 | 'a_method', 'a_method_pep_695', |
| 382 | 'an_async_method', 'an_async_method_pep_695', |
| 383 | 'a_classmethod', 'a_classmethod_pep_695', |
| 384 | 'an_async_classmethod', 'an_async_classmethod_pep_695', |
| 385 | 'a_staticmethod', 'a_staticmethod_pep_695', |
| 386 | 'an_async_staticmethod', 'an_async_staticmethod_pep_695', |
| 387 | 'a_fakemethod', 'a_fakemethod_pep_695', |
| 388 | 'an_async_fakemethod', 'an_async_fakemethod_pep_695', |
| 389 | 'glob_unassigned_meth', 'glob_unassigned_meth_pep_695', |
| 390 | 'glob_unassigned_async_meth', 'glob_unassigned_async_meth_pep_695', |
| 391 | 'glob_assigned_meth', 'glob_assigned_meth_pep_695', |
| 392 | 'glob_assigned_async_meth', 'glob_assigned_async_meth_pep_695', |
| 393 | )) |
| 394 | |
| 395 | # Test generator expressions that are of type TYPE_FUNCTION |
| 396 | # but will not be reported by get_methods() since they are |
| 397 | # not functions per se. |
| 398 | # |
| 399 | # Other kind of comprehensions such as list, set or dict |
| 400 | # expressions do not have the TYPE_FUNCTION type. |
| 401 | |
| 402 | def check_body(body, expected_methods): |
| 403 | indented = textwrap.indent(body, ' ' * 4) |
| 404 | top = symtable.symtable(f"class A:\n{indented}", "?", "exec") |
| 405 | this = find_block(top, "A") |
| 406 | with self.assertWarnsRegex(DeprecationWarning, deprecation_mess): |
| 407 | self.assertEqual(this.get_methods(), expected_methods) |
| 408 | |
| 409 | # statements with 'genexpr' inside it |
| 410 | GENEXPRS = ( |
| 411 | 'x = (x for x in [])', |
| 412 | 'x = (x async for x in [])', |
| 413 | 'type x[genexpr = (x for x in [])] = (x for x in [])', |
| 414 | 'type x[genexpr = (x async for x in [])] = (x async for x in [])', |
| 415 | 'genexpr = (x for x in [])', |
| 416 | 'genexpr = (x async for x in [])', |
| 417 | 'type genexpr[genexpr = (x for x in [])] = (x for x in [])', |
| 418 | 'type genexpr[genexpr = (x async for x in [])] = (x async for x in [])', |
| 419 | ) |
| 420 | |
| 421 | for gen in GENEXPRS: |
| 422 | # test generator expression |
| 423 | with self.subTest(gen=gen): |
| 424 | check_body(gen, ()) |
nothing calls this directly
no test coverage detected