From 5d8c9577a723a7e80773b13cd7b0de376b7dc9a2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 22 Nov 2017 11:53:49 +0100 Subject: [PATCH] Improve hypothesis example generation for configtypes.Dict --- tests/unit/config/test_configtypes.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index 36988a0a7..1a4360479 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -1616,19 +1616,19 @@ class TestDict: else: d.to_py(val) - @hypothesis.given(val=strategies.dictionaries(strategies.text(min_size=1), - strategies.booleans())) + @hypothesis.given(val=strategies.dictionaries( + strategies.text(min_size=1, alphabet=strategies.characters( + # No control characters, surrogates, or codepoints encoded as + # surrogate + blacklist_categories=['Cc', 'Cs'], max_codepoint=0xFFFF)), + strategies.booleans())) def test_hypothesis(self, klass, val): d = klass(keytype=configtypes.String(), valtype=configtypes.Bool(), none_ok=True) - try: - converted = d.to_py(val) - expected = converted if converted else None - assert d.from_str(d.to_str(converted)) == expected - except configexc.ValidationError: - # Invalid unicode in the string, etc... - hypothesis.assume(False) + converted = d.to_py(val) + expected = converted if converted else None + assert d.from_str(d.to_str(converted)) == expected @hypothesis.given(val=strategies.dictionaries(strategies.text(min_size=1), strategies.booleans()))