File tree 2 files changed +10
-3
lines changed
src/hypothesis/strategies/_internal
2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change
1
+ RELEASE_TYPE: patch
2
+
3
+ This patch teaches :func: `~hypothesis.strategies.text ` to rewrite a few more
4
+ filter predicates (:issue: `3134 `). You're unlikely to notice any change.
Original file line number Diff line number Diff line change @@ -121,11 +121,14 @@ def __repr__(self):
121
121
# See https://docs.python.org/3/library/stdtypes.html#string-methods
122
122
# These methods always return Truthy values for any nonempty string.
123
123
_nonempty_filters = ListStrategy ._nonempty_filters + (
124
+ str ,
124
125
str .capitalize ,
125
126
str .casefold ,
127
+ str .encode ,
126
128
str .expandtabs ,
127
129
str .join ,
128
130
str .lower ,
131
+ str .rsplit ,
129
132
str .split ,
130
133
str .splitlines ,
131
134
str .swapcase ,
@@ -144,6 +147,9 @@ def __repr__(self):
144
147
str .isnumeric ,
145
148
str .isspace ,
146
149
str .istitle ,
150
+ str .lstrip ,
151
+ str .rstrip ,
152
+ str .strip ,
147
153
)
148
154
149
155
def filter (self , condition ):
@@ -156,9 +162,6 @@ def filter(self, condition):
156
162
# We use ListStrategy filter logic for the conditions that *only* imply
157
163
# the string is nonempty. Here, we increment the min_size but still apply
158
164
# the filter for conditions that imply nonempty *and specific contents*.
159
- #
160
- # TODO: we may eventually rewrite the elements_strategy for some of these,
161
- # avoiding rejection sampling and making them much more efficient.
162
165
if condition in self ._nonempty_and_content_filters :
163
166
assert self .max_size >= 1 , "Always-empty is special cased in st.text()"
164
167
self = copy .copy (self )
You can’t perform that action at this time.
0 commit comments