Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/hid: run ruff format on the python part

We aim at syncing with the hid-tools repo on
gitlab.freedesktop.org/libevdev/hid-tools. One of the commits is this
mechanical formatting, so pull it over here so changes are not hidden by
those.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Link: https://patch.msgid.link/20250709-wip-fix-ci-v1-1-b7df4c271cf8@kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>

+325 -115
+2 -2
tools/testing/selftests/hid/tests/test_tablet.py
··· 1228 1228 pen.current_state = state 1229 1229 1230 1230 def call_input_event(self, report): 1231 - if report[0] == 0x0a: 1231 + if report[0] == 0x0A: 1232 1232 # ensures the original second Eraser usage is null 1233 - report[1] &= 0xdf 1233 + report[1] &= 0xDF 1234 1234 1235 1235 # ensures the original last bit is equal to bit 6 (In Range) 1236 1236 if report[1] & 0x40:
+323 -113
tools/testing/selftests/hid/tests/test_wacom_generic.py
··· 892 892 locations. The value of `t` may be incremented over time to move the 893 893 points along a linear path. 894 894 """ 895 - return [ self.make_contact(id, t) for id in range(0, n) ] 895 + return [self.make_contact(id, t) for id in range(0, n)] 896 896 897 897 def assert_contact(self, uhdev, evdev, contact_ids, t=0): 898 898 """ ··· 997 997 998 998 assert libevdev.InputEvent(libevdev.EV_KEY.BTN_TOUCH, 1) in events 999 999 1000 - self.assert_contacts(uhdev, evdev, 1001 - [ self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = None), 1002 - self.ContactIds(contact_id = 1, tracking_id = 0, slot_num = 0), 1003 - self.ContactIds(contact_id = 2, tracking_id = -1, slot_num = None), 1004 - self.ContactIds(contact_id = 3, tracking_id = 1, slot_num = 1), 1005 - self.ContactIds(contact_id = 4, tracking_id = -1, slot_num = None) ]) 1000 + self.assert_contacts( 1001 + uhdev, 1002 + evdev, 1003 + [ 1004 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=None), 1005 + self.ContactIds(contact_id=1, tracking_id=0, slot_num=0), 1006 + self.ContactIds(contact_id=2, tracking_id=-1, slot_num=None), 1007 + self.ContactIds(contact_id=3, tracking_id=1, slot_num=1), 1008 + self.ContactIds(contact_id=4, tracking_id=-1, slot_num=None), 1009 + ], 1010 + ) 1006 1011 1007 1012 def confidence_change_assert_playback(self, uhdev, evdev, timeline): 1008 1013 """ ··· 1031 1026 events = uhdev.next_sync_events() 1032 1027 self.debug_reports(r, uhdev, events) 1033 1028 1034 - ids = [ x[0] for x in state ] 1029 + ids = [x[0] for x in state] 1035 1030 self.assert_contacts(uhdev, evdev, ids, t) 1036 1031 1037 1032 t += 1 ··· 1049 1044 uhdev = self.uhdev 1050 1045 evdev = uhdev.get_evdev() 1051 1046 1052 - self.confidence_change_assert_playback(uhdev, evdev, [ 1053 - # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1054 - # Both fingers confidently in contact 1055 - [(self.ContactIds(contact_id = 0, tracking_id = 0, slot_num = 0), True, True), 1056 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1057 - 1058 - # t=1: Contact 0 == !Down + confident; Contact 1 == Down + confident 1059 - # First finger looses confidence and clears only the tipswitch flag 1060 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, True), 1061 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1062 - 1063 - # t=2: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1064 - # First finger has lost confidence and has both flags cleared 1065 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, False), 1066 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1067 - 1068 - # t=3: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1069 - # First finger has lost confidence and has both flags cleared 1070 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, False), 1071 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)] 1072 - ]) 1047 + self.confidence_change_assert_playback( 1048 + uhdev, 1049 + evdev, 1050 + [ 1051 + # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1052 + # Both fingers confidently in contact 1053 + [ 1054 + ( 1055 + self.ContactIds(contact_id=0, tracking_id=0, slot_num=0), 1056 + True, 1057 + True, 1058 + ), 1059 + ( 1060 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1061 + True, 1062 + True, 1063 + ), 1064 + ], 1065 + # t=1: Contact 0 == !Down + confident; Contact 1 == Down + confident 1066 + # First finger looses confidence and clears only the tipswitch flag 1067 + [ 1068 + ( 1069 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1070 + False, 1071 + True, 1072 + ), 1073 + ( 1074 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1075 + True, 1076 + True, 1077 + ), 1078 + ], 1079 + # t=2: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1080 + # First finger has lost confidence and has both flags cleared 1081 + [ 1082 + ( 1083 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1084 + False, 1085 + False, 1086 + ), 1087 + ( 1088 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1089 + True, 1090 + True, 1091 + ), 1092 + ], 1093 + # t=3: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1094 + # First finger has lost confidence and has both flags cleared 1095 + [ 1096 + ( 1097 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1098 + False, 1099 + False, 1100 + ), 1101 + ( 1102 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1103 + True, 1104 + True, 1105 + ), 1106 + ], 1107 + ], 1108 + ) 1073 1109 1074 1110 def test_confidence_loss_b(self): 1075 1111 """ ··· 1125 1079 uhdev = self.uhdev 1126 1080 evdev = uhdev.get_evdev() 1127 1081 1128 - self.confidence_change_assert_playback(uhdev, evdev, [ 1129 - # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1130 - # Both fingers confidently in contact 1131 - [(self.ContactIds(contact_id = 0, tracking_id = 0, slot_num = 0), True, True), 1132 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1133 - 1134 - # t=1: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1135 - # First finger looses confidence and has both flags cleared simultaneously 1136 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, False), 1137 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1138 - 1139 - # t=2: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1140 - # First finger has lost confidence and has both flags cleared 1141 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, False), 1142 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1143 - 1144 - # t=3: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1145 - # First finger has lost confidence and has both flags cleared 1146 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, False), 1147 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)] 1148 - ]) 1082 + self.confidence_change_assert_playback( 1083 + uhdev, 1084 + evdev, 1085 + [ 1086 + # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1087 + # Both fingers confidently in contact 1088 + [ 1089 + ( 1090 + self.ContactIds(contact_id=0, tracking_id=0, slot_num=0), 1091 + True, 1092 + True, 1093 + ), 1094 + ( 1095 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1096 + True, 1097 + True, 1098 + ), 1099 + ], 1100 + # t=1: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1101 + # First finger looses confidence and has both flags cleared simultaneously 1102 + [ 1103 + ( 1104 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1105 + False, 1106 + False, 1107 + ), 1108 + ( 1109 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1110 + True, 1111 + True, 1112 + ), 1113 + ], 1114 + # t=2: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1115 + # First finger has lost confidence and has both flags cleared 1116 + [ 1117 + ( 1118 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1119 + False, 1120 + False, 1121 + ), 1122 + ( 1123 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1124 + True, 1125 + True, 1126 + ), 1127 + ], 1128 + # t=3: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1129 + # First finger has lost confidence and has both flags cleared 1130 + [ 1131 + ( 1132 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1133 + False, 1134 + False, 1135 + ), 1136 + ( 1137 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1138 + True, 1139 + True, 1140 + ), 1141 + ], 1142 + ], 1143 + ) 1149 1144 1150 1145 def test_confidence_loss_c(self): 1151 1146 """ ··· 1200 1113 uhdev = self.uhdev 1201 1114 evdev = uhdev.get_evdev() 1202 1115 1203 - self.confidence_change_assert_playback(uhdev, evdev, [ 1204 - # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1205 - # Both fingers confidently in contact 1206 - [(self.ContactIds(contact_id = 0, tracking_id = 0, slot_num = 0), True, True), 1207 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1208 - 1209 - # t=1: Contact 0 == Down + !confident; Contact 1 == Down + confident 1210 - # First finger looses confidence and clears only the confidence flag 1211 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), True, False), 1212 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1213 - 1214 - # t=2: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1215 - # First finger has lost confidence and has both flags cleared 1216 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, False), 1217 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1218 - 1219 - # t=3: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1220 - # First finger has lost confidence and has both flags cleared 1221 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, False), 1222 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)] 1223 - ]) 1116 + self.confidence_change_assert_playback( 1117 + uhdev, 1118 + evdev, 1119 + [ 1120 + # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1121 + # Both fingers confidently in contact 1122 + [ 1123 + ( 1124 + self.ContactIds(contact_id=0, tracking_id=0, slot_num=0), 1125 + True, 1126 + True, 1127 + ), 1128 + ( 1129 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1130 + True, 1131 + True, 1132 + ), 1133 + ], 1134 + # t=1: Contact 0 == Down + !confident; Contact 1 == Down + confident 1135 + # First finger looses confidence and clears only the confidence flag 1136 + [ 1137 + ( 1138 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1139 + True, 1140 + False, 1141 + ), 1142 + ( 1143 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1144 + True, 1145 + True, 1146 + ), 1147 + ], 1148 + # t=2: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1149 + # First finger has lost confidence and has both flags cleared 1150 + [ 1151 + ( 1152 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1153 + False, 1154 + False, 1155 + ), 1156 + ( 1157 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1158 + True, 1159 + True, 1160 + ), 1161 + ], 1162 + # t=3: Contact 0 == !Down + !confident; Contact 1 == Down + confident 1163 + # First finger has lost confidence and has both flags cleared 1164 + [ 1165 + ( 1166 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1167 + False, 1168 + False, 1169 + ), 1170 + ( 1171 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1172 + True, 1173 + True, 1174 + ), 1175 + ], 1176 + ], 1177 + ) 1224 1178 1225 1179 def test_confidence_gain_a(self): 1226 1180 """ ··· 1272 1144 uhdev = self.uhdev 1273 1145 evdev = uhdev.get_evdev() 1274 1146 1275 - self.confidence_change_assert_playback(uhdev, evdev, [ 1276 - # t=0: Contact 0 == Down + !confident; Contact 1 == Down + confident 1277 - # Only second finger is confidently in contact 1278 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = None), True, False), 1279 - (self.ContactIds(contact_id = 1, tracking_id = 0, slot_num = 0), True, True)], 1280 - 1281 - # t=1: Contact 0 == Down + !confident; Contact 1 == Down + confident 1282 - # First finger gains confidence 1283 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = None), True, False), 1284 - (self.ContactIds(contact_id = 1, tracking_id = 0, slot_num = 0), True, True)], 1285 - 1286 - # t=2: Contact 0 == Down + confident; Contact 1 == Down + confident 1287 - # First finger remains confident 1288 - [(self.ContactIds(contact_id = 0, tracking_id = 1, slot_num = 1), True, True), 1289 - (self.ContactIds(contact_id = 1, tracking_id = 0, slot_num = 0), True, True)], 1290 - 1291 - # t=3: Contact 0 == Down + confident; Contact 1 == Down + confident 1292 - # First finger remains confident 1293 - [(self.ContactIds(contact_id = 0, tracking_id = 1, slot_num = 1), True, True), 1294 - (self.ContactIds(contact_id = 1, tracking_id = 0, slot_num = 0), True, True)] 1295 - ]) 1147 + self.confidence_change_assert_playback( 1148 + uhdev, 1149 + evdev, 1150 + [ 1151 + # t=0: Contact 0 == Down + !confident; Contact 1 == Down + confident 1152 + # Only second finger is confidently in contact 1153 + [ 1154 + ( 1155 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=None), 1156 + True, 1157 + False, 1158 + ), 1159 + ( 1160 + self.ContactIds(contact_id=1, tracking_id=0, slot_num=0), 1161 + True, 1162 + True, 1163 + ), 1164 + ], 1165 + # t=1: Contact 0 == Down + !confident; Contact 1 == Down + confident 1166 + # First finger gains confidence 1167 + [ 1168 + ( 1169 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=None), 1170 + True, 1171 + False, 1172 + ), 1173 + ( 1174 + self.ContactIds(contact_id=1, tracking_id=0, slot_num=0), 1175 + True, 1176 + True, 1177 + ), 1178 + ], 1179 + # t=2: Contact 0 == Down + confident; Contact 1 == Down + confident 1180 + # First finger remains confident 1181 + [ 1182 + ( 1183 + self.ContactIds(contact_id=0, tracking_id=1, slot_num=1), 1184 + True, 1185 + True, 1186 + ), 1187 + ( 1188 + self.ContactIds(contact_id=1, tracking_id=0, slot_num=0), 1189 + True, 1190 + True, 1191 + ), 1192 + ], 1193 + # t=3: Contact 0 == Down + confident; Contact 1 == Down + confident 1194 + # First finger remains confident 1195 + [ 1196 + ( 1197 + self.ContactIds(contact_id=0, tracking_id=1, slot_num=1), 1198 + True, 1199 + True, 1200 + ), 1201 + ( 1202 + self.ContactIds(contact_id=1, tracking_id=0, slot_num=0), 1203 + True, 1204 + True, 1205 + ), 1206 + ], 1207 + ], 1208 + ) 1296 1209 1297 1210 def test_confidence_gain_b(self): 1298 1211 """ ··· 1344 1175 uhdev = self.uhdev 1345 1176 evdev = uhdev.get_evdev() 1346 1177 1347 - self.confidence_change_assert_playback(uhdev, evdev, [ 1348 - # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1349 - # First and second finger confidently in contact 1350 - [(self.ContactIds(contact_id = 0, tracking_id = 0, slot_num = 0), True, True), 1351 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1352 - 1353 - # t=1: Contact 0 == Down + !confident; Contact 1 == Down + confident 1354 - # Firtst finger looses confidence 1355 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), True, False), 1356 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1357 - 1358 - # t=2: Contact 0 == Down + confident; Contact 1 == Down + confident 1359 - # First finger gains confidence 1360 - [(self.ContactIds(contact_id = 0, tracking_id = 2, slot_num = 0), True, True), 1361 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)], 1362 - 1363 - # t=3: Contact 0 == !Down + confident; Contact 1 == Down + confident 1364 - # First finger goes up 1365 - [(self.ContactIds(contact_id = 0, tracking_id = -1, slot_num = 0), False, True), 1366 - (self.ContactIds(contact_id = 1, tracking_id = 1, slot_num = 1), True, True)] 1367 - ]) 1178 + self.confidence_change_assert_playback( 1179 + uhdev, 1180 + evdev, 1181 + [ 1182 + # t=0: Contact 0 == Down + confident; Contact 1 == Down + confident 1183 + # First and second finger confidently in contact 1184 + [ 1185 + ( 1186 + self.ContactIds(contact_id=0, tracking_id=0, slot_num=0), 1187 + True, 1188 + True, 1189 + ), 1190 + ( 1191 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1192 + True, 1193 + True, 1194 + ), 1195 + ], 1196 + # t=1: Contact 0 == Down + !confident; Contact 1 == Down + confident 1197 + # Firtst finger looses confidence 1198 + [ 1199 + ( 1200 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1201 + True, 1202 + False, 1203 + ), 1204 + ( 1205 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1206 + True, 1207 + True, 1208 + ), 1209 + ], 1210 + # t=2: Contact 0 == Down + confident; Contact 1 == Down + confident 1211 + # First finger gains confidence 1212 + [ 1213 + ( 1214 + self.ContactIds(contact_id=0, tracking_id=2, slot_num=0), 1215 + True, 1216 + True, 1217 + ), 1218 + ( 1219 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1220 + True, 1221 + True, 1222 + ), 1223 + ], 1224 + # t=3: Contact 0 == !Down + confident; Contact 1 == Down + confident 1225 + # First finger goes up 1226 + [ 1227 + ( 1228 + self.ContactIds(contact_id=0, tracking_id=-1, slot_num=0), 1229 + False, 1230 + True, 1231 + ), 1232 + ( 1233 + self.ContactIds(contact_id=1, tracking_id=1, slot_num=1), 1234 + True, 1235 + True, 1236 + ), 1237 + ], 1238 + ], 1239 + )