Example #1
0
@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(tuples(text(), integers(min_value=21), text(), integers(min_value=21), text()))
def test_keep_entry_range_returns_False_if_no_portion_of_input_is_between_the_range_bounds(x):
    s = ''.join(map(py23_str, x))
    assume(all(not (1 <= int(i) <= 20) for i in re.findall(r'\d+', s) if re.match(r'\d+$', i)))
    assert not keep_entry_range(s, [1], [20], int, re.compile(r'\d+'))


def test_exclude_entry_returns_True_if_exlcude_parameters_are_not_in_input_example():
    assert exclude_entry('a56b23c89', [100, 45], int, re.compile(r'\d+'))


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(tuples(text(), integers(min_value=0), text(), integers(min_value=0), text()))
def test_exclude_entry_returns_True_if_exlcude_parameters_are_not_in_input(x):
    s = ''.join(map(py23_str, x))
    assume(not any(int(i) in (23, 45, 87) for i in re.findall(r'\d+', s) if re.match(r'\d+$', i)))
    assert exclude_entry(s, [23, 45, 87], int, re.compile(r'\d+'))


def test_exclude_entry_returns_False_if_exlcude_parameters_are_in_input_example():
    assert not exclude_entry('a56b23c89', [23], int, re.compile(r'\d+'))


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(tuples(text(), sampled_from([23, 45, 87]), text(), sampled_from([23, 45, 87]), text()))
def test_exclude_entry_returns_False_if_exlcude_parameters_are_in_input(x):
    s = ''.join(map(py23_str, x))
    assume(any(int(i) in (23, 45, 87) for i in re.findall(r'\d+', s) if re.match(r'\d+$', i)))
    assert not exclude_entry(s, [23, 45, 87], int, re.compile(r'\d+'))

@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given([py23_str, int])
def test_py3_safe_inserts_empty_string_between_two_numbers(x):
    assume(bool(x))
    assert _py3_safe(x, False, isint) == sep_inserter(x, (int, long), '')


def test_path_splitter_splits_path_string_by_separator_example():
    z = '/this/is/a/path'
    assert _path_splitter(z) == list(pathlib.Path(z).parts)


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given([sampled_from(string.ascii_letters)])
def test_path_splitter_splits_path_string_by_separator(x):
    assume(len(x) > 1)
    assume(all(x))
    z = py23_str(pathlib.Path(*x))
    assert _path_splitter(z) == list(pathlib.Path(z).parts)


def test_path_splitter_splits_path_string_by_separator_and_removes_extension_example():
    z = '/this/is/a/path/file.exe'
    y = list(pathlib.Path(z).parts)
    assert _path_splitter(z) == y[:-1] + [pathlib.Path(z).stem] + [pathlib.Path(z).suffix]


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given([sampled_from(string.ascii_letters)])
Example #3
0

@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(
    tuples(text(), integers(min_value=0), text(), integers(min_value=0),
           text()))
def test_exclude_entry_returns_True_if_exlcude_parameters_are_not_in_input(x):
    s = ''.join(map(py23_str, x))
    assume(not any(
        int(i) in (23, 45, 87)
        for i in re.findall(r'\d+', s) if re.match(r'\d+$', i)))
    assert exclude_entry(s, [23, 45, 87], int, re.compile(r'\d+'))


def test_exclude_entry_returns_False_if_exlcude_parameters_are_in_input_example(
):
    assert not exclude_entry('a56b23c89', [23], int, re.compile(r'\d+'))


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(
    tuples(text(), sampled_from([23, 45, 87]), text(),
           sampled_from([23, 45, 87]), text()))
def test_exclude_entry_returns_False_if_exlcude_parameters_are_in_input(x):
    s = ''.join(map(py23_str, x))
    assume(
        any(
            int(i) in (23, 45, 87) for i in re.findall(r'\d+', s)
            if re.match(r'\d+$', i)))
    assert not exclude_entry(s, [23, 45, 87], int, re.compile(r'\d+'))
