Reproducer for #11895: short paths not collected on Windows.
(pytester: Pytester)
| 1758 | |
| 1759 | @pytest.mark.skipif(not sys.platform.startswith("win"), reason="Windows only") |
| 1760 | def test_collect_short_file_windows(pytester: Pytester) -> None: |
| 1761 | """Reproducer for #11895: short paths not collected on Windows.""" |
| 1762 | short_path = tempfile.mkdtemp() |
| 1763 | if "~" not in short_path: # pragma: no cover |
| 1764 | if running_on_ci(): |
| 1765 | # On CI, we are expecting that under the current GitHub actions configuration, |
| 1766 | # tempfile.mkdtemp() is producing short paths, so we want to fail to prevent |
| 1767 | # this from silently changing without us noticing. |
| 1768 | pytest.fail( |
| 1769 | f"tempfile.mkdtemp() failed to produce a short path on CI: {short_path}" |
| 1770 | ) |
| 1771 | else: |
| 1772 | # We want to skip failing this test locally in this situation because |
| 1773 | # depending on the local configuration tempfile.mkdtemp() might not produce a short path: |
| 1774 | # For example, user might have configured %TEMP% exactly to avoid generating short paths. |
| 1775 | pytest.skip( |
| 1776 | f"tempfile.mkdtemp() failed to produce a short path: {short_path}, skipping" |
| 1777 | ) |
| 1778 | |
| 1779 | test_file = Path(short_path).joinpath("test_collect_short_file_windows.py") |
| 1780 | test_file.write_text("def test(): pass", encoding="UTF-8") |
| 1781 | result = pytester.runpytest(short_path) |
| 1782 | assert result.parseoutcomes() == {"passed": 1} |
| 1783 | |
| 1784 | |
| 1785 | def test_collect_short_file_windows_multi_level_symlink( |
nothing calls this directly
no test coverage detected