Skip to main content

Pytest style fixtures outside of Pytest.

Project description

PyFixtures

Pytest style fixtures outside of Pytest.

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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfixtures-1.1.0.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

pyfixtures-1.1.0-py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page