Example #4
0
@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(lists(elements=text() | integers()))
def test_sep_inserter_inserts_separator_between_two_numbers(x):
    assume(bool(x))
    assert list(_sep_inserter(iter(x), '')) == list(add_leading_space_if_first_is_num(sep_inserter(x, ''), ''))


def test_path_splitter_splits_path_string_by_separator_example():
    z = '/this/is/a/path'
    assert tuple(_path_splitter(z)) == tuple(pathlib.Path(z).parts)
    z = pathlib.Path('/this/is/a/path')
    assert tuple(_path_splitter(z)) == tuple(pathlib.Path(z).parts)


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(lists(sampled_from(string.ascii_letters), min_size=2))
def test_path_splitter_splits_path_string_by_separator(x):
    assume(all(x))
    z = py23_str(pathlib.Path(*x))
    assert tuple(_path_splitter(z)) == tuple(pathlib.Path(z).parts)


def test_path_splitter_splits_path_string_by_separator_and_removes_extension_example():
    z = '/this/is/a/path/file.exe'
    y = tuple(pathlib.Path(z).parts)
    assert tuple(_path_splitter(z)) == y[:-1] + (pathlib.Path(z).stem, pathlib.Path(z).suffix)


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(lists(sampled_from(string.ascii_letters), min_size=3))
def test_path_splitter_splits_path_string_by_separator_and_removes_extension(x):
Example #5
0

@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(lists(elements=text() | integers()))
def test_py3_safe_inserts_empty_string_between_two_numbers(x):
    assume(bool(x))
    assert _py3_safe(x, False, isint) == sep_inserter(x, (int, long), '')


def test_path_splitter_splits_path_string_by_separator_example():
    z = '/this/is/a/path'
    assert _path_splitter(z) == list(pathlib.Path(z).parts)


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given(lists(sampled_from(string.ascii_letters), min_size=2))
def test_path_splitter_splits_path_string_by_separator(x):
    assume(all(x))
    z = py23_str(pathlib.Path(*x))
    assert _path_splitter(z) == list(pathlib.Path(z).parts)


def test_path_splitter_splits_path_string_by_separator_and_removes_extension_example(
):
    z = '/this/is/a/path/file.exe'
    y = list(pathlib.Path(z).parts)
    assert _path_splitter(z) == y[:-1] + [pathlib.Path(z).stem
                                          ] + [pathlib.Path(z).suffix]


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
Example #6
0
@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given((py23_str, integers_from(21), py23_str, integers_from(21), py23_str))
def test_keep_entry_range_returns_False_if_no_portion_of_input_is_between_the_range_bounds(x):
    s = ''.join(map(py23_str, x))
    assume(all(not (1 <= int(i) <= 20) for i in re.findall(r'\d+', s) if re.match(r'\d+$', i)))
    assert not keep_entry_range(s, [1], [20], int, re.compile(r'\d+'))


def test_exclude_entry_returns_True_if_exlcude_parameters_are_not_in_input_example():
    assert exclude_entry('a56b23c89', [100, 45], int, re.compile(r'\d+'))


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given((py23_str, integers_from(0), py23_str, integers_from(0), py23_str))
def test_exclude_entry_returns_True_if_exlcude_parameters_are_not_in_input(x):
    s = ''.join(map(py23_str, x))
    assume(not any(int(i) in (23, 45, 87) for i in re.findall(r'\d+', s) if re.match(r'\d+$', i)))
    assert exclude_entry(s, [23, 45, 87], int, re.compile(r'\d+'))


def test_exclude_entry_returns_False_if_exlcude_parameters_are_in_input_example():
    assert not exclude_entry('a56b23c89', [23], int, re.compile(r'\d+'))


@pytest.mark.skipif(not use_hypothesis, reason='requires python2.7 or greater')
@given((py23_str, sampled_from([23, 45, 87]), py23_str, sampled_from([23, 45, 87]), py23_str))
def test_exclude_entry_returns_False_if_exlcude_parameters_are_in_input(x):
    s = ''.join(map(py23_str, x))
    assume(any(int(i) in (23, 45, 87) for i in re.findall(r'\d+', s) if re.match(r'\d+$', i)))
    assert not exclude_entry(s, [23, 45, 87], int, re.compile(r'\d+'))