diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0de076a133c93daecd7cffcdd24effa5f5f22cbb..1ca7989241b586b35be9c8b5a98a6f681d2a81d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,13 +2,7 @@ sha: v0.7.1 hooks: - id: check-added-large-files - - id: check-json - - id: check-xml - id: check-yaml - id: check-merge-conflict - id: flake8 - id: check-symlinks -- repo: https://www.shore.co.il/git/shell-pre-commit/ - sha: v0.5.3 - hooks: - - id: shell-lint diff --git a/.travis.yml b/.travis.yml index 436187bf4a2f10b5682f65d91c39abefec4e73ae..784413b6f640f61f5fefcef9bdb559e1795d38e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,11 @@ matrix: - python: "3.2" install: + - git clone --depth 1 https://github.com/sstephenson/bats "$HOME/bats" - pip install tox-travis | cat +env: + PATH: "$PATH:$HOME/bats/bin" script: - tox diff --git a/MANIFEST.in b/MANIFEST.in index e09a28e6f447a42be56d7f6140ef46470fcbef29..30ab8989bd7e8bf4681dd29d8f9cc36fcf59dab3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ recursive-include template *.py exclude .pre-commit-config.yaml +exclude *.bats include *.rst include VERSION include *.txt diff --git a/README.rst b/README.rst index d8092512413e87f0676b652b51ed1e209d20b5f9..56f25e8a97394feaa7066566f344312130776083 100644 --- a/README.rst +++ b/README.rst @@ -43,21 +43,20 @@ The following Jinja filters were added: - :code:`from_yaml`: Convert from yaml. - :code:`to_json`: Convert to json. - :code:`from_json`: Convert from json. -- :code:`combine`: Combine 2 dictionaries. - :code:`to_toml`: Convert to toml. - :code:`from_toml`: Convert from toml. - :code:`jmespath`: Queries data using the `JMESPath <http://jmespath.org/>`_ query language. -Example usage can be seen in :code:`tests.sh` and for specific filters in the +Example usage can be seen in :code:`tests` and for specific filters in the docstrings in :code:`template/filters.py`. Testing ------- -Tests require Python 2.7, Python 3.3 or later and Tox and are run by running -:code:`tox`. Also, Travis CI is used to test on multiple Python versions for -every push. +Tests require Python 2.7, Python 3.3 or later, Tox and Bats and are run by +running :code:`tox`. Also, Travis CI is used to test on multiple Python +versions for every push. Release ------- diff --git a/VERSION b/VERSION index 70d5b25fa8733140e4b2b4516377c5ef6f96d496..b300caa32a150146a910b36c742c9782c7bf198b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.3 \ No newline at end of file +0.4.4 \ No newline at end of file diff --git a/tests.sh b/tests.sh deleted file mode 100755 index d329d33f939fd7cfe4975a21a033357c9b3c433b..0000000000000000000000000000000000000000 --- a/tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -eu - -export infile="$(mktemp)" -export outfile="$(mktemp)" - -echo Basic test. -export name='John' -test "$(echo 'Hello {{ name if name is defined else 'world' }}.' | template)" = "Hello John." - -echo Testing arguments and reading/ writing to file. -echo '{{ name }}' > "$infile" -export name='John' -template --output "$outfile" "$infile" -test "$(cat $outfile)" = "$name" - -rm "$infile" "$outfile" diff --git a/tests/input b/tests/input new file mode 100644 index 0000000000000000000000000000000000000000..aa2bf894473478e4387c50ba6ce282d082a59375 --- /dev/null +++ b/tests/input @@ -0,0 +1 @@ +{{ name }} diff --git a/tests/templates.bats b/tests/templates.bats new file mode 100644 index 0000000000000000000000000000000000000000..b5c3dfc49e76fdbc31fc80fb29ceb207f4ecb96e --- /dev/null +++ b/tests/templates.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +export name='John' + +@test "Basic test" { + run sh -c "echo 'Hello {{ name }}.' | template" + [ "$output" = "Hello John." ] +} + +@test "Test arguments and reading and to/ from a file" { + template --output "$BATS_TMPDIR/output" "$BATS_TEST_DIRNAME/input" + run cat "$BATS_TMPDIR/output" + [ "$output" = "John" ] +} diff --git a/tox.ini b/tox.ini index 34b08a6fc11a19344bf0ead96baf42a3a3bfe25b..29539b2b2cf308c55b66b1b631039094d5da957b 100644 --- a/tox.ini +++ b/tox.ini @@ -19,12 +19,14 @@ deps = readme_renderer flake8 six +whitelist_externals = + bats commands = check-manifest --ignore tox.ini,tests* python setup.py check --metadata --strict flake8 . python -m doctest template/filters.py template/__init__.py - ./tests.sh + bats -t tests [testenv:docs] basepython = python