Ok guys, this was just documented on our wiki. Please take note:
https://github.com/autotest/autotest/wiki/TestCodingStyle
Here goes the added text verbatim:
Sometimes, for a tiny feature inside the test suite, people import an
external, lesser known python library, on a very central and proeminent
part of the framework.
Please, don't do it. You are breaking other people's workflow and that
is bad.
The correct way of doing this is conditionally importing the library,
setting a top level variable that indicates whether the feature is
active in the system (that is, the library can be imported), and when
calling the specific feature, check the top level variable to see if the
feature could be found. If it couldn't, you fail the test, most probably
by throwing an autotest.client.shared.error.TestNAError.
So, instead of doing:
import platinumlib
...
platinumlib.destroy_all()
You will do:
PLATINUMLIB_ENABLED = True
try:
import platinumlib
except ImportError:
PLATINUMLIB_ENABLED = False
...
if not PLATINUMLIB_ENABLED:
raise error.TestNAError('Platinum lib is not installed. '
'You need to install the package '
'python-platinumlib for this test '
'to work.')
platinumlib.destroy_all()
Any patch that carelessly sticks external library imports in central
libraries of virt-test for optional features will be downright rejected.
Thanks for your attention,
Lucas
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel