Mercurial > piecrust2
comparison tests/test_plugins_base.py @ 1030:c2cd2ac289b2
tests: Add plugin tests.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Wed, 27 Dec 2017 13:25:53 -0800 |
| parents | |
| children | c1e062843464 |
comparison
equal
deleted
inserted
replaced
| 1029:41f4f8dfa42d | 1030:c2cd2ac289b2 |
|---|---|
| 1 from .mockutil import mock_fs, mock_fs_scope | |
| 2 | |
| 3 | |
| 4 def test_no_plugins(): | |
| 5 fs = (mock_fs() | |
| 6 .withConfig()) | |
| 7 with mock_fs_scope(fs): | |
| 8 app = fs.getApp() | |
| 9 assert len(app.plugin_loader.plugins) == 1 | |
| 10 assert app.plugin_loader.plugins[0].name == '__builtin__' | |
| 11 | |
| 12 | |
| 13 testplug_code = """from piecrust.plugins.base import PieCrustPlugin | |
| 14 | |
| 15 class TestPlugPlugin(PieCrustPlugin): | |
| 16 name = 'just a test plugin' | |
| 17 | |
| 18 __piecrust_plugin__ = TestPlugPlugin | |
| 19 """ | |
| 20 | |
| 21 def test_loose_file(): | |
| 22 fs = (mock_fs() | |
| 23 .withConfig({'site': {'plugins': 'testplug'}}) | |
| 24 .withFile('kitchen/plugins/testplug.py', testplug_code)) | |
| 25 with mock_fs_scope(fs): | |
| 26 app = fs.getApp() | |
| 27 assert sorted([p.name for p in app.plugin_loader.plugins]) == \ | |
| 28 sorted(['__builtin__', 'just a test plugin']) | |
| 29 assert False |
