Skip to content

Commit

Permalink
[thermalctld] Report unit test coverage (sonic-net#141)
Browse files Browse the repository at this point in the history
Report Pytest unit test coverage for thermalctld.

Current coverage:

```
----------- coverage: platform linux, python 3.7.3-final-0 -----------
Name                  Stmts   Miss  Cover
-----------------------------------------
scripts/thermalctld     424    113    73%
Coverage HTML written to dir htmlcov
Coverage XML written to file coverage.xml
```

- Also add check to import 'mock' from the 'unittest' package if running with Python 3
  • Loading branch information
jleveque authored Jan 22, 2021
1 parent ad0a5ad commit d7b9284
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions sonic-thermalctld/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[pytest]
filterwarnings =
ignore::DeprecationWarning
addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml
3 changes: 2 additions & 1 deletion sonic-thermalctld/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
'wheel'
],
tests_require=[
'mock>=2.0.0; python_version < "3.3"',
'pytest',
'mock>=2.0.0'
'pytest-cov'
],
classifiers=[
'Development Status :: 4 - Beta',
Expand Down
6 changes: 5 additions & 1 deletion sonic-thermalctld/tests/test_thermalctld.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import sys
from imp import load_source

from mock import Mock, MagicMock, patch
# TODO: Clean this up once we no longer need to support Python 2
if sys.version_info.major == 3:
from unittest.mock import Mock, MagicMock, patch
else:
from mock import Mock, MagicMock, patch
from sonic_py_common import daemon_base

from .mock_platform import MockChassis, MockFan, MockThermal
Expand Down

0 comments on commit d7b9284

Please sign in to comment.