mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-23 02:32:42 +00:00
Refine the ConfigParser generator
Limit the characters used in the section and item name strategies. ConfigParser doesn't allow all characters in all places.
This commit is contained in:
parent
021615bdff
commit
84647e25b7
@ -17,6 +17,9 @@ import os.path
|
||||
from configparser import (
|
||||
ConfigParser,
|
||||
)
|
||||
from functools import (
|
||||
partial,
|
||||
)
|
||||
|
||||
from hypothesis import (
|
||||
given,
|
||||
@ -24,6 +27,7 @@ from hypothesis import (
|
||||
from hypothesis.strategies import (
|
||||
dictionaries,
|
||||
text,
|
||||
characters,
|
||||
)
|
||||
|
||||
from twisted.python.filepath import (
|
||||
@ -37,6 +41,7 @@ from allmydata.util import configutil
|
||||
def arbitrary_config_dicts(
|
||||
min_sections=0,
|
||||
max_sections=3,
|
||||
max_section_name_size=8,
|
||||
max_items_per_section=3,
|
||||
max_item_length=8,
|
||||
max_value_length=8,
|
||||
@ -45,10 +50,23 @@ def arbitrary_config_dicts(
|
||||
Build ``dict[str, dict[str, str]]`` instances populated with arbitrary
|
||||
configurations.
|
||||
"""
|
||||
identifier_text = partial(
|
||||
text,
|
||||
# Don't allow most control characters or spaces
|
||||
alphabet=characters(
|
||||
blacklist_categories=('Cc', 'Cs', 'Zs'),
|
||||
),
|
||||
)
|
||||
return dictionaries(
|
||||
text(),
|
||||
identifier_text(
|
||||
min_size=1,
|
||||
max_size=max_section_name_size,
|
||||
),
|
||||
dictionaries(
|
||||
text(max_size=max_item_length),
|
||||
identifier_text(
|
||||
min_size=1,
|
||||
max_size=max_item_length,
|
||||
),
|
||||
text(max_size=max_value_length),
|
||||
max_size=max_items_per_section,
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user