apparmor/utils/test/test-example.py
Christian Boltz 1c4a885e27 Switch utils to python3
As discussed a while ago, switch the utils (including their tests) to
use python3 by default. While on it, drop usage of "env" to always get
the system python3 instead of a random one that happens to live
somewhere in $PATH.

In practise, this patch doesn't change much - AFAIK openSUSE, Debian and
Ubuntu already patch aa-* to use python3.

Also add a note to README to officially deprecate Python 2.x.
(I won't break Python 2.x support intentionally - unless some future
change gives me a very good reason to finally drop Python 2.x support.)



Acked-by: Seth Arnold <seth.arnold@canonical.com>
(since 2016-08-23, but the commit had to wait for the FileRule series
 because it touches test-file.py)
2016-10-01 20:57:09 +02:00

53 lines
1.3 KiB
Python

#! /usr/bin/python3
# ------------------------------------------------------------------
#
# 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 AASetup(self):
# called by setUp() - use AASetup() to avoid the need for using super(...)
pass
def AATeardown(self):
# called by tearDown() - use AATeardown() to avoid the need for using super(...)
pass
def test_Baz_only_one_test(self):
self.assertEqual("baz", "baz")
setup_all_loops(__name__)
if __name__ == '__main__':
unittest.main(verbosity=2)