Collection works with symlinked files and broken symlinks
(use_pkg: bool, pytester: Pytester)
| 1528 | |
| 1529 | @pytest.mark.parametrize("use_pkg", (True, False)) |
| 1530 | def test_collect_sub_with_symlinks(use_pkg: bool, pytester: Pytester) -> None: |
| 1531 | """Collection works with symlinked files and broken symlinks""" |
| 1532 | sub = pytester.mkdir("sub") |
| 1533 | if use_pkg: |
| 1534 | sub.joinpath("__init__.py").touch() |
| 1535 | sub.joinpath("test_file.py").write_text("def test_file(): pass", encoding="utf-8") |
| 1536 | |
| 1537 | # Create a broken symlink. |
| 1538 | symlink_or_skip("test_doesnotexist.py", sub.joinpath("test_broken.py")) |
| 1539 | |
| 1540 | # Symlink that gets collected. |
| 1541 | symlink_or_skip("test_file.py", sub.joinpath("test_symlink.py")) |
| 1542 | |
| 1543 | result = pytester.runpytest("-v", str(sub)) |
| 1544 | result.stdout.fnmatch_lines( |
| 1545 | [ |
| 1546 | "sub/test_file.py::test_file PASSED*", |
| 1547 | "sub/test_symlink.py::test_file PASSED*", |
| 1548 | "*2 passed in*", |
| 1549 | ] |
| 1550 | ) |
| 1551 | |
| 1552 | |
| 1553 | def test_collector_respects_tbstyle(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected