summaryrefslogtreecommitdiff
path: root/tests/unittests/test_templating.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2015-01-26 20:02:31 -0500
committerBarry Warsaw <barry@python.org>2015-01-26 20:02:31 -0500
commit5e2b8ef0703eb4582a5a8ba50ae7c83a8294d65a (patch)
tree9f3c2d6d7cdd3e63e52d54152d3dbb15e916d9f3 /tests/unittests/test_templating.py
parentfe99f7d6d87e88320933957b2933288c6eb2986d (diff)
downloadvyos-cloud-init-5e2b8ef0703eb4582a5a8ba50ae7c83a8294d65a.tar.gz
vyos-cloud-init-5e2b8ef0703eb4582a5a8ba50ae7c83a8294d65a.zip
Repair the Python 2.6 tests.
Diffstat (limited to 'tests/unittests/test_templating.py')
-rw-r--r--tests/unittests/test_templating.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/unittests/test_templating.py b/tests/unittests/test_templating.py
index 957467f6..fbad405f 100644
--- a/tests/unittests/test_templating.py
+++ b/tests/unittests/test_templating.py
@@ -16,6 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
+import sys
import six
import unittest
@@ -24,6 +27,20 @@ import textwrap
from cloudinit import templater
+try:
+ skipIf = unittest.skipIf
+except AttributeError:
+ # Python 2.6. Doesn't have to be high fidelity.
+ def skipIf(condition, reason):
+ def decorator(func):
+ def wrapper(*args, **kws):
+ if condition:
+ return func(*args, **kws)
+ else:
+ print(reason, file=sys.stderr)
+ return wrapper
+ return decorator
+
class TestTemplates(test_helpers.TestCase):
def test_render_basic(self):
@@ -41,7 +58,7 @@ class TestTemplates(test_helpers.TestCase):
out_data = templater.basic_render(in_data, {'b': 2})
self.assertEqual(expected_data.strip(), out_data)
- @unittest.skipIf(six.PY3, 'Cheetah is not compatible with Python 3')
+ @skipIf(six.PY3, 'Cheetah is not compatible with Python 3')
def test_detection(self):
blob = "## template:cheetah"