This release is a pre-release and may not be stable for production use.
Th2 pytest bdd plugin
This is the plugin for pytest, which uses pytest-bdd plugin and th2 as backend.
Features
- Typed tables in feature file;
- Th2 client boilerplate isolation (auto th2 access factory creation, events hierarchy creation in background);
- Test context.
Installation
-
From PyPI
This package can be found on PyPI.pip install pytest-th2-bdd -
From Source
git clone https://github.com/th2-net/pytest-th2-bdd pip install pytest-th2-bdd/
Available fixtures
factory
This fixture yields th2 CommonFactory for which will be created from configuration located in configs/ directory.
ctx
This fixture is used for inter-steps communication. It has some important service items:
| key | purpose |
|---|---|
__ROOT__ |
root events for each feature |
__SCENARIO__ |
current scenario root event |
__SCENARIO_START__ |
current scenario start datetime (in UTC) |
__STEP__ |
current step event |
Requirements
- Prepared th2 test environment;
- Configuration for th2 CommonFactory in
configs/directory;
How to use tables
Imagine, that you need to pass data as table in some step:
| field1 | field2 | ... | fieldN |
| 1 | 2 | ... | 3 |
...
| valN | valK | ... | valM |
- You need to declare dataclass with header definition:
@dataclass
class SomeRow:
field1: str
field2: str
...
fieldN: str
- Add field and converter at the desired step definition
@given(
parsers.cfparse(
"some step description {var1} ... \n{table}",
),
converters={"table": Table(SomeRow)}, # converter setup
)
def some_step(var1, table: Table[SomeRow]): # Syntax hints via generics
...
How to start test process (with installed plugin)
pytest tests/
How to start test process (without installed plugin)
export PYTHONPATH=path/to/directory/with/this/repository:$PYTHONPATH
pytest -p th2_bdd.pytest tests/
Metadata
Release files for pytest-th2-bdd 0.0.1.dev2320248668
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_th2_bdd-0.0.1.dev2320248668.tar.gz | 6.8 kB | Without provenance | Details for pytest_th2_bdd-0.0.1.dev2320248668.tar.gz |
Release files / pytest_th2_bdd-0.0.1.dev2320248668.tar.gz
| Download URL | pytest_th2_bdd-0.0.1.dev2320248668.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ee67c48a1b492b2cb6713a16892489d548345c7df4b8ba487695ece9fe695be
|
|
BLAKE2b-256 checksum How to use checksums |
e8076769a82c6965eb6e26006a270a02799e536f60c8b07684ed2e7ad7053039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Security for pytest-th2-bdd 0.0.1.dev2320248668
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.