2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 14:25:52 +00:00

utils: fix pyflakes issues with test-severity

The recent re-work of the severity.db tests were not verified to
pyflakes clean. All but one of pyflakes co are of marginal impact
(assigning to a variable that isn't later referenced); however, one
legitimate issue it detected is that I inadvertently created two test
cases with the same method name, so only one test case would actually
be used.

The following patch fixes the issues.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
This commit is contained in:
Steve Beattie
2014-11-13 10:58:50 -08:00
parent 4dd956461b
commit 1a9505a4ef

View File

@@ -144,60 +144,60 @@ class SeverityDBTest(unittest.TestCase):
return self.sev_db
def test_simple_db(self):
db = self._test_db('''
self._test_db('''
CAP_LEASE 8
/etc/passwd* 4 8 0
''')
def test_cap_val_max_range(self):
db = self._test_db("CAP_LEASE 10\n")
self._test_db("CAP_LEASE 10\n")
def test_cap_val_min_range(self):
db = self._test_db("CAP_LEASE 0\n")
self._test_db("CAP_LEASE 0\n")
def test_cap_val_out_of_range(self):
def test_cap_val_out_of_range_1(self):
with self.assertRaises(AppArmorException):
db = self._test_db("CAP_LEASE 18\n")
self._test_db("CAP_LEASE 18\n")
def test_cap_val_out_of_range(self):
def test_cap_val_out_of_range_2(self):
with self.assertRaises(AppArmorException):
db = self._test_db("CAP_LEASE -1\n")
self._test_db("CAP_LEASE -1\n")
def test_path_insufficient_vals(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd* 0 4\n")
self._test_db("/etc/passwd* 0 4\n")
def test_path_too_many_vals(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd* 0 4 5 6\n")
self._test_db("/etc/passwd* 0 4 5 6\n")
def test_path_outside_range_1(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd* -2 4 6\n")
self._test_db("/etc/passwd* -2 4 6\n")
def test_path_outside_range_2(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd* 12 4 6\n")
self._test_db("/etc/passwd* 12 4 6\n")
def test_path_outside_range_3(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd* 2 -4 6\n")
self._test_db("/etc/passwd* 2 -4 6\n")
def test_path_outside_range_4(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd 2 14 6\n")
self._test_db("/etc/passwd 2 14 6\n")
def test_path_outside_range_5(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd 2 4 -12\n")
self._test_db("/etc/passwd 2 4 -12\n")
def test_path_outside_range_6(self):
with self.assertRaises(AppArmorException):
db = self._test_db("/etc/passwd 2 4 4294967297\n")
self._test_db("/etc/passwd 2 4 4294967297\n")
def test_garbage_line(self):
with self.assertRaises(AppArmorException):
db = self._test_db("garbage line\n")
self._test_db("garbage line\n")
def test_invalid_db(self):
self.assertRaises(AppArmorException, severity.Severity, 'severity_broken.db')