@@ -1052,47 +1052,76 @@ def test_not_literal(self):
1052
1052
1053
1053
def test_possible_set_operations (self ):
1054
1054
s = bytes (range (128 )).decode ()
1055
- with self .assertWarns (FutureWarning ) :
1055
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference' ) as w :
1056
1056
p = re .compile (r'[0-9--1]' )
1057
+ self .assertEqual (w .filename , __file__ )
1057
1058
self .assertEqual (p .findall (s ), list ('-./0123456789' ))
1059
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference' ) as w :
1060
+ self .assertEqual (re .findall (r'[0-9--2]' , s ), list ('-./0123456789' ))
1061
+ self .assertEqual (w .filename , __file__ )
1062
+
1058
1063
self .assertEqual (re .findall (r'[--1]' , s ), list ('-./01' ))
1059
- with self .assertWarns (FutureWarning ):
1064
+
1065
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference' ) as w :
1060
1066
p = re .compile (r'[%--1]' )
1067
+ self .assertEqual (w .filename , __file__ )
1061
1068
self .assertEqual (p .findall (s ), list ("%&'()*+,-1" ))
1062
- with self .assertWarns (FutureWarning ):
1069
+
1070
+ with self .assertWarnsRegex (FutureWarning , 'Possible set difference ' ) as w :
1063
1071
p = re .compile (r'[%--]' )
1072
+ self .assertEqual (w .filename , __file__ )
1064
1073
self .assertEqual (p .findall (s ), list ("%&'()*+,-" ))
1065
1074
1066
- with self .assertWarns (FutureWarning ) :
1075
+ with self .assertWarnsRegex (FutureWarning , 'Possible set intersection ' ) as w :
1067
1076
p = re .compile (r'[0-9&&1]' )
1077
+ self .assertEqual (w .filename , __file__ )
1068
1078
self .assertEqual (p .findall (s ), list ('&0123456789' ))
1069
- with self .assertWarns (FutureWarning ):
1079
+ with self .assertWarnsRegex (FutureWarning , 'Possible set intersection ' ) as w :
1080
+ self .assertEqual (re .findall (r'[0-8&&1]' , s ), list ('&012345678' ))
1081
+ self .assertEqual (w .filename , __file__ )
1082
+
1083
+ with self .assertWarnsRegex (FutureWarning , 'Possible set intersection ' ) as w :
1070
1084
p = re .compile (r'[\d&&1]' )
1085
+ self .assertEqual (w .filename , __file__ )
1071
1086
self .assertEqual (p .findall (s ), list ('&0123456789' ))
1087
+
1072
1088
<
10000
code class="diff-text syntax-highlighted-line"> self .assertEqual (re .findall (r'[&&1]' , s ), list ('&1' ))
1073
1089
1074
- with self .assertWarns (FutureWarning ) :
1090
+ with self .assertWarnsRegex (FutureWarning , 'Possible set union ' ) as w :
1075
1091
p = re .compile (r'[0-9||a]' )
1092
+ self .assertEqual (w .filename , __file__ )
1076
1093
self .assertEqual (p .findall (s ), list ('0123456789a|' ))
1077
- with self .assertWarns (FutureWarning ):
1094
+
1095
+ with self .assertWarnsRegex (FutureWarning , 'Possible set union ' ) as w :
1078
1096
p = re .compile (r'[\d||a]' )
1097
+ self .assertEqual (w .filename , __file__ )
1079
1098
self .assertEqual (p .findall (s ), list ('0123456789a|' ))
1099
+
1080
1100
self .assertEqual (re .findall (r'[||1]' , s ), list ('1|' ))
1081
1101
1082
- with self .assertWarns (FutureWarning ) :
1102
+ with self .assertWarnsRegex (FutureWarning , 'Possible set symmetric difference ' ) as w :
1083
1103
p = re .compile (r'[0-9~~1]' )
1104
+ self .assertEqual (w .filename , __file__ )
1084
1105
self .assertEqual (p .findall (s ), list ('0123456789~' ))
1085
- with self .assertWarns (FutureWarning ):
1106
+
1107
+ with self .assertWarnsRegex (FutureWarning , 'Possible set symmetric difference ' ) as w :
1086
1108
p = re .compile (r'[\d~~1]' )
1109
+ self .assertEqual (w .filename , __file__ )
1087
1110
self .assertEqual (p .findall (s ), list ('0123456789~' ))
1111
+
1088
1112
self .assertEqual (re .findall (r'[~~1]' , s ), list ('1~' ))
1089
1113
1090
- with self .assertWarns (FutureWarning ) :
1114
+ with self .assertWarnsRegex (FutureWarning , 'Possible nested set ' ) as w :
1091
1115
p = re .compile (r'[[0-9]|]' )
1116
+ self .assertEqual (w .filename , __file__ )
1092
1117
self .assertEqual (p .findall (s ), list ('0123456789[]' ))
1118
+ with self .assertWarnsRegex (FutureWarning , 'Possible nested set ' ) as w :
1119
+ self .assertEqual (re .findall (r'[[0-8]|]' , s ), list ('012345678[]' ))
1120
+ self .assertEqual (w .filename , __file__ )
1093
1121
1094
- with self .assertWarns (FutureWarning ) :
1122
+ with self .assertWarnsRegex (FutureWarning , 'Possible nested set ' ) as w :
1095
1123
p = re .compile (r'[[:digit:]|]' )
1124
+ self .assertEqual (w .filename , __file__ )
1096
1125
self .assertEqual (p .findall (s ), list (':[]dgit' ))
1097
1126
1098
1127
def test_search_coverage (self ):
0 commit comments