BhallaLab / moose-core

C++ basecode and python scripting interface
https://moose.ncbs.res.in
GNU General Public License v3.0
15 stars 27 forks source link

Adds Test Coverage #394

Closed dilawar closed 4 years ago

dilawar commented 4 years ago

This PR adds target pytest which generates test coverage. Currently the coverage is pretty bad (~30%). This PR also includes tests which covers more lines in core functionality i.e. moose.py file. Over the time, more tests can be added to increase the coverage.

C++ code coverage is not implemented in this PR. To do so, all tests have to run as one single giant python code. That means there will be duplicates. For example testa.py creates moose.Pool('/model/a') and testb.py also creates moose.Pool('/model/a'). This is fine iftesta.pyandtestsb.py` runs independently but when run as a single file, there is a duplicate. Most tests will fail.

This can be implemented in the future if a function like moose.clean() is available which cleanup all the objects created during a tests and new test can starts from a clean slate.

Current coverage report.

$ make pytest -j12
Name                                                 Stmts   Miss  Cover
------------------------------------------------------------------------
python/moose/OrderedDict.py                            155    155     0%
python/moose/SBML/__init__.py                            3      0   100%
python/moose/SBML/readSBML.py                         1033    662    36%
python/moose/SBML/validation.py                         72     39    46%
python/moose/SBML/writeSBML.py                         955    915     4%
python/moose/__init__.py                                 7      0   100%
python/moose/chemMerge/__init__.py                       1      0   100%
python/moose/chemMerge/merge.py                        457    432     5%
python/moose/chemMerge/mtypes.py                        87     66    24%
python/moose/chemUtil/__init__.py                        3      0   100%
python/moose/chemUtil/add_Delete_ChemicalSolver.py      92     35    62%
python/moose/chemUtil/chemConnectUtil.py               200    164    18%
python/moose/chemUtil/graphUtils.py                     57     48    16%
python/moose/constants.py                                9      9     0%
python/moose/fixXreacs.py                              136     11    92%
python/moose/genesis/__init__.py                         1      0   100%
python/moose/genesis/writeKkit.py                      553    503     9%
python/moose/graph_utils.py                             54     54     0%
python/moose/graphutil.py                              121    121     0%
python/moose/hdfutil.py                                171    171     0%
python/moose/helper.py                                  38     38     0%
python/moose/methods_utils.py                           27     27     0%
python/moose/model_utils.py                            110     48    56%
python/moose/moose.py                                  164     70    57%
python/moose/moose_constants.py                         24      0   100%
python/moose/moose_test.py                             121     85    30%
python/moose/neuroml/ChannelML.py                      332    169    49%
python/moose/neuroml/MorphML.py                        397    150    62%
python/moose/neuroml/NetworkML.py                      254    136    46%
python/moose/neuroml/NeuroML.py                         72     25    65%
python/moose/neuroml/__init__.py                         6      0   100%
python/moose/neuroml/utils.py                          150    110    27%
python/moose/neuroml2/__init__.py                        5      0   100%
python/moose/neuroml2/hhfit.py                         101    101     0%
python/moose/neuroml2/reader.py                        448    200    55%
python/moose/neuroml2/run_cell.py                       43     43     0%
python/moose/neuroml2/run_hhcell.py                     79     79     0%
python/moose/neuroml2/test_converter.py                 45     45     0%
python/moose/neuroml2/test_hhfit.py                     71     71     0%
python/moose/neuroml2/test_reader.py                    64     64     0%
python/moose/neuroml2/test_reader2.py                   45     45     0%
python/moose/neuroml2/units.py                          32      6    81%
python/moose/optimizer_interface.py                     30     30     0%
python/moose/plot_utils.py                             196    167    15%
python/moose/print_utils.py                             71     22    69%
python/moose/recording.py                              115    115     0%
python/moose/server.py                                 295    238    19%
python/moose/streamer_utils.py                          44     44     0%
python/moose/utils.py                                  526    463    12%
python/moose/wrapper.py                                113     54    52%
python/rdesigneur/__init__.py                            3      0   100%
python/rdesigneur/moogul.py                            197    109    45%
python/rdesigneur/rdesigneur.py                        982    442    55%
python/rdesigneur/rdesigneurProtos.py                  471    301    36%
python/rdesigneur/rmoogli.py                            27      5    81%
------------------------------------------------------------------------
TOTAL                                                 9865   6887    30%

$ coverage html # to generate a neat html

dilawar commented 4 years ago

@upibhalla This is ready to be reviewed . This also closes #393