[apparmor] [patch] use in-tree python modules in all tests

Christian Boltz apparmor at cboltz.de
Tue Jul 22 18:37:27 UTC 2014


Hello,

Am Montag, 21. Juli 2014 schrieb Steve Beattie:
> On Mon, Jul 14, 2014 at 10:19:52PM +0200, Christian Boltz wrote:
> > this patch changes several utils/test/*.py to use the in-tree
> > python modules.
> 
> Sorry, but I don't like this patch. The reason is that I don't want
> to hardcode the local path into the tests; I'd like to be able to
> use the tests to verify an installation of the utilities in addition
> to checking during builds and development, and want to avoid making
> it unnecessarily difficult to do so 

Good argument (and just some hours after the timeout deadline - your 
luck that I didn't commit it yet ;-)

> (and yes, I'm aware a few of the
> test scripts already append to the search path). 

Basically that was the reason why I wanted to add it to the remaining 
tests.

> We currently don't
> have a 'make check USE_SYSTEM=1' option yet to make it easy do so,
> but I'd like to see one.
>
> If the runtests-py* scripts are breaking because of this and aren't
> already doing so, they should be setting PYTHONPATH explicitly.

Sounds like a good idea.

Updated patch:


Set PYTHONPATH=.. in runtests-py3.sh to make sure the tests use the in-
tree python modules.

Also remove "sys.path.append('../')" (and now-unused "import sys") from 
all tests that contain it for consistency and to make testing with the 
installed modules possible (even if we don't have a USE_SYSTEM option 
yet).


=== modified file 'utils/test/aa_test.py'
--- utils/test/aa_test.py       2014-02-13 19:32:36 +0000
+++ utils/test/aa_test.py       2014-07-22 18:27:32 +0000
@@ -12,9 +12,7 @@
 #
 # 
----------------------------------------------------------------------
 import unittest
-import sys
 
-sys.path.append('../')
 import apparmor.aa
 import apparmor.logparser
 

=== modified file 'utils/test/common_test.py'
--- utils/test/common_test.py   2014-02-13 00:59:27 +0000
+++ utils/test/common_test.py   2014-07-22 18:27:47 +0000
@@ -13,9 +13,7 @@
 # 
----------------------------------------------------------------------
 import unittest
 import re
-import sys
 
-sys.path.append('../')
 import apparmor.common
 import apparmor.config
 

=== modified file 'utils/test/config_test.py'
--- utils/test/config_test.py   2014-02-28 10:39:00 +0000
+++ utils/test/config_test.py   2014-07-22 18:27:53 +0000
@@ -12,9 +12,7 @@
 #
 # 
----------------------------------------------------------------------
 import unittest
-import sys
 
-sys.path.append('../')
 import apparmor.config as config
 
 class Test(unittest.TestCase):
=== modified file 'utils/test/runtests-py3.sh'
--- utils/test/runtests-py3.sh  2014-07-17 13:47:18 +0000
+++ utils/test/runtests-py3.sh  2014-07-22 18:25:19 +0000
@@ -11,6 +11,8 @@
 
 test -z "$RUNTESTS_PY__PYTHON_BINARY" && 
RUNTESTS_PY__PYTHON_BINARY=python3
 
+export PYTHONPATH=.. 
+
 failed=""
 for file in *.py ; do 
        echo "running $file..." 

=== modified file 'utils/test/severity_test.py'
--- utils/test/severity_test.py 2014-07-17 13:59:57 +0000
+++ utils/test/severity_test.py 2014-07-22 18:28:12 +0000
@@ -13,11 +13,8 @@
 # 
----------------------------------------------------------------------
 import os
 import shutil
-import sys
 import unittest
 
-sys.path.append('../')
-
 import apparmor.severity as severity
 from apparmor.common import AppArmorException
 


Regards,

Christian Boltz
-- 
Personal Firewall bietet Schutz vor klassischen Angriffen -- Was hat
man unter "klassischen Angriffen" zu verstehen? -- Seltsam angezogene
Fremde rollen ein riesiges Holzpferd vor Deine Haustür...
[Johannes Sackmann, Heiko Schlenker, Ralf Bürckner]




More information about the AppArmor mailing list