Skip to content
Snippets Groups Projects

Add a blacklist_types argument to object_dicsts() and objects() hypothesis generators

2 unresolved threads
Compare and
2 files
+ 48
24
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -16,12 +16,17 @@ from swh.model.model import TargetType
target_types = ("content", "directory", "revision", "release", "snapshot", "alias")
@given(objects())
@given(objects(blacklist_types=()))
def test_generation(obj_type_and_obj):
(obj_type, object_) = obj_type_and_obj
attr.validate(object_)
@given(objects(blacklist_types=("origin_visit", "directory")))
def test_generation_blacklist(obj_type_and_obj):
assert obj_type_and_obj[0] not in ("origin_visit", "directory")
    • You should make this a list of object_dicts to make the test more relevant.

      By default, it might only try a couple of objects.

      • Author Maintainer

        According to my runs, it does at least try one of each types, then the number for each type seems to depend on the strategy used for this type.

        Each test execution tries 100 objects.

        So I'm not sure what a list would really add there.

      • Please register or sign in to reply
Please register or sign in to reply
def assert_nested_dict(obj):
"""Tests the object is a nested dict and contains no more class
from swh.model.model."""
@@ -38,7 +43,7 @@ def assert_nested_dict(obj):
assert False, obj
@given(object_dicts())
@given(object_dicts(blacklist_types=()))
def test_dicts_generation(obj_type_and_obj):
(obj_type, object_) = obj_type_and_obj
assert_nested_dict(object_)
@@ -59,6 +64,11 @@ def test_dicts_generation(obj_type_and_obj):
assert branch is None or branch["target_type"] in target_types
@given(object_dicts(blacklist_types=("release", "content")))
def test_dicts_generation_blacklist(obj_type_and_obj):
assert obj_type_and_obj[0] not in ("release", "content")
Please register or sign in to reply
@given(objects())
def test_model_to_dicts(obj_type_and_obj):
(obj_type, object_) = obj_type_and_obj
Loading