pytest-csv-params/tests/test_complex_example.py

38 lines
1.1 KiB
Python

"""
Example Test Case from the documentation
"""
from math import ceil
from os.path import dirname, join
from pytest_csv_params.decorator import csv_params
@csv_params(
data_file="example.csv",
base_dir=join(dirname(__file__), "assets"),
id_col="Test ID",
header_renames={
"Bananas shipped": "bananas_shipped",
"Single Banana Weight": "banana_weight",
"Apples shipped": "apples_shipped",
"Single Apple Weight": "apple_weight",
"Container Size": "container_size",
},
data_casts={
"bananas_shipped": int,
"banana_weight": float,
"apples_shipped": int,
"apple_weight": float,
"container_size": int,
},
)
def test_container_size_is_big_enough(
bananas_shipped: int, banana_weight: float, apples_shipped: int, apple_weight: float, container_size: int
) -> None:
"""
This is just an example test case for the documentation.
"""
gross_weight = (banana_weight * bananas_shipped) + (apple_weight * apples_shipped)
assert ceil(gross_weight) <= container_size