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