| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1513,6 +1513,60 @@ def test_parameters_required_after_star(self): | |||
| 1513 | 1513 | with self.subTest(block=block): | |
| 1514 | 1514 | self.expect_failure(block, err) | |
| 1515 | 1515 | ||
| 1516 | + def test_fulldisplayname_class(self): | ||
| 1517 | + dataset = ( | ||
| 1518 | + ("T", """ | ||
| 1519 | + class T "void *" "" | ||
| 1520 | + T.__init__ | ||
| 1521 | + """), | ||
| 1522 | + ("m.T", """ | ||
| 1523 | + module m | ||
| 1524 | + class m.T "void *" "" | ||
| 1525 | + @classmethod | ||
| 1526 | + m.T.__new__ | ||
| 1527 | + """), | ||
| 1528 | + ("m.T.C", """ | ||
| 1529 | + module m | ||
| 1530 | + class m.T "void *" "" | ||
| 1531 | + class m.T.C "void *" "" | ||
| 1532 | + m.T.C.__init__ | ||
| 1533 | + """), | ||
| 1534 | + ) | ||
| 1535 | + for name, code in dataset: | ||
| 1536 | + with self.subTest(name=name, code=code): | ||
| 1537 | + block = self.parse(code) | ||
| 1538 | + func = block.signatures[-1] | ||
| 1539 | + self.assertEqual(func.fulldisplayname, name) | ||
| 1540 | + | ||
| 1541 | + def test_fulldisplayname_meth(self): | ||
| 1542 | + dataset = ( | ||
| 1543 | + ("func", "func"), | ||
| 1544 | + ("m.func", """ | ||
| 1545 | + module m | ||
| 1546 | + m.func | ||
| 1547 | + """), | ||
| 1548 | + ("T.meth", """ | ||
| 1549 | + class T "void *" "" | ||
| 1550 | + T.meth | ||
| 1551 | + """), | ||
| 1552 | + ("m.T.meth", """ | ||
| 1553 | + module m | ||
| 1554 | + class m.T "void *" "" | ||
| 1555 | + m.T.meth | ||
| 1556 | + """), | ||
| 1557 | + ("m.T.C.meth", """ | ||
| 1558 | + module m | ||
| 1559 | + class m.T "void *" "" | ||
| 1560 | + class m.T.C "void *" "" | ||
| 1561 | + m.T.C.meth | ||
| 1562 | + """), | ||
| 1563 | + ) | ||
| 1564 | + for name, code in dataset: | ||
| 1565 | + with self.subTest(name=name, code=code): | ||
| 1566 | + block = self.parse(code) | ||
| 1567 | + func = block.signatures[-1] | ||
| 1568 | + self.assertEqual(func.fulldisplayname, name) | ||
| 1569 | + | ||
| 1516 | 1570 | def test_depr_star_invalid_format_1(self): | |
| 1517 | 1571 | block = """ | |
| 1518 | 1572 | module foo | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2682,9 +2682,16 @@ def displayname(self) -> str: | |||
| 2682 | 2682 | ||
| 2683 | 2683 | @functools.cached_property | |
| 2684 | 2684 | def fulldisplayname(self) -> str: | |
| 2685 | - if isinstance(self.module, Module): | ||
| 2686 | - return f"{self.module.name}.{self.displayname}" | ||
| 2687 | - return self.displayname | ||
| 2685 | + parent: Class | Module | Clinic | None | ||
| 2686 | + if self.kind.new_or_init: | ||
| 2687 | + parent = getattr(self.cls, "parent", None) | ||
| 2688 | + else: | ||
| 2689 | + parent = self.parent | ||
| 2690 | + name = self.displayname | ||
| 2691 | + while isinstance(parent, (Module, Class)): | ||
| 2692 | + name = f"{parent.name}.{name}" | ||
| 2693 | + parent = parent.parent | ||
| 2694 | + return name | ||
| 2688 | 2695 | ||
| 2689 | 2696 | @property | |
| 2690 | 2697 | def render_parameters(self) -> list[Parameter]: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments