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