From 726fa53eebe601c8c439e5ee574611af97bceb25 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Thu, 17 Dec 2015 23:44:18 +0100 Subject: [PATCH] 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 for trunk and 2.10. --- utils/test/test-aa.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/test/test-aa.py b/utils/test/test-aa.py index 8cd3cbb83..b5e662b4c 100644 --- a/utils/test/test-aa.py +++ b/utils/test/test-aa.py @@ -75,7 +75,7 @@ class AaTest_check_for_apparmor(AaTestWithTempdir): class AaTest_create_new_profile(AATest): tests = [ # 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)), ] 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'][program]['mode'], {'r', '::r'} ) 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: 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'].keys(), {program} ) + self.assertEqual(set(profile[program][program]['allow']['path'].keys()), {program} ) 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: - 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): tests = [