Skip to content

Commit c5e1106

Browse files
committed
blacklisting quote characters in hypothesis strings until moto bug is fixed getmoto/moto#1505
1 parent d2c25dc commit c5e1106

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

test/functional/hypothesis_strategies.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
from boto3.dynamodb.types import Binary, DYNAMODB_CONTEXT
1919
import hypothesis
20-
from hypothesis.strategies import binary, booleans, dictionaries, deferred, fractions, just, lists, none, sets, text
20+
from hypothesis.strategies import (
21+
binary, booleans, characters, dictionaries, deferred, fractions, just, lists, none, sets, text
22+
)
2123

2224
SLOW_SETTINGS = hypothesis.settings(
2325
suppress_health_check=(
@@ -49,7 +51,14 @@
4951
)
5052

5153

52-
ddb_string = text(min_size=1, max_size=MAX_ITEM_BYTES)
54+
ddb_string = text(
55+
min_size=1,
56+
max_size=MAX_ITEM_BYTES,
57+
alphabet=characters(
58+
blacklist_categories=('Cs',),
59+
blacklist_characters=('"', "'") # Quotes break moto :(
60+
)
61+
)
5362
ddb_string_set = sets(ddb_string, min_size=1)
5463

5564

@@ -89,9 +98,17 @@ def _ddb_fraction_to_decimal(val):
8998
| ddb_number_set
9099
| ddb_binary_set
91100
)
101+
ddb_attribute_names = text(
102+
min_size=1,
103+
max_size=255,
104+
alphabet=characters(
105+
blacklist_categories=('Cs',),
106+
blacklist_characters=('"', "'") # Quotes break moto :(
107+
)
108+
)
92109
# TODO: List and Map types have a max depth of 32
93110
ddb_map_type = deferred(lambda: dictionaries(
94-
keys=text(),
111+
keys=ddb_attribute_names,
95112
values=(
96113
ddb_scalar_types
97114
| ddb_set_types
@@ -112,7 +129,7 @@ def _ddb_fraction_to_decimal(val):
112129
ddb_attribute_values = ddb_scalar_types | ddb_set_types | ddb_list_type
113130

114131
ddb_items = dictionaries(
115-
keys=text(min_size=1, max_size=255),
132+
keys=ddb_attribute_names,
116133
values=ddb_scalar_types | ddb_set_types | ddb_list_type
117134
)
118135

0 commit comments

Comments
 (0)