From 3df7a9f1b46387e0be413dbfa3427e92b5ff28ba Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 7 May 2011 09:39:30 +0200 Subject: [PATCH 1/3] Add additional standard path for tools. Node.js tools may be installed in /usr/bin if installed by system package tools or in ~/bin if installed by a default installation of npm. --- hyde/tests/ext/test_less.py | 3 ++- hyde/tests/ext/test_optipng.py | 2 +- hyde/tests/ext/test_stylus.py | 8 +++++--- hyde/tests/ext/test_uglify.py | 9 ++++++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hyde/tests/ext/test_less.py b/hyde/tests/ext/test_less.py index 1a9cc1a..f8cd849 100644 --- a/hyde/tests/ext/test_less.py +++ b/hyde/tests/ext/test_less.py @@ -29,7 +29,8 @@ class TestLess(object): def test_can_execute_less(self): s = Site(TEST_SITE) s.config.plugins = ['hyde.ext.plugins.less.LessCSSPlugin'] - paths = ['/usr/local/share/npm/bin/lessc', '~/local/bin/lessc'] + paths = ['/usr/local/share/npm/bin/lessc', '~/local/bin/lessc', + '/usr/bin/lessc', '~/bin/lessc'] less = [path for path in paths if File(path).exists] if not less: assert False, "Cannot find the lessc executable" diff --git a/hyde/tests/ext/test_optipng.py b/hyde/tests/ext/test_optipng.py index 8154880..480e1da 100644 --- a/hyde/tests/ext/test_optipng.py +++ b/hyde/tests/ext/test_optipng.py @@ -31,7 +31,7 @@ class TestOptipng(object): s = Site(TEST_SITE) s.config.mode = "production" s.config.plugins = ['hyde.ext.plugins.optipng.OptiPNGPlugin'] - paths = ['/usr/local/bin/optipng'] + paths = ['/usr/local/bin/optipng', '/usr/bin/optipng'] optipng = [path for path in paths if File(path).exists] if not optipng: assert False, "Cannot find the optipng executable" diff --git a/hyde/tests/ext/test_stylus.py b/hyde/tests/ext/test_stylus.py index 20facef..1f2af53 100644 --- a/hyde/tests/ext/test_stylus.py +++ b/hyde/tests/ext/test_stylus.py @@ -29,7 +29,8 @@ class TestLess(object): def test_can_execute_stylus(self): s = Site(TEST_SITE) s.config.plugins = ['hyde.ext.plugins.stylus.StylusPlugin'] - paths = ['/usr/local/share/npm/bin/stylus', '~/local/bin/stylus'] + paths = ['/usr/local/share/npm/bin/stylus', '~/local/bin/stylus', + '~/bin/stylus'] stylus = [path for path in paths if File(path).exists] if not stylus: assert False, "Cannot find the stylus executable" @@ -53,7 +54,8 @@ class TestLess(object): s = Site(TEST_SITE) s.config.mode = "production" s.config.plugins = ['hyde.ext.plugins.stylus.StylusPlugin'] - paths = ['/usr/local/share/npm/bin/stylus', '~/local/bin/stylus'] + paths = ['/usr/local/share/npm/bin/stylus', '~/local/bin/stylus', + '~/bin/stylus'] stylus = [path for path in paths if File(path).exists] if not stylus: assert False, "Cannot find the stylus executable" @@ -68,4 +70,4 @@ class TestLess(object): assert target.exists text = target.read_all() expected_text = File(STYLUS_SOURCE.child('expected-site-compressed.css')).read_all() - assert text.strip() == expected_text.strip() \ No newline at end of file + assert text.strip() == expected_text.strip() diff --git a/hyde/tests/ext/test_uglify.py b/hyde/tests/ext/test_uglify.py index 57d1952..41d4220 100644 --- a/hyde/tests/ext/test_uglify.py +++ b/hyde/tests/ext/test_uglify.py @@ -31,7 +31,8 @@ class TestLess(object): s = Site(TEST_SITE) s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin'] s.config.mode = "production" - paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs'] + paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs', + '/usr/bin/uglifyjs', '~/bin/uglifyjs'] uglify = [path for path in paths if File(path).exists] if not uglify: assert False, "Cannot find the uglify executable" @@ -52,7 +53,8 @@ class TestLess(object): s = Site(TEST_SITE) s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin'] s.config.mode = "production" - paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs'] + paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs', + '/usr/bin/uglifyjs', '~/bin/uglifyjs'] uglify = [path for path in paths if File(path).exists] if not uglify: assert False, "Cannot find the uglify executable" @@ -74,7 +76,8 @@ class TestLess(object): s = Site(TEST_SITE) s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin'] s.config.mode = "dev" - paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs'] + paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs', + '/usr/bin/uglifyjs', '~/bin/uglifyjs'] uglify = [path for path in paths if File(path).exists] if not uglify: assert False, "Cannot find the uglify executable" From 3e1ea8337814b5730a0af9b3de7797e054abbf99 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 7 May 2011 09:45:40 +0200 Subject: [PATCH 2/3] Fix the use of unknown dateformat filter dateformat in tests. Use strftime instead. There seems to be no dateformat filter in jinja documentation. --- hyde/tests/templates/jinja2/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyde/tests/templates/jinja2/index.html b/hyde/tests/templates/jinja2/index.html index b006d05..0379820 100644 --- a/hyde/tests/templates/jinja2/index.html +++ b/hyde/tests/templates/jinja2/index.html @@ -6,7 +6,7 @@

