nicolargo / glances

Glances an Eye on your system. A top/htop alternative for GNU/Linux, BSD, Mac OS and Windows operating systems.
http://nicolargo.github.io/glances/
Other
25.65k stars 1.46k forks source link

Improve unittest #2757

Open nicolargo opened 1 month ago

nicolargo commented 1 month ago
nicolargo commented 1 month ago

Improve tests by testing all the plugin/model.py methods done in Glances 4.0.0

nicolargo commented 1 month ago

Pytest tesbed

Include existing unittest

./venv/bin/pip install pytest

ln -s unittest-core.py test_core.py

./venv/bin/pytest
.....................................                                                                          [100%]
37 passed in 20.43s

Also work with other unitest file:

ln -s unittest-restful.py test_restful.py

ln -s unittest-xmlrpc.py test_xmlrpc.py

./venv/bin/pytest
......................................................................                                         [100%]
70 passed in 31.61s

Add new Pytest tests

Example:

cat /home/nhe/dev/glances/glances/timer_test.py
from .timer import Timer
def test_timer():
    t = Timer(5)
    assert t is not None

./venv/bin/pytest
.                                                                                                              [100%]
1 passed in 0.09s