From 0856072b29c4f2d6714aa947750c546c9a017685 Mon Sep 17 00:00:00 2001 From: Florian Strzelecki Date: Wed, 23 Jan 2019 23:22:15 +0100 Subject: [PATCH] test: sopel.loader.clean_callable function with intents --- test/test_loader.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_loader.py b/test/test_loader.py index 5e0d89a613..1ab12cf528 100644 --- a/test/test_loader.py +++ b/test/test_loader.py @@ -413,6 +413,22 @@ def test_clean_callable_example_nickname(tmpconfig, func): assert docs[1] == 'Sopel: hello' +def test_clean_callable_intents(tmpconfig, func): + setattr(func, 'intents', [r'abc']) + loader.clean_callable(func, tmpconfig) + + assert hasattr(func, 'intents') + assert len(func.intents) == 1 + + # Test the regex is compiled properly + regex = func.intents[0] + assert regex.match('abc') + assert regex.match('abcd') + assert regex.match('ABC') + assert regex.match('AbCdE') + assert not regex.match('efg') + + def test_load_module_pymod(tmpdir): root = tmpdir.mkdir('loader_mods') mod_file = root.join('file_mod.py')