Reproducer for issue #9765 on Windows https://github.com/pytest-dev/pytest/issues/9765
(pytester: Pytester)
| 1519 | |
| 1520 | @pytest.mark.skip(reason="Test is not isolated") |
| 1521 | def test_issue_9765(pytester: Pytester) -> None: |
| 1522 | """Reproducer for issue #9765 on Windows |
| 1523 | |
| 1524 | https://github.com/pytest-dev/pytest/issues/9765 |
| 1525 | """ |
| 1526 | pytester.makepyprojecttoml( |
| 1527 | """ |
| 1528 | [tool.pytest.ini_options] |
| 1529 | addopts = "-p my_package.plugin.my_plugin" |
| 1530 | """ |
| 1531 | ) |
| 1532 | pytester.makepyfile( |
| 1533 | **{ |
| 1534 | "setup.py": ( |
| 1535 | """ |
| 1536 | from setuptools import setup |
| 1537 | |
| 1538 | if __name__ == '__main__': |
| 1539 | setup(name='my_package', packages=['my_package', 'my_package.plugin']) |
| 1540 | """ |
| 1541 | ), |
| 1542 | "my_package/__init__.py": "", |
| 1543 | "my_package/conftest.py": "", |
| 1544 | "my_package/test_foo.py": "def test(): pass", |
| 1545 | "my_package/plugin/__init__.py": "", |
| 1546 | "my_package/plugin/my_plugin.py": ( |
| 1547 | """ |
| 1548 | import pytest |
| 1549 | |
| 1550 | def pytest_configure(config): |
| 1551 | |
| 1552 | class SimplePlugin: |
| 1553 | @pytest.fixture(params=[1, 2, 3]) |
| 1554 | def my_fixture(self, request): |
| 1555 | yield request.param |
| 1556 | |
| 1557 | config.pluginmanager.register(SimplePlugin()) |
| 1558 | """ |
| 1559 | ), |
| 1560 | } |
| 1561 | ) |
| 1562 | |
| 1563 | subprocess.run( |
| 1564 | [sys.executable, "-Im", "pip", "install", "-e", "."], |
| 1565 | check=True, |
| 1566 | ) |
| 1567 | try: |
| 1568 | # We are using subprocess.run rather than pytester.run on purpose. |
| 1569 | # pytester.run is adding the current directory to PYTHONPATH which avoids |
| 1570 | # the bug. We also use pytest rather than python -m pytest for the same |
| 1571 | # PYTHONPATH reason. |
| 1572 | subprocess.run( |
| 1573 | ["pytest", "my_package"], |
| 1574 | capture_output=True, |
| 1575 | check=True, |
| 1576 | encoding="utf-8", |
| 1577 | text=True, |
| 1578 | ) |
nothing calls this directly
no test coverage detected