On 2015-11-29 22:34:43, Christian Boltz wrote:
> Hello,
> 
> $subject.
> 
> 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.
> 
> 
> I propose this patch for trunk and 2.10.
> (Nothing to fix in 2.9 - it doesn't have this test.)
> 
> 
> 
> [ 22-adjust-test-aa-for-py2.diff ]
> 
> === modified file ./utils/test/test-aa.py
> --- utils/test/test-aa.py       2015-11-19 17:42:26.329879090 +0100
> +++ utils/test/test-aa.py       2015-11-29 21:44:36.968433594 +0100
> @@ -75,7 +75,7 @@
>  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')),

This syntax for unicode strings was introduced for Python 3 in version
3.3:

  https://www.python.org/dev/peps/pep-0414/

That means that this change will prevent the test from being run on
python3.2 in Ubuntu 12.04:

  $ python3.2 -c "print(u'test')"
    File "<string>", line 1
      print(u'test')
                  ^
    SyntaxError: invalid syntax

That may affect Steve's automated tests so I'm cc'ing him so that he can NAK,
if needed.

If he's good with the change, then...

  Acked-by: Tyler Hicks <tyhi...@canonical.com>

... for both branches.

Tyler

>          ('foo bar',                (None,                   None)),
>      ]
>      def _run_test(self, params, expected):
> @@ -89,16 +89,16 @@
>              
> 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 = [
> 
> 
> 
> Regards,
> 
> Christian Boltz
> -- 
> > Kann ich auf einen Bootloader (lilo oder grub) verzichten,
> > falls auf der Festplatte nur 2 Partitionen sind
> Klar kannst du. Vorausgesetzt du kannst auch darauf verzichten
> das Betriebssystem zu booten.
> [> Wolfgang Erlenkötter und Hartmut Meyer in suse-linux]
> 
> 
> -- 
> AppArmor mailing list
> AppArmor@lists.ubuntu.com
> Modify settings or unsubscribe at: 
> https://lists.ubuntu.com/mailman/listinfo/apparmor

Attachment: signature.asc
Description: Digital signature

-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to