| 479 | |
| 480 | |
| 481 | def test_function_instance(pytester: Pytester) -> None: |
| 482 | items = pytester.getitems( |
| 483 | """ |
| 484 | def test_func(): pass |
| 485 | class TestIt: |
| 486 | def test_method(self): pass |
| 487 | @classmethod |
| 488 | def test_class(cls): pass |
| 489 | @staticmethod |
| 490 | def test_static(): pass |
| 491 | """ |
| 492 | ) |
| 493 | assert len(items) == 3 |
| 494 | assert isinstance(items[0], Function) |
| 495 | assert items[0].name == "test_func" |
| 496 | assert items[0].instance is None |
| 497 | assert isinstance(items[1], Function) |
| 498 | assert items[1].name == "test_method" |
| 499 | assert items[1].instance is not None |
| 500 | assert items[1].instance.__class__.__name__ == "TestIt" |
| 501 | assert isinstance(items[2], Function) |
| 502 | assert items[2].name == "test_static" |
| 503 | assert items[2].instance is None |