| 791 | return self.obj() |
| 792 | |
| 793 | def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]: |
| 794 | if not safe_getattr(self.obj, "__test__", True): |
| 795 | return [] |
| 796 | if hasinit(self.obj): |
| 797 | assert self.parent is not None |
| 798 | self.warn( |
| 799 | PytestCollectionWarning( |
| 800 | "cannot collect test class %r because it has a " |
| 801 | "__init__ constructor (from: %s)" |
| 802 | % (self.obj.__name__, self.parent.nodeid) |
| 803 | ) |
| 804 | ) |
| 805 | return [] |
| 806 | elif hasnew(self.obj): |
| 807 | assert self.parent is not None |
| 808 | self.warn( |
| 809 | PytestCollectionWarning( |
| 810 | "cannot collect test class %r because it has a " |
| 811 | "__new__ constructor (from: %s)" |
| 812 | % (self.obj.__name__, self.parent.nodeid) |
| 813 | ) |
| 814 | ) |
| 815 | return [] |
| 816 | |
| 817 | self._inject_setup_class_fixture() |
| 818 | self._inject_setup_method_fixture() |
| 819 | |
| 820 | self.session._fixturemanager.parsefactories(self.newinstance(), self.nodeid) |
| 821 | |
| 822 | return super().collect() |
| 823 | |
| 824 | def _inject_setup_class_fixture(self) -> None: |
| 825 | """Inject a hidden autouse, class scoped fixture into the collected class object |