Browse Source

Added a failing test

main
Lakshmi Vyasarajan 13 years ago
parent
commit
899228add7
2 changed files with 12 additions and 10 deletions
  1. +4
    -5
      hyde/plugin.py
  2. +8
    -5
      hyde/tests/test_plugin.py

+ 4
- 5
hyde/plugin.py View File

@@ -40,11 +40,10 @@ class PluginProxy(object):
# "\tCalling plugin [%s]",
# plugin.__class__.__name__)
function = getattr(plugin, method_name)
newres = function(*args)
if newres:
res = newres
res = function(*args)
last = None
if res:
targs = list(args)
last = None
if len(targs):
last = targs.pop()
targs.append(res if res else last)
@@ -387,4 +386,4 @@ class TextyPlugin(Plugin):
text_close = re.compile(self.close_pattern, re.UNICODE|re.MULTILINE)
text = text_close.sub(
partial(self.text_to_tag, start=False), text)
return text
return text

+ 8
- 5
hyde/tests/test_plugin.py View File

@@ -19,15 +19,17 @@ TEST_SITE = File(__file__).parent.child_folder('_test')

class PluginLoaderStub(Plugin):
pass
class NoReturnPlugin(Plugin):
def begin_text_resource(self, resource, text):
print "NoReturnPlugin"
return None

class ConstantReturnPlugin(Plugin):

def begin_text_resource(self, resource, text):
print "ConstantReturnPlugin"
return "Jam"


@@ -318,11 +320,12 @@ class TestPlugins(object):

def test_plugin_chaining(self):
self.site.config.plugins = [
'hyde.tests.test_plugin.NoReturnPlugin',
'hyde.tests.test_plugin.ConstantReturnPlugin']
'hyde.tests.test_plugin.ConstantReturnPlugin',
'hyde.tests.test_plugin.NoReturnPlugin'
]
path = self.site.content.source_folder.child('about.html')
gen = Generator(self.site)
gen.generate_resource_at_path(path, incremental=True)
gen.generate_resource_at_path(path)
about = File(Folder(
self.site.config.deploy_root_path).child('about.html'))
assert about.read_all() == "Jam"

Loading…
Cancel
Save