diff --git a/swh/model/hypothesis_strategies.py b/swh/model/hypothesis_strategies.py index 61c55e11415026c0d7ca1f948fc1b93a778ed0cf..1b99957a737030dab80f3f01f204a925e6d2621f 100644 --- a/swh/model/hypothesis_strategies.py +++ b/swh/model/hypothesis_strategies.py @@ -20,6 +20,15 @@ from .model import ( from .identifiers import snapshot_identifier, identifier_to_bytes +pgsql_alphabet = characters( + blacklist_categories=('Cs', ), + blacklist_characters=['\u0000']) # postgresql does not like these + + +def pgsql_text(): + return text(alphabet=pgsql_alphabet) + + def sha1_git(): return binary(min_size=20, max_size=20) @@ -89,10 +98,7 @@ def releases(draw): def revision_metadata(): - alphabet = characters( - blacklist_categories=('Cs', ), - blacklist_characters=['\u0000']) # postgresql does not like these - return dictionaries(text(alphabet=alphabet), text(alphabet=alphabet)) + return dictionaries(pgsql_text(), pgsql_text()) def revisions(): @@ -125,7 +131,7 @@ def directories(): def contents(draw): (status, data, reason) = draw(one_of( tuples(just('visible'), binary(), none()), - tuples(just('absent'), none(), text()), + tuples(just('absent'), none(), pgsql_text()), tuples(just('hidden'), none(), none()), ))