2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

Enable testloops for nosetests

Ensure nosetests sees all tests in the tests[] tuples. This requires
some name changes because nosetests thinks all function names containing
"test" are tests. (A "not a test" docorator would be an alternative, but
that would require some try/except magic to avoid a dependency on nose.)

To avoid nosetests thinks the functions are a test,
- rename setup_all_tests() to setup_all_loops()
- rename regex_test() to _regex_test() (in test-regex_matches.py)

Also add the module_name as parameter to setup_all_loops and always run
it (not only if __name__ == '__main__').

Known issue: nosetests errors out with
    ValueError: no such test method in <class ...>: stub_test
when trying to run a single test generated out of tests[].
(debugging hint: stub_test is the name used in setup_test_loop().)
But that's still an improvement over not seeing those tests at all ;-)


Acked-by: Steve Beattie <steve@nxnw.org> for trunk and 2.9.
This commit is contained in:
Christian Boltz
2015-04-22 22:01:34 +02:00
parent 47a811f2f5
commit 682e23e1cd
4 changed files with 10 additions and 11 deletions

View File

@@ -10,7 +10,7 @@
# ------------------------------------------------------------------
import unittest
from common_test import AATest, setup_all_tests
from common_test import AATest, setup_all_loops
import os
import shutil
import tempfile
@@ -536,6 +536,6 @@ class AaTestInvalid_serialize_parse_profile_start(AATest):
serialize_parse_profile_start(line, 'somefile', 1, profile, hat, prof_data_profile, prof_data_external, True)
setup_all_loops(__name__)
if __name__ == '__main__':
setup_all_tests()
unittest.main(verbosity=2)