A warning on setUpClass in our python tests
abartlet at samba.org
Tue Aug 31 00:45:18 UTC 2021
I wanted to use setUpClass() to create once a user account for some
tests (user_account_control.py), to avoid making a user over and over
However it is important to note that unless the test is under
python/samba/tests and loaded with planpythontestsutie any exceptions
raised in the setUpClass() are not caught.
The result is that ALL THE TESTS ARE SILENTLY SKIPPED.
Not ideal. Thankfully we don't do this, but there is a real risk that
we might have a testsuite that silently vanishes. The official docs
don't mention this here:
Hoever there is this note here:
which indicates that a _ErrorHolder object is created. We might need
to find a way to locate that if we don't just move away from tests as
Others have seen this (trying to skip):
Their monkey-patch looks horrible:
But vaugely mention that _Error
Medium term it would be really good if, source4/dsdb/tests/python was
moved to python/samba/tests/dsdb and the invocations changes to use
planpythontestsuite, as it works there.
(BTW, with Python 3.8 we gain addClassCleanup() which would be
TLDR: avoid setUpClass unless using planpythontestuite.
Andrew Bartlett (he/him) https://samba.org/~abartlet/
Samba Team Member (since 2001) https://samba.org
Samba Team Lead, Catalyst IT https://catalyst.net.nz/services/samba
Samba Development and Support, Catalyst IT - Expert Open Source
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4431 bytes
Desc: not available
More information about the samba-technical