{{ article.title|e }}

written by {{ article.user.username|e }} on {{ article.pub_date|dateformat }}

+ }}">{{ article.user.username|e }} on {{ article.pub_date.strftime('%Y-%m-%d') }}

{{ article.body }}
{%- endfor %} From cc09d99a4e617ea83bb8a2a3b882831447081273 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 7 May 2011 10:04:33 +0200 Subject: [PATCH 3/3] Make sorting more predictable. Always first sort by name then by any attributes you want. Otherwise, tests may fail. --- hyde/ext/plugins/sorter.py | 3 ++- hyde/tests/ext/test_sorter.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hyde/ext/plugins/sorter.py b/hyde/ext/plugins/sorter.py index c923283..229e565 100644 --- a/hyde/ext/plugins/sorter.py +++ b/hyde/ext/plugins/sorter.py @@ -44,7 +44,8 @@ def sort_method(node, settings=None): if settings and hasattr(settings, 'attr') and settings.attr: attr = settings.attr filter_ = partial(filter_method, settings=settings) - resources = ifilter(filter_, node.walk_resources()) + resources = sorted(ifilter(filter_, node.walk_resources()), + key=lambda f: f.name) reverse = False if settings and hasattr(settings, 'reverse'): reverse = settings.reverse diff --git a/hyde/tests/ext/test_sorter.py b/hyde/tests/ext/test_sorter.py index 21770dd..29aff42 100644 --- a/hyde/tests/ext/test_sorter.py +++ b/hyde/tests/ext/test_sorter.py @@ -49,7 +49,7 @@ class TestSorter(object): pages = [page.name for page in s.content.walk_resources_sorted_by_kind()] - assert pages == sorted(expected, key=lambda f: File(f).kind) + assert pages == sorted(sorted(expected), key=lambda f: File(f).kind) def test_walk_resources_sorted_reverse(self): s = Site(TEST_SITE) @@ -74,7 +74,7 @@ class TestSorter(object): s.content.walk_resources_sorted_by_kind()] - assert pages == sorted(expected, key=lambda f: File(f).kind, reverse=True) + assert pages == sorted(sorted(expected), key=lambda f: File(f).kind, reverse=True) def test_walk_resources_sorted_with_filters(self): s = Site(TEST_SITE) @@ -131,7 +131,7 @@ class TestSorter(object): expected_sorted = [File(page).name for page in - sorted(expected, + sorted(sorted(expected), key=lambda p: tuple( [File(p).kind, File(p).parent.name]))] @@ -269,4 +269,4 @@ class TestSorter(object): text = target.read_all() q = PyQuery(text) - assert q('span.latest').text() == 'YayYayYay' \ No newline at end of file + assert q('span.latest').text() == 'YayYayYay'