Skip to main content

Pytest style fixtures outside of Pytest.

Project description

Fixtures

Pytest style fixtures outside of Pytest.

import asyncio
from pathlib import Path
from py_fixtures 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.0.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

pyfixtures-1.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pyfixtures-1.0.0.tar.gz.

File metadata

  • Download URL: pyfixtures-1.0.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.13 Linux/5.13.0-1023-azure

File hashes

Hashes for pyfixtures-1.0.0.tar.gz
Algorithm Hash digest
SHA256 448b32e584316c3fb5b90e72ed69b12ebd8dbaf8abf7f7dc757070ac07575e97
MD5 1f2ead86f1fea573df4eb8e303e810c6
BLAKE2b-256 2dbcac7a40f118261a1447d47d9bd8e2c4b2fb2cad7ca495bb5a955979dce1c1

See more details on using hashes here.

File details

Details for the file pyfixtures-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyfixtures-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.13 Linux/5.13.0-1023-azure

File hashes

Hashes for pyfixtures-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6deadee0c105cd425539a17a98a17b59367c5179696a1e336159dd30b2fb58ee
MD5 30b23d3e6a65af376fec825338b0e373
BLAKE2b-256 9db14e17fefb0729c2903f5831bcccb7faeb6fdade5b8453e46f90f4ddfbf3c8

See more details on using hashes here.

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