https://github.com/virtool/pyfixtures
Pytest style fixtures outside of Pytest
https://github.com/virtool/pyfixtures
python
Last synced: 4 months ago
JSON representation
Pytest style fixtures outside of Pytest
- Host: GitHub
- URL: https://github.com/virtool/pyfixtures
- Owner: virtool
- License: mit
- Created: 2022-05-27T21:26:53.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T21:54:21.000Z (about 4 years ago)
- Last Synced: 2024-10-11T20:37:23.950Z (over 1 year ago)
- Topics: python
- Language: Python
- Homepage:
- Size: 68.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.rst
- License: LICENSE
Awesome Lists containing this project
README
# PyFixtures
[Pytest](https://docs.pytest.org/en/7.1.x/) style [fixtures](https://docs.pytest.org/en/6.2.x/fixture.html) outside of Pytest.
```python
import asyncio
from pathlib import Path
from pyfixtures import fixture, FixtureScope
@fixture
def tmpdir() -> path:
path = Path("temp")
path.mkdir()
try:
yield path
finally:
path.unlink()
def mk_temp_files(tmpdir: Path):
tmp_file = tmpdir/"tempfile.txt"
tmp_file.touch()
async def main():
async with FixtureScope() as scope:
operation = await scope.bind(mk_temp_files)
await operation()
asyncio.run(main())
```