forked from allure-framework/allure-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.py
More file actions
24 lines (17 loc) · 641 Bytes
/
content.py
File metadata and controls
24 lines (17 loc) · 641 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import csv
import io
from hamcrest.core.base_matcher import BaseMatcher
class CsvEquivalent(BaseMatcher):
def __init__(self, rows, **csv_kwargs):
self.__rows = rows
self.__csv_kwargs = csv_kwargs
def _matches(self, item):
with io.StringIO(item, newline="") as stream:
reader = csv.reader(stream, **self.__csv_kwargs)
return list(reader) == self.__rows
def describe_to(self, description):
description.append_text(
f"csv document equivalent to {self.__rows!r}"
)
def csv_equivalent(rows, **csv_kwargs):
return CsvEquivalent(rows, **csv_kwargs)