-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failed test_non_zero_cost shows filename
- Loading branch information
Showing
2 changed files
with
18 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import csv | ||
import os | ||
from pathlib import Path | ||
from typing import List | ||
|
||
import pytest | ||
|
||
files = sorted(Path(os.environ["CATALOG_DIR"]).glob("*.csv")) | ||
|
||
@pytest.fixture | ||
def catalog_files(catalog_dir: Path) -> List[Path]: | ||
return list(catalog_dir.glob("*.csv")) | ||
|
||
def catalog_name(catalog) -> str: | ||
return catalog.name | ||
|
||
|
||
class TestAllCatalogs: | ||
def test_non_zero_cost(self, catalog_files: List[Path]): | ||
for file in catalog_files: | ||
with open(file, "r") as f: | ||
reader = csv.DictReader(f) | ||
prices = [float(row["price"]) for row in reader] | ||
assert 0 not in prices | ||
@pytest.fixture(params=files, ids=catalog_name) | ||
def catalog(self, request): | ||
yield request.param | ||
|
||
def test_non_zero_cost(self, catalog): | ||
reader = csv.DictReader(catalog.open()) | ||
for row in reader: | ||
assert float(row["price"]) != pytest.approx(0), str(row) |