Code Duplication    Length = 17-17 lines in 8 locations

tests/fuzz/fuzz_test_phonetic.py 4 locations

@@ 304-320 (lines=17) @@
301
                    self.fail('Exception "{}" thrown by {} for word: {}'
302
                              .format(inst, algo, fuzzed))
303
304
    def fuzz_test_fuzz_unicode(self):
305
        """Fuzz test phonetic algorithms against valid Unicode fuzz."""
306
        for _ in range(self.reps):
307
            fuzzed = ''.join(random_char() for _ in
308
                             range(0, random.randint(8, 16)))
309
310
            if EXTREME_TEST:
311
                algs = list(algorithms.keys())
312
            else:
313
                algs = random.choices(list(algorithms.keys()), k=5)
314
315
            for algo in algs:
316
                try:
317
                    algorithms[algo](fuzzed)
318
                except Exception as inst:
319
                    self.fail('Exception "{}" thrown by {} for word: {}'
320
                              .format(inst, algo, fuzzed))
321
322
323
if __name__ == '__main__':
@@ 286-302 (lines=17) @@
283
                    self.fail('Exception "{}" thrown by {} for word: {}'
284
                              .format(inst, algo, fuzzed))
285
286
    def fuzz_test_fuzz_bmpsmp_latin(self):
287
        """Fuzz test phonetic algorithms against Latin BMP+SMP fuzz."""
288
        for _ in range(self.reps):
289
            fuzzed = ''.join(random_char(0x1ffff, 'LATIN ') for _ in
290
                             range(0, random.randint(8, 16)))
291
292
            if EXTREME_TEST:
293
                algs = list(algorithms.keys())
294
            else:
295
                algs = random.choices(list(algorithms.keys()), k=5)
296
297
            for algo in algs:
298
                try:
299
                    algorithms[algo](fuzzed)
300
                except Exception as inst:
301
                    self.fail('Exception "{}" thrown by {} for word: {}'
302
                              .format(inst, algo, fuzzed))
303
304
    def fuzz_test_fuzz_unicode(self):
305
        """Fuzz test phonetic algorithms against valid Unicode fuzz."""
@@ 268-284 (lines=17) @@
265
                    self.fail('Exception "{}" thrown by {} for word: {}'
266
                              .format(inst, algo, fuzzed))
267
268
    def fuzz_test_fuzz_bmpsmp_letter(self):
269
        """Fuzz test phonetic algorithms against alphabetic BMP+SMP fuzz."""
270
        for _ in range(self.reps):
271
            fuzzed = ''.join(random_char(0x1ffff, ' LETTER ') for _ in
272
                             range(0, random.randint(8, 16)))
273
274
            if EXTREME_TEST:
275
                algs = list(algorithms.keys())
276
            else:
277
                algs = random.choices(list(algorithms.keys()), k=5)
278
279
            for algo in algs:
280
                try:
281
                    algorithms[algo](fuzzed)
282
                except Exception as inst:
283
                    self.fail('Exception "{}" thrown by {} for word: {}'
284
                              .format(inst, algo, fuzzed))
285
286
    def fuzz_test_fuzz_bmpsmp_latin(self):
287
        """Fuzz test phonetic algorithms against Latin BMP+SMP fuzz."""
@@ 250-266 (lines=17) @@
247
                    self.fail('Exception "{}" thrown by {} for word: {}'
248
                              .format(inst, algo, fuzzed))
249
250
    def fuzz_test_fuzz_bmp(self):
251
        """Fuzz test phonetic algorithms against BMP fuzz."""
252
        for _ in range(self.reps):
253
            fuzzed = ''.join(random_char(0xffff) for _ in
254
                             range(0, random.randint(8, 16)))
255
256
            if EXTREME_TEST:
257
                algs = list(algorithms.keys())
258
            else:
259
                algs = random.choices(list(algorithms.keys()), k=5)
260
261
            for algo in algs:
262
                try:
263
                    algorithms[algo](fuzzed)
264
                except Exception as inst:
265
                    self.fail('Exception "{}" thrown by {} for word: {}'
266
                              .format(inst, algo, fuzzed))
267
268
    def fuzz_test_fuzz_bmpsmp_letter(self):
269
        """Fuzz test phonetic algorithms against alphabetic BMP+SMP fuzz."""

tests/fuzz/fuzz_test_fingerprint.py 4 locations

@@ 205-221 (lines=17) @@
202
                    self.fail('Exception "{}" thrown by {} for word: {}'
203
                              .format(inst, algo, fuzzed))
204
205
    def fuzz_test_fuzz_unicode(self):
206
        """Fuzz test fingerprint algorithms against valid Unicode fuzz."""
207
        for _ in range(self.reps):
208
            fuzzed = ''.join(random_char() for _ in
209
                             range(0, random.randint(8, 16)))
210
211
            if EXTREME_TEST:
212
                algs = list(algorithms.keys())
213
            else:
214
                algs = random.choices(list(algorithms.keys()), k=5)
215
216
            for algo in algs:
217
                try:
218
                    algorithms[algo](fuzzed)
219
                except Exception as inst:
220
                    self.fail('Exception "{}" thrown by {} for word: {}'
221
                              .format(inst, algo, fuzzed))
222
223
224
if __name__ == '__main__':
@@ 187-203 (lines=17) @@
184
                    self.fail('Exception "{}" thrown by {} for word: {}'
185
                              .format(inst, algo, fuzzed))
186
187
    def fuzz_test_fuzz_bmpsmp_latin(self):
188
        """Fuzz test fingerprint algorithms against Latin BMP+SMP fuzz."""
189
        for _ in range(self.reps):
190
            fuzzed = ''.join(random_char(0x1ffff, 'LATIN ') for _ in
191
                             range(0, random.randint(8, 16)))
192
193
            if EXTREME_TEST:
194
                algs = list(algorithms.keys())
195
            else:
196
                algs = random.choices(list(algorithms.keys()), k=5)
197
198
            for algo in algs:
199
                try:
200
                    algorithms[algo](fuzzed)
201
                except Exception as inst:
202
                    self.fail('Exception "{}" thrown by {} for word: {}'
203
                              .format(inst, algo, fuzzed))
204
205
    def fuzz_test_fuzz_unicode(self):
206
        """Fuzz test fingerprint algorithms against valid Unicode fuzz."""
@@ 169-185 (lines=17) @@
166
                    self.fail('Exception "{}" thrown by {} for word: {}'
167
                              .format(inst, algo, fuzzed))
168
169
    def fuzz_test_fuzz_bmpsmp_letter(self):
170
        """Fuzz test fingerprint algorithms against alphabetic BMP+SMP fuzz."""
171
        for _ in range(self.reps):
172
            fuzzed = ''.join(random_char(0x1ffff, ' LETTER ') for _ in
173
                             range(0, random.randint(8, 16)))
174
175
            if EXTREME_TEST:
176
                algs = list(algorithms.keys())
177
            else:
178
                algs = random.choices(list(algorithms.keys()), k=5)
179
180
            for algo in algs:
181
                try:
182
                    algorithms[algo](fuzzed)
183
                except Exception as inst:
184
                    self.fail('Exception "{}" thrown by {} for word: {}'
185
                              .format(inst, algo, fuzzed))
186
187
    def fuzz_test_fuzz_bmpsmp_latin(self):
188
        """Fuzz test fingerprint algorithms against Latin BMP+SMP fuzz."""
@@ 151-167 (lines=17) @@
148
                    self.fail('Exception "{}" thrown by {} for word: {}'
149
                              .format(inst, algo, fuzzed))
150
151
    def fuzz_test_fuzz_bmp(self):
152
        """Fuzz test fingerprint algorithms against BMP fuzz."""
153
        for _ in range(self.reps):
154
            fuzzed = ''.join(random_char(0xffff) for _ in
155
                             range(0, random.randint(8, 16)))
156
157
            if EXTREME_TEST:
158
                algs = list(algorithms.keys())
159
            else:
160
                algs = random.choices(list(algorithms.keys()), k=5)
161
162
            for algo in algs:
163
                try:
164
                    algorithms[algo](fuzzed)
165
                except Exception as inst:
166
                    self.fail('Exception "{}" thrown by {} for word: {}'
167
                              .format(inst, algo, fuzzed))
168
169
    def fuzz_test_fuzz_bmpsmp_letter(self):
170
        """Fuzz test fingerprint algorithms against alphabetic BMP+SMP fuzz."""