From 10e59fb9278b79fd4254f7e4b456f975a10cab3f Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Sat, 14 Mar 2020 21:16:53 +0100 Subject: [PATCH] Updated README with development instructions * Additionally the `setup.py` file is simplified. * Tests automatically enforce `flake8` by using the `pytest-flake8` plugin. --- .gitignore | 8 +++++++- .travis.yml | 3 +-- README.md | 20 ++++++++++++++++++++ jinja2cli/cli.py | 4 +--- setup.cfg | 5 +++++ setup.py | 11 +++++------ 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 9f431dd..763dec3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ *.so # Packages -*.egg +*.eggs *.egg-info dist build @@ -18,6 +18,12 @@ develop-eggs lib lib64 +# Virtualenv +env +.env +venv +.venv + # Installer logs pip-log.txt diff --git a/.travis.yml b/.travis.yml index 8ee17f0..1b56297 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,4 @@ python: install: pip install -e .[yaml,toml,tests,xml] script: - - pytest -v - - flake8 jinja2cli tests + - pytest -vvv diff --git a/README.md b/README.md index 13579e6..18ddb09 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,26 @@ If `xmltodict` is present, you can use XML as an input data source. `$ pip install jinja2-cli[xml]` +## Development +For local development install the package in develop mode with `tests` extras +into a virtualenv: + +```console +$ python -m venv env +$ env/bin/activate +(env) $ pip install -e ".[tests]" +``` + +### Code style +The project uses `flake8` to check the code style. + +### Tests +To invoke tests (and code style checks) run the `pytest` command: + +```console +(env) $ pytest +``` + ## TODO * Variable inheritance and overrides * Tests! diff --git a/jinja2cli/cli.py b/jinja2cli/cli.py index 79d84db..e908bcf 100644 --- a/jinja2cli/cli.py +++ b/jinja2cli/cli.py @@ -6,13 +6,11 @@ """ import warnings - -warnings.filterwarnings("ignore") - import os import sys from optparse import Option, OptionParser +warnings.filterwarnings("ignore") sys.path.insert(0, os.getcwd()) PY3 = sys.version_info[0] == 3 diff --git a/setup.cfg b/setup.cfg index 5d6505d..fc49e46 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,3 +4,8 @@ max-line-length = 100 [bdist_wheel] universal = 1 + +[tool:pytest] +addopts = --flake8 +flake8-max-line-length = 100 +flake8-ignore = E402 diff --git a/setup.py b/setup.py index 3eed97b..687b6f0 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import find_packages, setup install_requires = ["jinja2"] -tests_requires = ["pytest", "flake8"] +tests_require = ["pytest", "pytest-flake8"] setup( name="jinja2-cli", @@ -29,12 +29,11 @@ license="BSD", install_requires=install_requires, extras_require={ - "yaml": install_requires + ["pyyaml"], - "toml": install_requires + ["toml"], - "xml": install_requires + ["xmltodict"], - "tests": install_requires + tests_requires, + "yaml": ["pyyaml"], + "toml": ["toml"], + "xml": ["xmltodict"], + "tests": tests_require, }, - tests_require=tests_requires, include_package_data=True, entry_points={"console_scripts": ["jinja2 = jinja2cli:main"]}, classifiers=[