From 047458dcf61ad93572c829d690dbcf978b4d400a Mon Sep 17 00:00:00 2001 From: Sylvain Tricot Date: Fri, 29 Nov 2019 17:38:41 +0100 Subject: [PATCH] Add test coverage report in documentation Now tests are run through the coverage utility and a report is generated and available in the FAQ of the html doc. --- Makefile | 2 +- doc/Makefile | 8 ++++++-- doc/source/conf.py | 2 ++ .../faq/coverage_report/coverage_report.rst | 8 ++++++++ doc/source/faq/index.rst | 19 ++++++++++--------- src/Makefile | 7 ++++++- src/msspec/es/es_mod/es_apollonius.py | 2 +- src/msspec/es/es_mod/es_sym_analys.py | 16 ++++++++-------- .../msspecgui/msspec/gui/clustereditor.py | 4 ++-- .../msspec/gui/clusterviewer3d/GLPanel.py | 8 ++++---- src/msspec/tests.py | 4 ++++ 11 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 doc/source/faq/coverage_report/coverage_report.rst diff --git a/Makefile b/Makefile index 42c8ff5..4fe07c2 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ clean: venv: @virtualenv --python=python3 --system-site-packages ci_venv $(SUPPRESS_OUPUT) - @. "./ci_venv/bin/activate" && pip install --upgrade pip numpy ase h5py lxml pint terminaltables pycairo sphinx $(SUPPRESS_OUPUT) + @. "./ci_venv/bin/activate" && pip install --upgrade pip numpy ase h5py lxml pint terminaltables pycairo sphinx coverage $(SUPPRESS_OUPUT) doc: @echo "Building pdf and html documentation..." diff --git a/doc/Makefile b/doc/Makefile index 28b7e10..7fec930 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = -SPHINXBUILD = python -m sphinx +SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build @@ -83,9 +83,13 @@ html0: banner images @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." -html: html0 ownership $(BUILDDIR)/html/sitemap.xml +html: html0 ownership $(BUILDDIR)/html/sitemap.xml coverage_report @echo +coverage_report: + @echo "Generating coverage report..." + @mv source/htmlcov $(BUILDDIR)/html/_static + dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo diff --git a/doc/source/conf.py b/doc/source/conf.py index d7672b0..1c6b515 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -20,6 +20,8 @@ import sys, os sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('../src')) sys.path.insert(0, os.path.abspath('../src/msspec')) +sys.path.insert(0, os.path.abspath('../../src')) +sys.path.insert(0, os.path.abspath('../../src/msspec')) #sys.path.insert(0, os.path.abspath('../')) diff --git a/doc/source/faq/coverage_report/coverage_report.rst b/doc/source/faq/coverage_report/coverage_report.rst new file mode 100644 index 0000000..47650a4 --- /dev/null +++ b/doc/source/faq/coverage_report/coverage_report.rst @@ -0,0 +1,8 @@ +.. _coverage_report_faq: + +Test coverage +------------- + +.. raw:: html + + diff --git a/doc/source/faq/index.rst b/doc/source/faq/index.rst index f46ebfb..6d4ece4 100644 --- a/doc/source/faq/index.rst +++ b/doc/source/faq/index.rst @@ -1,9 +1,10 @@ -.. _faq: - -### -FAQ -### - -.. toctree:: - - hemispherical_cluster/hemispherical_cluster +.. _faq: + +### +FAQ +### + +.. toctree:: + + hemispherical_cluster/hemispherical_cluster + coverage_report/coverage_report diff --git a/src/Makefile b/src/Makefile index b48a36d..3f8c536 100644 --- a/src/Makefile +++ b/src/Makefile @@ -27,7 +27,12 @@ results: pybinding tests: pybinding @echo "Runing unittests" - @python -c "from msspec.tests import run_tests; run_tests()" 1>/dev/null +# @python -c "from msspec.tests import run_tests; run_tests()" 1>/dev/null + @coverage run --source=./ --omit=msspec/es/*,msspec/msspecgui/* msspec/tests.py 1>/dev/null +# create the html coverage report +# @mv .coverage ../doc/source + @coverage html -d ../doc/source/htmlcov + @rm .coverage clean: @echo "Cleaning all..." diff --git a/src/msspec/es/es_mod/es_apollonius.py b/src/msspec/es/es_mod/es_apollonius.py index a16a83f..0570ec7 100644 --- a/src/msspec/es/es_mod/es_apollonius.py +++ b/src/msspec/es/es_mod/es_apollonius.py @@ -24,7 +24,7 @@ def Apollonius_CCC(circles_data) : rmin=min(circles_data[1]) nbmin=circles_data[1].count(rmin)#So it is the number of circles with the smallest radius if nbmin==1 : #then we have 1 little circle, we go to Apollonius CCP - + pass elif nbmin==2: #then we have 2 little circles, we go to Apollonius CPP if r1!=rmin : data=[[O1,r1],O2,O3] diff --git a/src/msspec/es/es_mod/es_sym_analys.py b/src/msspec/es/es_mod/es_sym_analys.py index ff6b87a..f9b6d46 100644 --- a/src/msspec/es/es_mod/es_sym_analys.py +++ b/src/msspec/es/es_mod/es_sym_analys.py @@ -54,16 +54,16 @@ def compare_sym(Nsym,Osym): print("New number of sym :", N) if N>O : output=2 - print "Symmetries gained. Symmetry-list updated" + print("Symmetries gained. Symmetry-list updated") elif O==1 : output=-1 - print "No symmetry existing to help at decision" + print("No symmetry existing to help at decision") elif N == O: output=1 - print "Symmetry has been conserved." + print("Symmetry has been conserved.") elif N