@@ -1116,47 +1116,76 @@ def test_not_literal(self):
1116
1116
1117
1117
def test_possible_set_operations (self ):
1118
1118
s = bytes (range (128 )).decode ()
1119
- with self .assertWarns (FutureWarning ) :
1119
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference' ) as w :
1120
1120
p = re .compile (r'[0-9--1]' )
1121
+ self .assertEqual (w .filename , __file__ )
1121
1122
self .assertEqual (p .findall (s ), list ('-./0123456789' ))
1123
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference' ) as w :
1124
+ self .assertEqual (re .findall (r'[0-9--2]' , s ), list ('-./0123456789' ))
1125
+ self .assertEqual (w .filename , __file__ )
1126
+
1122
1127
self .assertEqual (re .findall (r'[--1]' , s ), list ('-./01' ))
1123
- with self .assertWarns (FutureWarning ):
1128
+
1129
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference' ) as w :
1124
1130
p = re .compile (r'[%--1]' )
1131
+ self .assertEqual (w .filename , __file__ )
1125
1132
self .assertEqual (p .findall (s ), list ("%&'()*+,-1" ))
1126
- with self .assertWarns (FutureWarning ):
1133
+
1134
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference ' ) as w :
1127
1135
p = re .compile (r'[%--]' )
1136
+ self .assertEqual (w .filename , __file__ )
1128
1137
self .assertEqual (p .findall (s ), list ("%&'()*+,-" ))
1129
1138
1130
- with self .assertWarns (FutureWarning ) :
1139
+ with self .assertWarnsRegex (FutureWarning , 'Possible set intersection ' ) as w :
1131
1140
p = re .compile (r'[0-9&&1]' )
1141
+ self .assertEqual (w .filename , __file__ )
1132
1142
self .assertEqual (p .findall (s ), list ('&0123456789' ))
1133
- with self .assertWarns (FutureWarning ):
1143
+ with self .assertWarnsRegex (FutureWarning , 'Possible set intersection ' ) as w :
1144
+ self .assertEqual (re .findall (r'[0-8&&1]' , s ), list ('&012345678' ))
1145
+ self .assertEqual (w .filename , __file__ )
1146
+
1147
+ with self .assertWarnsRegex (FutureWarning , 'Possible set intersection ' ) as w :
1134
1148
p = re .compile (r'[\d&&1]' )
1149
+ self .assertEqual (w .filename , __file__ )
1135
1150
self .assertEqual (p .findall (s ), list ('&0123456789' ))
1151
+
1136
1152
self .assertEqual (re .findall (r'[&&1]' , s ), list ('&1' ))
1137
1153
1138
- with self .assertWarns (FutureWarning ) :
1154
+ with self .assertWarnsRegex (FutureWarning , 'Possible set union ' ) as w :
1139
1155
p = re .compile (r'[0-9||a]' )
1156
+ self .assertEqual (w .filename , __file__ )
1140
1157
self .assertEqual (p .findall (s ), list ('0123456789a|' ))
1141
- with self .assertWarns (FutureWarning ):
1158
+
1159
+ with self .assertWarnsRegex (FutureWarning , 'Possible set union ' ) as w :
1142
1160
p = re .compile (r'[\d||a]' )
1161
+ self .assertEqual (w .filename , __file__ )
1143
1162
self .assertEqual (p .findall (s ), list ('0123456789a|' ))
1163
+
1144
1164
self .assertEqual (re .findall (r'[||1]' , s ), list ('1|' ))
1145
1165
1146
- with self .assertWarns (FutureWarning ) :
1166
+ with self .assertWarnsRegex (FutureWarning , 'Possible set symmetric difference ' ) as w :
1147
1167
p = re .compile (r'[0-9~~1]' )
1168
+ self .assertEqual (w .filename , __file__ )
1148
1169
self .assertEqual (p .findall (s ), list ('0123456789~' ))
1149
- with self .assertWarns (FutureWarning ):
1170
+
1171
+ with self .assertWarnsRegex (FutureWarning , 'Possible set symmetric difference ' ) as w :
1150
1172
p = re .compile (r'[\d~~1]' )
1173
+ self .assertEqual (w .filename , __file__ )
1151
1174
self .assertEqual (p .findall (s ), list ('0123456789~' ))
1175
+
1152
1176
self .assertEqual (re .findall (r'[~~1]' , s ), list ('1~' ))
1153
1177
1154
- with self .assertWarns (FutureWarning ) :
1178
+ with self .assertWarnsRegex (FutureWarning , 'Possible nested set ' ) as w :
1155
1179
p = re .compile (r'[[0-9]|]' )
1180
+ self .assertEqual (w .filename , __file__ )
1156
1181
self .assertEqual (p .findall (s ), list ('0123456789[]' ))
1182
+ with self .assertWarnsRegex (FutureWarning , 'Possible nested set ' ) as w :
1183
+ self .assertEqual (re .findall (r'[[0-8]|]' , s ), list ('012345678[]' ))
1184
+ self .assertEqual (w .filename , __file__ )
1157
1185
1158
- with self .assertWarns (FutureWarning ) :
1186
+ with self .assertWarnsRegex (FutureWarning , 'Possible nested set ' ) as w :
1159
1187
p = re .compile (r'[[:digit:]|]' )
1188
+ self .assertEqual (w .filename , __file__ )
1160
1189
self .assertEqual (p .findall (s ), list (':[]dgit' ))
1161
1190
1162
1191
def test_search_coverage (self ):
0 commit comments