A pytest plugin for testing logic that should work the same way across different types of functions: regular, async, and generator ones
Project description
If your code needs to work the same way with regular, asynchronous, and generator functions, you normally have to write three sets of nearly identical tests. With this library, you no longer need to do that — just use the special pytest fixture, which automatically generates the variants.
Usage
To use the fixture, install it via:
pip install transtests
The transformed fixture is now available. It returns a decorator that transforms the original function into one of three variants: a synchronous function, an asynchronous function, or a generator function:
from asyncio import run
from inspect import iscoroutinefunction, isgeneratorfunction
def test_something(transformed):
@transformed
def some_function(a, b):
return a + b
if iscoroutinefunction(some_function):
assert run(some_function(1, 2)) == 3
elif isgeneratorfunction(some_function):
assert list(some_function(1, 2)) == [3]
else:
assert some_function(1, 2) == 3
↑ The test will be run three times automatically, once per variant.
This functionality is based on the transfunctions library, so you can use context managers from that library in the source function.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transtests-0.0.1.tar.gz.
File metadata
- Download URL: transtests-0.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbecddf65de246349daf0ca3bde254ada574eedd055936cea0e200d1cdbdff9e
|
|
| MD5 |
8940cdae6912a25c72327c5448a65aa1
|
|
| BLAKE2b-256 |
2c96ee2195a1ce43bf8a5e75eee01683e2c29ac1817f890a33b1880f9ba9a674
|
Provenance
The following attestation bundles were made for transtests-0.0.1.tar.gz:
Publisher:
release.yml on mutating/transtests
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transtests-0.0.1.tar.gz -
Subject digest:
bbecddf65de246349daf0ca3bde254ada574eedd055936cea0e200d1cdbdff9e - Sigstore transparency entry: 1199396943
- Sigstore integration time:
-
Permalink:
mutating/transtests@b4885f56d33b8967f085ca416b01bd6e98948fd8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mutating
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b4885f56d33b8967f085ca416b01bd6e98948fd8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file transtests-0.0.1-py3-none-any.whl.
File metadata
- Download URL: transtests-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68774e7f7a7ca3a4ff99b18bd597e26f67b329396d51fc834a55c5c011477960
|
|
| MD5 |
ed658cf997de6cf1844545155791c47f
|
|
| BLAKE2b-256 |
c44b671bec37c6d1438336b0259f060fe073f67e06ea73de74b6cce658070d05
|
Provenance
The following attestation bundles were made for transtests-0.0.1-py3-none-any.whl:
Publisher:
release.yml on mutating/transtests
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transtests-0.0.1-py3-none-any.whl -
Subject digest:
68774e7f7a7ca3a4ff99b18bd597e26f67b329396d51fc834a55c5c011477960 - Sigstore transparency entry: 1199396997
- Sigstore integration time:
-
Permalink:
mutating/transtests@b4885f56d33b8967f085ca416b01bd6e98948fd8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mutating
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b4885f56d33b8967f085ca416b01bd6e98948fd8 -
Trigger Event:
push
-
Statement type: