Code Duplication    Length = 17-18 lines in 4 locations

test/test_loader.py 4 locations

@@ 260-277 (lines=18) @@
257
    assert regex in func.rule
258
259
260
def test_clean_callable_rule_nick(tmpconfig, func):
261
    """Assert ``$nick`` in a rule will match ``TestBot: `` or ``TestBot, ``."""
262
    setattr(func, 'rule', [r'$nickhello'])
263
    loader.clean_callable(func, tmpconfig)
264
265
    assert hasattr(func, 'rule')
266
    assert len(func.rule) == 1
267
268
    # Test the regex is compiled properly
269
    regex = func.rule[0]
270
    assert regex.match('TestBot: hello')
271
    assert regex.match('TestBot, hello')
272
    assert not regex.match('TestBot not hello')
273
274
    # idempotency
275
    loader.clean_callable(func, tmpconfig)
276
    assert len(func.rule) == 1
277
    assert regex in func.rule
278
279
280
def test_clean_callable_rule_nickname(tmpconfig, func):
@@ 280-296 (lines=17) @@
277
    assert regex in func.rule
278
279
280
def test_clean_callable_rule_nickname(tmpconfig, func):
281
    """Assert ``$nick`` in a rule will match ``TestBot``."""
282
    setattr(func, 'rule', [r'$nickname\s+hello'])
283
    loader.clean_callable(func, tmpconfig)
284
285
    assert hasattr(func, 'rule')
286
    assert len(func.rule) == 1
287
288
    # Test the regex is compiled properly
289
    regex = func.rule[0]
290
    assert regex.match('TestBot hello')
291
    assert not regex.match('TestBot not hello')
292
293
    # idempotency
294
    loader.clean_callable(func, tmpconfig)
295
    assert len(func.rule) == 1
296
    assert regex in func.rule
297
298
299
def test_clean_callable_nickname_command(tmpconfig, func):
@@ 241-257 (lines=17) @@
238
    assert regex in func.rule
239
240
241
def test_clean_callable_rule_string(tmpconfig, func):
242
    setattr(func, 'rule', r'abc')
243
    loader.clean_callable(func, tmpconfig)
244
245
    assert hasattr(func, 'rule')
246
    assert len(func.rule) == 1
247
248
    # Test the regex is compiled properly
249
    regex = func.rule[0]
250
    assert regex.match('abc')
251
    assert regex.match('abcd')
252
    assert not regex.match('efg')
253
254
    # idempotency
255
    loader.clean_callable(func, tmpconfig)
256
    assert len(func.rule) == 1
257
    assert regex in func.rule
258
259
260
def test_clean_callable_rule_nick(tmpconfig, func):
@@ 222-238 (lines=17) @@
219
    assert func.event == ['SOME']
220
221
222
def test_clean_callable_rule(tmpconfig, func):
223
    setattr(func, 'rule', [r'abc'])
224
    loader.clean_callable(func, tmpconfig)
225
226
    assert hasattr(func, 'rule')
227
    assert len(func.rule) == 1
228
229
    # Test the regex is compiled properly
230
    regex = func.rule[0]
231
    assert regex.match('abc')
232
    assert regex.match('abcd')
233
    assert not regex.match('efg')
234
235
    # idempotency
236
    loader.clean_callable(func, tmpconfig)
237
    assert len(func.rule) == 1
238
    assert regex in func.rule
239
240
241
def test_clean_callable_rule_string(tmpconfig, func):