Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chobeat/hypothesis-csv
Extension for the hypothesis framework to support the generative testing with CSV input
https://github.com/chobeat/hypothesis-csv
csv generative-testing hypothesis property-based-testing python-library python3
Last synced: about 4 hours ago
JSON representation
Extension for the hypothesis framework to support the generative testing with CSV input
- Host: GitHub
- URL: https://github.com/chobeat/hypothesis-csv
- Owner: chobeat
- License: apache-2.0
- Created: 2018-07-19T19:53:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-22T10:08:45.000Z (10 months ago)
- Last Synced: 2024-09-30T10:35:39.238Z (about 1 month ago)
- Topics: csv, generative-testing, hypothesis, property-based-testing, python-library, python3
- Language: Python
- Size: 75.2 KB
- Stars: 24
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
- Authors: AUTHORS.rst
Awesome Lists containing this project
README
==============
hypothesis-csv
==============:code:`hypothesis-csv` is an extension to the `hypothesis` framework. The goal of this framework is to offer a flexible tool
to perform generative-testing/property-based testing for software that accepts CSV files as an input.Description
===========`hypothesis-csv` is designed with two main use cases in mind:
* test software that accepts a wide spectrum of CSV formats and doesn't make assumptions on the content (i.e. CSV parsers)
* test software that accepts very specific CSV formats and makes assumption on the content, types and header fields.It provides two strategies, :code:`data_rows` and :code:`csv`, to pursue this goal, both contained in the `strategies` module.
Please refer to their documentation and the examples for more details.Examples
========Generate arbitrary, non-empty CSV
---------------------------------.. code-block:: python
:name: Generate arbitrary, non-empty CSVfrom hypothesis_csv.strategies import csv
@given(csv=csv())
def test_my_csv_parse(csv):
parsed_csv=my_csv_parser(csv)
assert ...Generate CSV of a given size (5 columns x 20 rows)
--------------------------------------------------.. code-block:: python
:name: Generate CSV of a given size (5 columns x 20 rows)from hypothesis_csv.strategies import csv
@given(csv=csv(lines=20,header=5))
def test_my_csv_parse(csv):
parsed_csv=my_csv_parser(csv)
assert parsed_csv.num_columns == 5
assert parsed_csv.num_rows == 20Generate CSV with a header
--------------------------
.. code-block:: python
:name: Generate CSV with a headerfrom hypothesis_csv.strategies import csv
@given(csv=csv(header=["timestamp","val_1","val_2"]))
def test_my_csv_parse(csv):
parsed_csv=my_csv_parser(csv)
assert parsed_csv.num_columns == 3Generate CSV with columns of a given type
-----------------------------------------.. code-block:: python
:name: Generate CSV with columns of a given typefrom hypothesis_csv.strategies import csv
@given(csv=csv(columns=[text(),int(),float()]))
def test_my_csv_parse(csv):
parsed_csv=my_csv_parser(csv)
assert parsed_csv.num_columns == 3Generate CSV with a given dialect
---------------------------------.. code-block:: python
:name: Generate CSV in a given dialectfrom hypothesis_csv.strategies import csv
@given(csv=csv(columns=[text(),int(),float()], dialect="excel-tab"))
def test_my_csv_parse(csv):
...Generate CSV with drawns dialects
---------------------------------.. code-block:: python
:name: Generate CSV with drawns dialectsfrom hypothesis_csv.strategies import csv
@given(csv=csv(columns=[text(),int(),float()], dialect=None))
def test_my_csv_parse(csv):
...