On 01/23/2014 03:48 AM, Mark Wu wrote:
On 01/23/2014 11:29 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>

$ sudo ./run_tests.sh test_rest
Failed to import plugin plugins.sample.Drawings

That's because plugin is not in src/

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
---
  tests/run_tests.sh.in | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/run_tests.sh.in b/tests/run_tests.sh.in
index 2baf66d..038e8fa 100644
--- a/tests/run_tests.sh.in
+++ b/tests/run_tests.sh.in
@@ -31,7 +31,7 @@ else
  fi

  if [ "$HAVE_UNITTEST" != "yes" -o "$PYTHON_VER" == "2.6" ]; then
-    PYTHONPATH=../src:./ unit2 $ARGS
+    PYTHONPATH=../src:./:../ unit2 $ARGS
  else
-    PYTHONPATH=../src python -m unittest $ARGS
+    PYTHONPATH=../src:../ python -m unittest $ARGS
  fi
We don't put any test cases for plugins in test_rest.  Instead,  we put them in test_plugin.  the python path
has been mangled there.


Despite the test cases for plugins are in test_plugin, all tests use the same cherrypy server (and configuration) to run the tests.
And when the cherrypy server starts up it tries to load all plugins enabled because that we got an error while running other tests (except the test_plugin)


.[23/Jan/2014:17:27:45] ENGINE Waiting for child threads to terminate...
[23/Jan/2014:17:27:45] ENGINE Waiting for thread MainThread.
...........Failed to import plugin plugins.sample.Drawings
[23/Jan/2014:17:27:46] ENGINE Bus STARTING
[23/Jan/2014:17:27:46] ENGINE Serving on 127.0.0.1:48919


Sheldon, as remembered by Mark you should remove the python path from test_plugin and keep it only in run_tests.sh.in script

diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index 42c87a9..607dd55 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -22,7 +22,6 @@
 
 import json
 import os
-import sys
 import unittest
 
 
@@ -32,7 +31,6 @@ from functools import partial
 import kimchi.mockmodel
 import kimchi.server
 import utils
-from kimchi import config
 
 
 test_server = None
@@ -48,7 +46,6 @@ def setUpModule():
     host = '127.0.0.1'
     port = utils.get_free_port('http')
     ssl_port = None
-    sys.path.append(config.get_prefix())
     test_server = utils.run_server(host, port, ssl_port, test_mode=True,
                                    model=model)



_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel