Skip to content

Commit

Permalink
#5: Began adding tests for the item extractor.
Browse files Browse the repository at this point in the history
  • Loading branch information
OOPMan committed Jan 9, 2016
1 parent f5eb0b1 commit 1a919fe
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions rightshift/tests/test_extractors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from math import isnan

from rightshift.extractors import item, attr, pattern_group
from hypothesis import given, assume
from hypothesis.strategies import text, integers, floats, lists, booleans, one_of
from random import randint


def __common_item_tests(data):
assume(len(data) > 0)
index = randint(0, len(data) - 1)
if isinstance(data[index], float):
assume(not isnan(data[index]))
assert item[index](data) == data[index]


@given(text())
def test_item_with_text(data):
__common_item_tests(data)


@given(lists(one_of(text(), integers(), floats(), booleans())))
def test_item_with_lists(data):
__common_item_tests(data)


0 comments on commit 1a919fe

Please sign in to comment.