Skip to content

Commit

Permalink
test: add regression test for PyFilePlugin folders w/submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Sep 12, 2024
1 parent 86efe41 commit a5fd1fe
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/plugins/test_plugins_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,44 @@ def test_get_label_entrypoint(plugin_tmpfile):
assert meta['label'] == 'plugin label'
assert meta['type'] == handlers.EntryPointPlugin.PLUGIN_TYPE
assert meta['source'] == 'test_plugin = file_mod'


MOCK_PARENT_MODULE = """
from sopel import plugin
from .sub import foo
@plugin.command('mock')
def mock(bot, trigger):
bot.say(foo)
"""

MOCK_SUB_MODULE = """
foo = 'bar baz'
"""


@pytest.fixture
def plugin_folder(tmp_path):
root = tmp_path / 'test_folder_plugin'
root.mkdir()

parent = root / '__init__.py'
with open(parent, 'w') as f:
f.write(MOCK_PARENT_MODULE)

submodule = root / 'sub.py'
with open(submodule, 'w') as f:
f.write(MOCK_SUB_MODULE)

return str(root)


def test_folder_plugin_imports(plugin_folder):
"""Ensure submodule imports work as expected in folder plugins.
Regression test for https://github.com/sopel-irc/sopel/issues/2619
"""
handler = handlers.PyFilePlugin(plugin_folder)
handler.load()

0 comments on commit a5fd1fe

Please sign in to comment.