#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.config.__init__.py:910
(self, pytester: Pytester, capwarn)
| 696 | assert lineno == 4 |
| 697 | |
| 698 | def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None: |
| 699 | """#4445: Make sure the warning points to a reasonable location |
| 700 | See origin of _issue_warning_captured at: _pytest.config.__init__.py:910 |
| 701 | """ |
| 702 | pytester.makeconftest( |
| 703 | """ |
| 704 | import nothing |
| 705 | """ |
| 706 | ) |
| 707 | pytester.parseconfig("--help") |
| 708 | |
| 709 | # with stacklevel=2 the warning should originate from config._preparse and is |
| 710 | # thrown by an erroneous conftest.py |
| 711 | assert len(capwarn.captured) == 1 |
| 712 | warning, location = capwarn.captured.pop() |
| 713 | file, _, func = location |
| 714 | |
| 715 | assert "could not load initial conftests" in str(warning.message) |
| 716 | assert f"config{os.sep}__init__.py" in file |
| 717 | assert func == "_preparse" |
| 718 | |
| 719 | @pytest.mark.filterwarnings("default") |
| 720 | def test_conftest_warning_captured(self, pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected