mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 14:25:52 +00:00
Adjust test-aa.py for python2
This means: - expect unicode (instead of str) when reading from a file in py2 - convert keys() result to a set to avoid test failures because of dict_keys type After this change, all tests work for both py2 and py3. Acked-by: Tyler Hicks <tyhicks@canonical.com> for trunk and 2.10.
This commit is contained in:
@@ -75,7 +75,7 @@ class AaTest_check_for_apparmor(AaTestWithTempdir):
|
|||||||
class AaTest_create_new_profile(AATest):
|
class AaTest_create_new_profile(AATest):
|
||||||
tests = [
|
tests = [
|
||||||
# file content expected interpreter expected abstraction (besides 'base')
|
# file content expected interpreter expected abstraction (besides 'base')
|
||||||
('#!/bin/bash\ntrue', ('/bin/bash', 'abstractions/bash')),
|
('#!/bin/bash\ntrue', (u'/bin/bash', 'abstractions/bash')),
|
||||||
('foo bar', (None, None)),
|
('foo bar', (None, None)),
|
||||||
]
|
]
|
||||||
def _run_test(self, params, expected):
|
def _run_test(self, params, expected):
|
||||||
@@ -89,16 +89,16 @@ class AaTest_create_new_profile(AATest):
|
|||||||
self.assertEqual(profile[program][program]['allow']['path'][exp_interpreter_path]['audit'], set() )
|
self.assertEqual(profile[program][program]['allow']['path'][exp_interpreter_path]['audit'], set() )
|
||||||
self.assertEqual(profile[program][program]['allow']['path'][program]['mode'], {'r', '::r'} )
|
self.assertEqual(profile[program][program]['allow']['path'][program]['mode'], {'r', '::r'} )
|
||||||
self.assertEqual(profile[program][program]['allow']['path'][program]['audit'], set() )
|
self.assertEqual(profile[program][program]['allow']['path'][program]['audit'], set() )
|
||||||
self.assertEqual(profile[program][program]['allow']['path'].keys(), {exp_interpreter_path, program} )
|
self.assertEqual(set(profile[program][program]['allow']['path'].keys()), {program, exp_interpreter_path} )
|
||||||
else:
|
else:
|
||||||
self.assertEqual(profile[program][program]['allow']['path'][program]['mode'], {'r', '::r', 'm', '::m'} )
|
self.assertEqual(profile[program][program]['allow']['path'][program]['mode'], {'r', '::r', 'm', '::m'} )
|
||||||
self.assertEqual(profile[program][program]['allow']['path'][program]['audit'], set() )
|
self.assertEqual(profile[program][program]['allow']['path'][program]['audit'], set() )
|
||||||
self.assertEqual(profile[program][program]['allow']['path'].keys(), {program} )
|
self.assertEqual(set(profile[program][program]['allow']['path'].keys()), {program} )
|
||||||
|
|
||||||
if exp_abstraction:
|
if exp_abstraction:
|
||||||
self.assertEqual(profile[program][program]['include'].keys(), {exp_abstraction, 'abstractions/base'})
|
self.assertEqual(set(profile[program][program]['include'].keys()), {exp_abstraction, 'abstractions/base'})
|
||||||
else:
|
else:
|
||||||
self.assertEqual(profile[program][program]['include'].keys(), {'abstractions/base'})
|
self.assertEqual(set(profile[program][program]['include'].keys()), {'abstractions/base'})
|
||||||
|
|
||||||
class AaTest_get_interpreter_and_abstraction(AATest):
|
class AaTest_get_interpreter_and_abstraction(AATest):
|
||||||
tests = [
|
tests = [
|
||||||
|
Reference in New Issue
Block a user