[test] Avoid error logging to print noisy output during tests
pandafy opened this issue · 0 comments
pandafy commented
The test suite logs error to the console which is not ideal. We should capture these logs like we did in other modules.
$ ./runtests.py
Found 143 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
................Failed to perform update topology admin action on <Topology: TestNetwork - NetJSON NetworkGraph>: TopologyRetrievalError
See error log for more information
..................................................................................Failed to perform add on <Node: 192.168.0.1>: IntegrityError
See error log for more information
................................/home/pandafy/openwisp/venv-network-topology/lib/python3.8/site-packages/django/db/models/fields/__init__.py:1409: RuntimeWarning: DateTimeField Ca.validity_start received a naive datetime (2022-02-02 00:00:00) while time zone support is active.
warnings.warn("DateTimeField %s received a naive datetime (%s)"
/home/pandafy/openwisp/venv-network-topology/lib/python3.8/site-packages/django/db/models/fields/__init__.py:1409: RuntimeWarning: DateTimeField Cert.validity_start received a naive datetime (2022-02-02 00:00:00) while time zone support is active.
warnings.warn("DateTimeField %s received a naive datetime (%s)"
........
Checkout the following functions:
- https://github.com/openwisp/openwisp-utils#openwisp_utilstestscapture_stdout
- https://github.com/openwisp/openwisp-utils#openwisp_utilstestscapture_stderr
- https://github.com/openwisp/openwisp-utils#openwisp_utilstestscapture_any_output
Take reference from openwisp/openwisp-controller#366