Mercurial > piecrust2
view tests/test_plugins_base.py @ 1188:a7c43131d871
bake: Fix file write flushing problem with Python 3.8+
Writing the cache files fails in Python 3.8 because it looks like flushing
behaviour has changed. We need to explicitly flush. And even then, in very
rare occurrences, it looks like it can still run into racing conditions,
so we do a very hacky and ugly "retry" loop when fetching cached data :(
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 15 Jun 2021 22:36:23 -0700 |
parents | c1e062843464 |
children |
line wrap: on
line source
from .mockutil import mock_fs, mock_fs_scope def test_no_plugins(): fs = (mock_fs() .withConfig()) with mock_fs_scope(fs): app = fs.getApp() assert len(app.plugin_loader.plugins) == 1 assert app.plugin_loader.plugins[0].name == '__builtin__' testplug_code = """from piecrust.plugins.base import PieCrustPlugin class TestPlugPlugin(PieCrustPlugin): name = 'just a test plugin' __piecrust_plugin__ = TestPlugPlugin """ def test_loose_file(): fs = (mock_fs() .withConfig({'site': {'plugins': 'testplug'}}) .withFile('kitchen/plugins/testplug.py', testplug_code)) with mock_fs_scope(fs): app = fs.getApp() assert sorted([p.name for p in app.plugin_loader.plugins]) == \ sorted(['__builtin__', 'just a test plugin'])