Skip to content

Commit

Permalink
Merge db1a735 into f69d7bd
Browse files Browse the repository at this point in the history
  • Loading branch information
nhoening committed May 13, 2023
2 parents f69d7bd + db1a735 commit fa4f7e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[run]
omit = */tests/*, */scripts/*
omit = */tests/*, */scripts/*, **/*.jinja, **/*.html, **/*.txt
27 changes: 21 additions & 6 deletions documentation/dev/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,37 @@ You can run automated tests with:
$ make test
which behind the curtains installs dependencies and calls pytest.
which behind the curtains installs dependencies and calls ``pytest``.

A coverage report can be created like this:
However, a test postgres database is needed to run these tests. If you have postgres, here is the short version on how to add the test database:

.. code-block:: bash
$ pytest --cov=flexmeasures --cov-config .coveragerc
make clean-db db_name=flexmeasures_test db_user=flexmeasures_test
# the password for the db user is "flexmeasures_test"
.. note:: The section :ref:`host-data` has more details on using postgres for FlexMeasures.

Alternatively, if you don't feel like installing postgres for the time being, here is a docker command:

.. code-block:: docker
docker run --rm --name flexmeasures-test-db -e POSTGRES_PASSWORD=flexmeasures_test -e POSTGRES_DB=flexmeasures_test -e POSTGRES_USER=flexmeasures_test -p 5432:5432 -v ./ci/load-psql-extensions.sql:/docker-entrypoint-initdb.d/load-psql-extensions.sql -d postgres:latest
.. warning:: This assumes that the port 5432 is not being used (for instance by an existing postgres database service).

You can add --cov-report=html after which a htmlcov/index.html is generated.
If you want the tests to create a coverage report (printed on the terminal), you can run the ``pytest`` command like this:

.. code-block:: bash
$ pytest --cov=flexmeasures --cov-config .coveragerc
It's also possible to use:
You can add `--cov-report=html`, after which a file called `htmlcov/index.html` is generated.
Or, after a test run with coverage turned on as shown above, you can still generate it in another form:

.. code-block:: bash
$ python setup.py test
$ python3 -m coverage [html|lcov|json]
Expand Down

0 comments on commit fa4f7e6

Please sign in to comment.