mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 16:35:02 +01:00

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.
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
#! /usr/bin/env python
|
|
# ------------------------------------------------------------------
|
|
#
|
|
# Copyright (C) 2015 Christian Boltz <apparmor@cboltz.de>
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of version 2 of the GNU General Public
|
|
# License published by the Free Software Foundation.
|
|
#
|
|
# ------------------------------------------------------------------
|
|
|
|
import unittest
|
|
from common_test import AATest, setup_all_loops
|
|
|
|
class TestFoo(AATest):
|
|
tests = [
|
|
(0, 0 ),
|
|
(42, 42),
|
|
]
|
|
|
|
def _run_test(self, params, expected):
|
|
self.assertEqual(params, expected)
|
|
|
|
class TestBar(AATest):
|
|
tests = [
|
|
('a', 'foo'),
|
|
('b', 'bar'),
|
|
('c', 'baz'),
|
|
]
|
|
|
|
def _run_test(self, params, expected):
|
|
self.assertNotEqual(params, expected)
|
|
|
|
def testAdditionalBarTest(self):
|
|
self.assertEqual(1, 1)
|
|
|
|
class TestBaz(AATest):
|
|
def test_Baz_only_one_test(self):
|
|
self.assertEqual("baz", "baz")
|
|
|
|
|
|
|
|
setup_all_loops(__name__)
|
|
if __name__ == '__main__':
|
|
unittest.main(verbosity=2)
|