-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
A plugin for making referencing objects usable within Hypothesis. | ||
This module is meant to be used as an entry point, meaning it should | ||
automatically be imported if both referencing and hypothesis are being used. | ||
See https://hypothesis.readthedocs.io/en/latest/strategies.html#hypothesis-integration-via-setuptools-entry-points | ||
and/or https://hatch.pypa.io/latest/config/metadata/#entry-points for further | ||
details. | ||
""" | ||
|
||
from typing import Callable, TypeVar | ||
|
||
from hypothesis import strategies | ||
|
||
from referencing import Resource | ||
|
||
contents = strategies.integers() | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
def register(cls: type[T]): | ||
def _register(strategy: Callable[[], T]): | ||
strategies.register_type_strategy(cls, strategy) | ||
return strategy | ||
|
||
return _register | ||
|
||
|
||
@register(Resource) | ||
def resource(): | ||
return contents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Tests for (and via) referencing's Hypothesis support. | ||
""" | ||
|
||
from hypothesis import given, strategies | ||
|
||
from referencing import Resource, Specification | ||
|
||
|
||
@given(strategies.builds(Resource, specification=Specification.OPAQUE)) | ||
def test_opaque_resources_do_not_have_ids(resource): | ||
print(resource) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
file:.#egg=referencing | ||
hypothesis | ||
pytest | ||
pytest-subtests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters