From d2854315c13749d663718c1be56f41bed883f3f3 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sun, 24 Jan 2021 16:19:46 +0100 Subject: [PATCH] [Test] Added setup.cfg to run tests and coverage, updated Readme --- readme.md | 25 ++++++++++++++++++------- setup.cfg | 9 +++++++++ setup.py | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 setup.cfg diff --git a/readme.md b/readme.md index a158069..51deeac 100644 --- a/readme.md +++ b/readme.md @@ -9,9 +9,9 @@ or with ldap support pip3 install --user ".[ldap]" -or if you want to use bjoern as the HTTP server: +or if you want to also run the tests: - pip3 install --user ".[ldap,bjoern]" + pip3 install --user ".[ldap,test]" #### Windows Same as above, but for mysql you have to follow this guide: @@ -19,7 +19,7 @@ Same as above, but for mysql you have to follow this guide: https://www.radishlogic.com/coding/python-3/installing-mysqldb-for-python-3-in-windows/ ### Configuration -1. Rename `flaschengeist.example.cfg` to `flaschengeist.cfg` +1. Rename `flaschengeist.example.toml` to `flaschengeist.toml` 2. Move it to either 1. the module path (where flaschegeist is installed) 2. `~/.config/` @@ -27,13 +27,24 @@ https://www.radishlogic.com/coding/python-3/installing-mysqldb-for-python-3-in-w 3. Change at least the database parameters ### Database installation - run_flaschengeist --install + run_flaschengeist install ### Run - run_flaschengeist + run_flaschengeist run or with debug messages: - run_flaschengeist --debug + run_flaschengeist run --debug + +## Tests + $ pip install '.[test]' + $ pytest +Run with coverage report: + + $ coverage run -m pytest + $ coverage report +Or with html output (open `htmlcov/index.html` in a browser): + + $ coverage html ## Development ### Code Style @@ -74,7 +85,7 @@ Or if you just want to use `git blame`, configure git like this: example_bp = Blueprint("example", __name__, url_prefix="/example") - permissions = {"EXAMPLE_HELLO": "example_hello"} + permissions = ["example_hello"] class PluginExample(Plugin): def __init__(self, conf): diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6218c19 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[bdist_wheel] +universal = True + +[tool:pytest] +testpaths = tests + +[coverage:run] +branch = True +source = flaschengeist \ No newline at end of file diff --git a/setup.py b/setup.py index 97d3100..d2c164b 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ setup( # Needed for python < 3.7 "backports-datetime-fromisoformat", ], - extras_require={"ldap": ["flask_ldapconn", "ldap3"], "tests": ["pytest"]}, + extras_require={"ldap": ["flask_ldapconn", "ldap3"], "test": ["pytest", "coverage"]}, entry_points={ "flaschengeist.plugin": [ # Authentication providers