aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-01-22 11:04:34 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-01-22 11:04:34 -0500
commitca89900531df1dda004e363141ab3306a621f3c1 (patch)
treecbce34db93d1c9bd599fd3f1917dccbaab7ecee5 /test
parent639fa5a0739b471c2994ed4c45a26f75ae3f6ae4 (diff)
downloadexternal_python_mako-ca89900531df1dda004e363141ab3306a621f3c1.tar.gz
external_python_mako-ca89900531df1dda004e363141ab3306a621f3c1.tar.bz2
external_python_mako-ca89900531df1dda004e363141ab3306a621f3c1.zip
- reimplement skiptests for babel or lingua not installed
- remove nose dependency
Diffstat (limited to 'test')
-rw-r--r--test/__init__.py7
-rw-r--r--test/ext/test_babelplugin.py25
-rw-r--r--test/ext/test_linguaplugin.py72
-rw-r--r--test/test_cache.py4
4 files changed, 72 insertions, 36 deletions
diff --git a/test/__init__.py b/test/__init__.py
index 46f9f81..666318f 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -6,7 +6,12 @@ from mako import compat
from mako.util import update_wrapper
import re
from mako.cache import CacheImpl, register_plugin
-from nose import SkipTest
+
+try:
+ from nose import SkipTest
+except ImportError:
+ from unittest import SkipTest
+
import contextlib
template_base = os.path.join(os.path.dirname(__file__), 'templates')
diff --git a/test/ext/test_babelplugin.py b/test/ext/test_babelplugin.py
index 4f17ad9..5fb69d6 100644
--- a/test/ext/test_babelplugin.py
+++ b/test/ext/test_babelplugin.py
@@ -1,21 +1,37 @@
import io
import os
import unittest
-from mako.ext.babelplugin import extract
-from .. import TemplateTest, template_base
+from .. import TemplateTest, template_base, skip_if
+
+try:
+ import babel
+except:
+ babel = None
+
+if babel is not None:
+ from mako.ext.babelplugin import extract
+
+
+def skip():
+ return skip_if(
+ lambda: not babel,
+ 'babel not installed: skipping babelplugin test')
class Test_extract(unittest.TestCase):
+ @skip()
def test_parse_python_expression(self):
input = io.BytesIO(b'<p>${_("Message")}</p>')
messages = list(extract(input, ['_'], [], {}))
self.assertEqual(messages, [(1, '_', u'Message', [])])
+ @skip()
def test_python_gettext_call(self):
input = io.BytesIO(b'<p>${_("Message")}</p>')
messages = list(extract(input, ['_'], [], {}))
self.assertEqual(messages, [(1, '_', u'Message', [])])
+ @skip()
def test_translator_comment(self):
input = io.BytesIO(b'''
<p>
@@ -24,11 +40,12 @@ class Test_extract(unittest.TestCase):
</p>''')
messages = list(extract(input, ['_'], ['TRANSLATORS:'], {}))
self.assertEqual(
- messages,
- [(4, '_', u'Message', [u'TRANSLATORS: This is a comment.'])])
+ messages,
+ [(4, '_', u'Message', [u'TRANSLATORS: This is a comment.'])])
class ExtractMakoTestCase(TemplateTest):
+ @skip()
def test_extract(self):
mako_tmpl = open(os.path.join(template_base, 'gettext.mako'))
messages = list(extract(mako_tmpl, {'_': None, 'gettext': None,
diff --git a/test/ext/test_linguaplugin.py b/test/ext/test_linguaplugin.py
index 55b3ba1..9c46271 100644
--- a/test/ext/test_linguaplugin.py
+++ b/test/ext/test_linguaplugin.py
@@ -1,7 +1,14 @@
import os
-from mako.ext.linguaplugin import LinguaMakoExtractor
-from lingua.extractors import register_extractors
-from .. import TemplateTest, template_base
+from .. import TemplateTest, template_base, skip_if
+
+try:
+ import lingua
+except:
+ lingua = None
+
+if lingua is not None:
+ from mako.ext.linguaplugin import LinguaMakoExtractor
+ from lingua.extractors import register_extractors
class MockOptions:
@@ -9,35 +16,42 @@ class MockOptions:
domain = None
+def skip():
+ return skip_if(
+ lambda: not lingua, 'lingua not installed: skipping linguaplugin test')
+
+
class ExtractMakoTestCase(TemplateTest):
+ @skip()
def test_extract(self):
register_extractors()
plugin = LinguaMakoExtractor({'comment-tags': 'TRANSLATOR'})
- messages = list(plugin(os.path.join(template_base, 'gettext.mako'), MockOptions()))
+ messages = list(
+ plugin(os.path.join(template_base, 'gettext.mako'), MockOptions()))
msgids = [(m.msgid, m.msgid_plural) for m in messages]
self.assertEqual(
- msgids,
- [
- ('Page arg 1', None),
- ('Page arg 2', None),
- ('Begin', None),
- ('Hi there!', None),
- ('Hello', None),
- ('Welcome', None),
- ('Yo', None),
- ('The', None),
- ('bunny', 'bunnies'),
- ('Goodbye', None),
- ('Babel', None),
- ('hella', 'hellas'),
- ('The', None),
- ('bunny', 'bunnies'),
- ('Goodbye, really!', None),
- ('P.S. byebye', None),
- ('Top', None),
- (u'foo', None),
- ('hoho', None),
- (u'bar', None),
- ('Inside a p tag', None),
- ('Later in a p tag', None),
- ('No action at a distance.', None)])
+ msgids,
+ [
+ ('Page arg 1', None),
+ ('Page arg 2', None),
+ ('Begin', None),
+ ('Hi there!', None),
+ ('Hello', None),
+ ('Welcome', None),
+ ('Yo', None),
+ ('The', None),
+ ('bunny', 'bunnies'),
+ ('Goodbye', None),
+ ('Babel', None),
+ ('hella', 'hellas'),
+ ('The', None),
+ ('bunny', 'bunnies'),
+ ('Goodbye, really!', None),
+ ('P.S. byebye', None),
+ ('Top', None),
+ (u'foo', None),
+ ('hoho', None),
+ (u'bar', None),
+ ('Inside a p tag', None),
+ ('Later in a p tag', None),
+ ('No action at a distance.', None)])
diff --git a/test/test_cache.py b/test/test_cache.py
index 3f6f1b8..6675fb0 100644
--- a/test/test_cache.py
+++ b/test/test_cache.py
@@ -4,17 +4,17 @@ from mako import lookup
import shutil, unittest, os, time
from test.util import result_lines
from test import TemplateTest, template_base, module_base
-from test import eq_
+from test import eq_, SkipTest
try:
import beaker
import beaker.cache
except:
- from nose import SkipTest
raise SkipTest("Beaker is required for these tests.")
from mako.cache import register_plugin, CacheImpl
+
class MockCacheImpl(CacheImpl):
realcacheimpl = None