From d4f711a63400720bcda1f98a2bedd84f1260f3f2 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Thu, 29 Dec 2016 21:46:18 +0200 Subject: [PATCH] - Adding doctest. --- template/filters.py | 13 +++++++++++++ tox.ini | 1 + 2 files changed, 14 insertions(+) diff --git a/template/filters.py b/template/filters.py index 018c9ac..993435a 100644 --- a/template/filters.py +++ b/template/filters.py @@ -2,6 +2,19 @@ def to_yaml(value): + ''' + Converts given data structure to YAML form. + Examples: + + >>> to_yaml([1,2,3]) + '[1, 2, 3]\\n' + >>> to_yaml({'a': 1, 'b': 2}) + '{a: 1, b: 2}\\n' + >>> to_yaml({1: {'a': [1,2,3]}}) + '1:\\n a: [1, 2, 3]\\n' + >>> to_yaml("abc") + 'abc\\n...\\n' + ''' from yaml import safe_dump return safe_dump(value) diff --git a/tox.ini b/tox.ini index 1ac57a8..c1b9865 100644 --- a/tox.ini +++ b/tox.ini @@ -21,6 +21,7 @@ commands = check-manifest --ignore tox.ini,tests* python setup.py check -m -r -s flake8 . + python -m doctest template/filters.py template/__init__.py ./tests.sh [testenv:release] -- GitLab