vedro-matrix
vedro-matrix is a Python package that extends the Vedro framework, enabling parameterized testing with matrix combinations. It simplifies the process of creating and managing multiple test scenarios, especially when dealing with combinations of different test parameters like browsers, screen resolutions, user types, etc.
Installation
Install vedro-matrix using pip:
$ pip install vedro-matrix
Usage
To use vedro-matrix, import the params_matrix decorator from the package and apply it to your test scenarios in a vedro test suite.
Example
Here is an example of how to use vedro-matrix to test a web page's rendering on different browsers and resolutions:
import vedro
from vedro_matrix import params_matrix
class Scenario(vedro.Scenario):
subject = "Open /about page ({browser}, {resolution})"
@params_matrix(
["chrome", "firefox"],
["1024x720", "1920x1080"],
)
def __init__(self, browser, resolution):
self.browser = browser
self.resolution = resolution
def when_user_opens_page(self):
self.page = open_about_page(self.browser, self.resolution)
def then_it_should_show_main_content(self):
assert self.page.main_content.is_visible()
This script will generate and run 4 separate test scenarios:
- Open /about page (chrome, 1024x720)
- Open /about page (chrome, 1920x1080)
- Open /about page (firefox, 1024x720)
- Open /about page (firefox, 1920x1080)
Running Tests
Run the scenarios using the vedro command:
$ vedro run
You should see an output similar to the following, indicating that all scenarios have passed:
Scenarios
*
✔ Open /about page (chrome, 1024x720)
✔ Open /about page (chrome, 1920x1080)
✔ Open /about page (firefox, 1024x720)
✔ Open /about page (firefox, 1920x1080)
# --seed 79b84f2d-e98c-47bf-b057-acdf597c4143
# 4 scenarios, 4 passed, 0 failed, 0 skipped (1.51s)
Additional Usage Examples
In addition to the standard matrix setup with fixed parameters, vedro-matrix offers flexible options to generate test cases using various types of iterables, like lists or enums, which simplifies the process of defining complex combinations of test inputs.
1. Simple Numeric Parameters
You can use vedro-matrix to test different inputs, such as numeric IDs or other sequences. Here's an example where post_id varies:
import vedro
from vedro_matrix import params_matrix
class Scenario(vedro.Scenario):
@params_matrix([1, 2, 3])
def __init__(self, post_id):
self.post_id = post_id
This will generate and run 3 test cases with the following values for post_id:
- Scenario with
post_id = 1 - Scenario with
post_id = 2 - Scenario with
post_id = 3
2. Using Enums for Parameters
In more structured setups, you can use enums to pass values to your test scenarios. This is particularly useful when the test parameters represent distinct options, such as browser types or user roles. Here's how to achieve that:
import vedro
from vedro_matrix import params_matrix
from enum import StrEnum
class Browser(StrEnum):
CHROME = "chrome"
FIREFOX = "firefox"
class Scenario(vedro.Scenario):
@params_matrix(Browser)
def __init__(self, browser):
self.browser = browser
In this case, vedro-matrix will generate two scenarios:
- Scenario with
browser = "chrome" - Scenario with
browser = "firefox"
This approach improves code readability and maintainability, especially when managing larger test matrices with more complex inputs.
Metadata
Release files for vedro-matrix 1.0.0
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 |
|---|---|---|---|---|
| vedro_matrix-1.0.0.tar.gz | 6.9 kB | Without provenance | Details for vedro_matrix-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vedro_matrix-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for vedro_matrix-1.0.0-py3-none-any.whl |
Total release size: 14.5 kB
Release files / vedro_matrix-1.0.0.tar.gz
| Download URL | vedro_matrix-1.0.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
893db764a691729a02d32cfdf095c41c671a48deaa493496fd822c2f37bb3a35
|
|
BLAKE2b-256 checksum How to use checksums |
f161611e727ec820728e64f28bd191057da62eeb822d1a59104dcfcbbc642ca1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Release files / vedro_matrix-1.0.0-py3-none-any.whl
| Download URL | vedro_matrix-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4d695cd597453e5fa45328c24f59f96174462abe1b4a5be35a536c960cf8edb
|
|
BLAKE2b-256 checksum How to use checksums |
74c7695e38180b685ae5823a4a8eb4c5d815fb4480683326e56b87c2ef81bdda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Security for vedro-matrix 1.0.0
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.