diff --git a/setup.cfg b/setup.cfg index 0a1d775e..d3796a38 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,6 +19,7 @@ markers = unit: mark test as a unit test (does not require network access) functional: mark test as a functional test (does not require network access) integ: mark a test as an integration test (requires network access) + hypothesis: mark a test as using hypothesis (will run many times for each pytest call) slow: mark a test as being known to take a long time to complete (order 5s < t < 60s) veryslow: mark a test as being known to take a very long time to complete (order t > 60s) nope: mark a test as being so slow that it should only be very infrequently (order t > 30m) diff --git a/test/functional/hypothesis_strategies.py b/test/functional/hypothesis_strategies.py index e4f9038d..aa0fb8e5 100644 --- a/test/functional/hypothesis_strategies.py +++ b/test/functional/hypothesis_strategies.py @@ -17,7 +17,9 @@ from boto3.dynamodb.types import Binary, DYNAMODB_CONTEXT import hypothesis -from hypothesis.strategies import binary, booleans, dictionaries, deferred, fractions, just, lists, none, sets, text +from hypothesis.strategies import ( + binary, booleans, characters, dictionaries, deferred, fractions, just, lists, none, sets, text +) SLOW_SETTINGS = hypothesis.settings( suppress_health_check=( @@ -49,7 +51,10 @@ ) -ddb_string = text(min_size=1, max_size=MAX_ITEM_BYTES) +ddb_string = text( + min_size=1, + max_size=MAX_ITEM_BYTES +) ddb_string_set = sets(ddb_string, min_size=1) @@ -89,9 +94,13 @@ def _ddb_fraction_to_decimal(val): | ddb_number_set | ddb_binary_set ) +ddb_attribute_names = text( + min_size=1, + max_size=255 +) # TODO: List and Map types have a max depth of 32 ddb_map_type = deferred(lambda: dictionaries( - keys=text(), + keys=ddb_attribute_names, values=( ddb_scalar_types | ddb_set_types @@ -112,7 +121,7 @@ def _ddb_fraction_to_decimal(val): ddb_attribute_values = ddb_scalar_types | ddb_set_types | ddb_list_type ddb_items = dictionaries( - keys=text(min_size=1, max_size=255), + keys=ddb_attribute_names, values=ddb_scalar_types | ddb_set_types | ddb_list_type ) diff --git a/test/functional/test_f_formatting_attribute_serialization.py b/test/functional/test_f_formatting_attribute_serialization.py index d128758b..c12e8f1c 100644 --- a/test/functional/test_f_formatting_attribute_serialization.py +++ b/test/functional/test_f_formatting_attribute_serialization.py @@ -73,6 +73,7 @@ def _serialize_deserialize_cycle(attribute): @pytest.mark.slow +@pytest.mark.hypothesis @SLOW_SETTINGS @hypothesis.given(ddb_attribute_values) def test_serialize_deserialize_attribute_slow(attribute): @@ -80,6 +81,7 @@ def test_serialize_deserialize_attribute_slow(attribute): @pytest.mark.veryslow +@pytest.mark.hypothesis @VERY_SLOW_SETTINGS @hypothesis.given(ddb_attribute_values) def test_serialize_deserialize_attribute_vslow(attribute): @@ -93,6 +95,7 @@ def _ddb_dict_ddb_transform_cycle(item): @pytest.mark.slow +@pytest.mark.hypothesis @SLOW_SETTINGS @hypothesis.given(ddb_items) def test_dict_to_ddb_and_back_slow(item): @@ -100,6 +103,7 @@ def test_dict_to_ddb_and_back_slow(item): @pytest.mark.veryslow +@pytest.mark.hypothesis @VERY_SLOW_SETTINGS @hypothesis.given(ddb_items) def test_dict_to_ddb_and_back_vslow(item): diff --git a/test/functional/test_f_formatting_material_description_serialization.py b/test/functional/test_f_formatting_material_description_serialization.py index 37d66b28..786aac9f 100644 --- a/test/functional/test_f_formatting_material_description_serialization.py +++ b/test/functional/test_f_formatting_material_description_serialization.py @@ -77,6 +77,7 @@ def _serialize_deserialize_cycle(material_description): @pytest.mark.slow +@pytest.mark.hypothesis @SLOW_SETTINGS @hypothesis.given(material_descriptions) def test_serialize_deserialize_material_description_slow(material_description): @@ -84,6 +85,7 @@ def test_serialize_deserialize_material_description_slow(material_description): @pytest.mark.veryslow +@pytest.mark.hypothesis @VERY_SLOW_SETTINGS @hypothesis.given(material_descriptions) def test_serialize_deserialize_material_description_vslow(material_description): diff --git a/test/requirements.txt b/test/requirements.txt new file mode 100644 index 00000000..34d6a3b4 --- /dev/null +++ b/test/requirements.txt @@ -0,0 +1,7 @@ +hypothesis +mock +git+https://github.com/spulec/moto.git +pytest>=3.3.1 +pytest-cov +pytest-mock +pytest-xdist \ No newline at end of file diff --git a/tox.ini b/tox.ini index a2daa457..40517637 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{27,34,35,36}-{local,integ}-full, + py{27,34,35,36}-{local,integ}-fast, bandit, doc8, readme, flake8, pylint, flake8-tests, pylint-tests, @@ -23,14 +23,7 @@ passenv = # Pass through AWS profile name (useful for local testing) AWS_PROFILE sitepackages = False -deps = - hypothesis - mock - moto - pytest>=3.3.1 - pytest-cov - pytest-mock - pytest-xdist +deps = -rtest/requirements.txt commands = local-fast: {[testenv:base-command]commands} -m "local and not slow and not veryslow and not nope" integ-fast: {[testenv:base-command]commands} -m "integ and not slow and not veryslow and not nope"