isso icon indicating copy to clipboard operation
isso copied to clipboard

Python test coverage needs improvement

Open jelmer opened this issue 2 years ago • 8 comments

The test coverage for isso's Python code is very spotty; in order to be confident when making changes and adding features, we should make sure that all code at least has some degree of coverage.

jelmer avatar Dec 31 '21 18:12 jelmer

To elaborate, the python unit tests are in isso/tests/.

To run Isso's unit tests, you can use python -m unittest discover isso/tests (or pytest installed via pip install pytest). - Edit: Simply run make test

We should probably update the docs that still recommend using nose since it won't run on current python versions and is abandoned by its creators. - Edit: Done

Any contributors experienced in python or unit testing are welcome to help out!

ix5 avatar Dec 31 '21 21:12 ix5

Maybe we could start by add a linter like flake8 to improve code reliability? We could also add it as a git hook through pr-commit to enforce code homogeneity and contributing guidelines?

If you want, I can push some PR.

Guts avatar Jan 04 '22 23:01 Guts

Code linting and enforcing style seems like a good idea (and I'd welcome a PR to add that), but it is unrelated to better tests.

jelmer avatar Jan 04 '22 23:01 jelmer

but it is unrelated to better tests.

Woo @jelmer, you are quite harsh! I see a static analysis tool (linter) as a good complementary first step to better tests since it aims at improving software quality.

Guts avatar Jan 04 '22 23:01 Guts

My apologies, I didn't mean to come across as harsh. I'm not disagreeing with you about the usefulness of a linter in general and its potential contributions to code quality. But they're orthogonal, and a linter won't give us significantly more confidence merging new PRs.

jelmer avatar Jan 04 '22 23:01 jelmer

No worries, I get it that we agree.

I've pushed a PR.

Guts avatar Jan 05 '22 00:01 Guts

Maybe we could start by add a linter like flake8 to improve code reliability?

@Guts we already have flake8 (via make flakes), would you care to modify the config (inside setup.cfg so far) so that it catches more things?

ix5 avatar Feb 17 '22 11:02 ix5

As a reference point, this is the current coverage:

$ coverage report --omit='*/tests/*'
Name                        Stmts   Miss  Cover
-----------------------------------------------
isso/__init__.py              159     81    49%
isso/config.py                 84     14    83%
isso/core.py                   69     24    65%
isso/db/__init__.py            66      6    91%
isso/db/comments.py           135     19    86%
isso/db/preferences.py         17      0   100%
isso/db/spam.py                40      2    95%
isso/db/threads.py             15      0   100%
isso/dispatch.py               39     39     0%
isso/ext/__init__.py           10      0   100%
isso/ext/notifications.py     149     99    34%
isso/migrate.py               193     27    86%
isso/run.py                     7      7     0%
isso/utils/__init__.py         66     11    83%
isso/utils/hash.py             58      1    98%
isso/utils/html.py             50      3    94%
isso/utils/http.py             35     24    31%
isso/utils/parse.py            42      2    95%
isso/views/__init__.py         35      8    77%
isso/views/comments.py        491     90    82%
isso/wsgi.py                   87     17    80%
-----------------------------------------------
TOTAL                        1847    474    74%

ix5 avatar Mar 27 '22 14:03 ix5