This patch moves the assignment of the regex function into the unittest setUp() function rather than at script load time. If for some reason the python utils library does not define the relevant function, without this patch the script fails entirely; with it, each individual test class that depends on the missing regex will fail each test case.
Signed-off-by: Steve Beattie <[email protected]> --- utils/test/test-regex_matches.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) Index: b/utils/test/test-regex_matches.py =================================================================== --- a/utils/test/test-regex_matches.py +++ b/utils/test/test-regex_matches.py @@ -184,7 +184,8 @@ def setup_regex_tests(test_class): class AARegexCapability(unittest.TestCase): '''Tests for RE_PROFILE_CAP''' - regex = aa.RE_PROFILE_CAP + def setUp(self): + self.regex = aa.RE_PROFILE_CAP tests = [ (' capability net_raw,', (None, None, 'net_raw', None)), @@ -198,7 +199,8 @@ class AARegexCapability(unittest.TestCas class AARegexPath(unittest.TestCase): '''Tests for RE_PROFILE_PATH_ENTRY''' - regex = aa.RE_PROFILE_PATH_ENTRY + def setUp(self): + self.regex = aa.RE_PROFILE_PATH_ENTRY tests = [ (' /tmp/foo r,', @@ -216,7 +218,8 @@ class AARegexPath(unittest.TestCase): class AARegexBareFile(unittest.TestCase): '''Tests for RE_PROFILE_BARE_FILE_ENTRY''' - regex = aa.RE_PROFILE_BARE_FILE_ENTRY + def setUp(self): + self.regex = aa.RE_PROFILE_BARE_FILE_ENTRY tests = [ (' file,', (None, None, None, None)), @@ -233,7 +236,8 @@ class AARegexBareFile(unittest.TestCase) class AARegexDbus(unittest.TestCase): '''Tests for RE_PROFILE_DBUS''' - regex = aa.RE_PROFILE_DBUS + def setUp(self): + self.regex = aa.RE_PROFILE_DBUS tests = [ (' dbus,', (None, None, 'dbus,', None)), @@ -248,7 +252,8 @@ class AARegexDbus(unittest.TestCase): class AARegexMount(unittest.TestCase): '''Tests for RE_PROFILE_MOUNT''' - regex = aa.RE_PROFILE_MOUNT + def setUp(self): + self.regex = aa.RE_PROFILE_MOUNT tests = [ (' mount,', (None, None, 'mount,', 'mount', None, None)), @@ -271,7 +276,8 @@ class AARegexMount(unittest.TestCase): class AARegexSignal(unittest.TestCase): '''Tests for RE_PROFILE_SIGNAL''' - regex = aa.RE_PROFILE_SIGNAL + def setUp(self): + self.regex = aa.RE_PROFILE_SIGNAL tests = [ (' signal,', (None, None, 'signal,', None)), @@ -296,7 +302,8 @@ class AARegexSignal(unittest.TestCase): class AARegexPtrace(unittest.TestCase): '''Tests for RE_PROFILE_PTRACE''' - regex = aa.RE_PROFILE_PTRACE + def setUp(self): + self.regex = aa.RE_PROFILE_PTRACE tests = [ (' ptrace,', (None, None, 'ptrace,', None)), @@ -317,7 +324,8 @@ class AARegexPtrace(unittest.TestCase): class AARegexPivotRoot(unittest.TestCase): '''Tests for RE_PROFILE_PIVOT_ROOT''' - regex = aa.RE_PROFILE_PIVOT_ROOT + def setUp(self): + self.regex = aa.RE_PROFILE_PIVOT_ROOT tests = [ (' pivot_root,', (None, None, 'pivot_root,', None)), -- AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
