From 73308f8f144d96a0d11181acd0d09723f2818007 Mon Sep 17 00:00:00 2001 From: James Sandford Date: Fri, 1 Mar 2024 10:27:09 +0000 Subject: [PATCH] Reduce size of video grains generated by hypothesis in tests --- mediagrains/hypothesis/strategies.py | 6 +++++- tests/fixtures.py | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mediagrains/hypothesis/strategies.py b/mediagrains/hypothesis/strategies.py index 35aaf46..55f7648 100644 --- a/mediagrains/hypothesis/strategies.py +++ b/mediagrains/hypothesis/strategies.py @@ -483,7 +483,11 @@ def grains_with_data(grain_type): """Strategy giving grains which have data payloads filled out using an appropriate strategy for the grain type. :param grain_type: The type of grains to generate""" - if grain_type in ("audio", "video", "coded_audio", "coded_video"): + if grain_type == "video": + return grains(grain_type, width=16, height=9).flatmap(lambda g: grains_from_template_with_data(g)) + elif grain_type == "coded_video": + return grains(grain_type, origin_width=16, origin_height=9).flatmap(lambda g: grains_from_template_with_data(g)) + elif grain_type in ("audio", "coded_audio"): return grains(grain_type).flatmap(lambda g: grains_from_template_with_data(g)) else: return grains(grain_type) diff --git a/tests/fixtures.py b/tests/fixtures.py index c325cc2..34441ab 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -72,7 +72,15 @@ def attribute_and_pairs_of_grains_of_type_differing_only_in_one_attribute(grain_ pairs_of_grains_of_type_differing_only_at_specified_attribute( grain_type, attr))) - if grain_type in ("audio", "video", "coded_audio", "coded_video"): + if grain_type == "video": + return grain_strat | grains(grain_type, width=16, height=9).flatmap( + lambda g: tuples( + just("data"), pairs_of(grains_from_template_with_data(g)))) + elif grain_type == "coded_video": + return grain_strat | grains(grain_type, origin_width=16, origin_height=9).flatmap( + lambda g: tuples( + just("data"), pairs_of(grains_from_template_with_data(g)))) + elif grain_type in ("audio", "coded_audio"): return grain_strat | grains(grain_type).flatmap( lambda g: tuples( just("data"), pairs_of(grains_from_template_with_data(g))))