How to use the hypothesis.given function in hypothesis

To help you get started, we’ve selected a few hypothesis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holoviz / spatialpandas / tests / spatialindex / test_rtree.py View on Github external
@given(st_bounds_array())
def test_bounds_array_generation(bounds_array):
    assert bounds_array.shape[1] % 2 == 0
    n = bounds_array.shape[1] // 2
    for d in range(n):
        assert np.all(bounds_array[:, d + n] >= bounds_array[:, d])
github PokeAPI / pokebase / tests / test_module_interface.py View on Github external
    @given(endpoint=text())
    @patch('pokebase.interface.get_data')
    def testArg_endpoint_Text(self, mock_get_data, endpoint):

        mock_get_data.side_effect = ValueError()

        with self.assertRaises(ValueError):
            interface.APIResourceList(endpoint)
github HypothesisWorks / hypothesis / tests / cover / test_testdecorators.py View on Github external
@given(builds(Litter, integers(), integers()))
def test_named_tuples_are_of_right_type(litter):
    assert isinstance(litter, Litter)
github python-attrs / attrs / tests / test_dunders.py View on Github external
    @given(booleans())
    def test_hash_mirrors_eq(self, eq):
        """
        If `hash` is None, the hash generation mirrors `eq`.
        """
        C = make_class("C", {"a": attr.ib()}, eq=eq, frozen=True)

        i = C(1)

        assert i == i
        assert hash(i) == hash(i)

        if eq:
            assert C(1) == C(1)
            assert hash(C(1)) == hash(C(1))
        else:
            assert C(1) != C(1)
github HypothesisWorks / hypothesis / tests / cover / test_validation.py View on Github external
@given(integers(), integers())
def test_too_many_positional(x):
    pass
github SethMMorton / fastnumbers / tests / test_fastnumbers.py View on Github external
    @given((text() | binary()).filter(not_a_number))
    def test_returns_default_value_if_given_invalid_string(self, x):
        assert fastnumbers.fast_int(x, default=90) == 90
        assert fastnumbers.fast_int(x, 90) == 90
github pyudev / pyudev / tests / _device_tests / _device_tests.py View on Github external
    @given(_CONTEXT_STRATEGY, strategies.sampled_from(_DEVICE_DATA))
    @settings(max_examples=5)
    def test_sys_path(self, a_context, device_datum):
        device = Devices.from_path(a_context, device_datum.device_path)
        assert device.sys_path == device_datum.sys_path
        assert is_unicode_string(device.sys_path)
github dit / dit / tests / utils / test_testing.py View on Github external
@given(dist=distribution_structures(size=2, alphabet=(2, 4), uniform=False))
def test_distribution_structures3(dist):
    """
    A test for the distributions strategy.
    """
    assert dist.outcome_length() == 2
    assert set(dist.alphabet[0]) <= {0, 1, 2, 3}
github ericmjl / pyjanitor / tests / test_functions.py View on Github external
@given(df_strategy())
def test_encode_categorical_missing_column(df):
    with pytest.raises(AssertionError):
        df.encode_categorical("aloha")
github leo-editor / leo-editor / leo / extensions / myleoqt.py View on Github external
@given(data())
def test_select_and_commnads(data):
    app = demo2_app()

    index = data.draw(integers(min_value=0, max_value=10000))
    names = data.draw(lists(sampled_from(method_names), min_size=5,
                             max_size=100))

    select_item_at_index(app, index)
    a1, b1 = outline_shapes(app)
    for name in names:
        meth = getattr(app, name)
        meth()
        print(name)
        app.processEvents()
        if method_names.index(name) > 5:
            # possible change in the outline