johnklee / fpu

Functional programming utility
MIT License
4 stars 4 forks source link

Configure Pytest #39

Closed wkCircle closed 1 year ago

wkCircle commented 1 year ago

The issue is intended to configure the pytest as a pre-step to have a complete CI build. The pytest configuration will be specified in pyproject.toml for convenience and easy integration with other tools in the future (though other file names are also supported via pytest).

The configuration should include

wkCircle commented 1 year ago

Explanation: effect of pytest -ra option

As documented in the doc of manaing pytest's output,

In the PR I use this -ra setting. An example screen shot will be demonstrated along the PR with all specific config in the pyproject.toml.

wkCircle commented 1 year ago

With --tb=line, we can show only one line per failure. Therefore I think the additional package pytest-lineno is no longer needed.

I also found that, in the coverage report (as shown below), most missing lines are related to NotImplementedError or unexecuted __str__, __hash__ etc. This affects the coverage rate and makes it harder to reach high coverage standard.

I see that many functions with NotImplementedError should not be a problem once we implement them in the future, yet __str__, __hash__ etc are still captured by the coverage report, which are trivial.

A possible solution would be to either ignore them by adding them to white-list, or add (trivial) tests for them. If we want to ignore the trivial lines mentioned, then we may need to switch to another package coverage since currently I didn't see pytest-cov supports it as discussed in their issue 428.

I will make a new PR.