From 420f81eacdc7fa35ca6f213ce0707e183b1206d1 Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Mon, 24 Jan 2005 17:26:56 +0000
Subject: [PATCH] This script runs unittests presents in
 $(instance_home)/tests. It can be called from the ZMI (actually, with a
 os.popen() call) or directly from the shell. It does not require framework.py
 or anything outside of ERP5Type/tests to run UnitTests that are in another
 directory. Directories containing scripts just have to be added to sys.path.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2277 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/tests/runUnitTest.py | 41 +++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100755 product/ERP5Type/tests/runUnitTest.py

diff --git a/product/ERP5Type/tests/runUnitTest.py b/product/ERP5Type/tests/runUnitTest.py
new file mode 100755
index 0000000000..9ebe5ca873
--- /dev/null
+++ b/product/ERP5Type/tests/runUnitTest.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+#
+# Runs the tests passed on the command line
+#
+import os, sys
+
+def getUnitTestFile() :
+  return os.path.abspath(__file__)
+
+# site specific variables
+instance_home = '/home/%s/zope' % os.environ['USER']
+software_home = '/usr/lib/zope/lib/python'
+tests_home = os.path.join(instance_home, 'tests')
+tests_framework_home = os.path.dirname(os.path.abspath(__file__))
+
+if '__INSTANCE_HOME' not in globals().keys() :
+  __INSTANCE_HOME = instance_home
+
+def runUnitTestList(test_list) :
+  os.environ['INSTANCE_HOME'] = instance_home
+  os.environ['SOFTWARE_HOME'] = software_home
+  os.environ['COPY_OF_INSTANCE_HOME'] = instance_home
+  os.environ['COPY_OF_SOFTWARE_HOME'] = software_home
+
+  execfile(os.path.join(tests_framework_home, 'framework.py')) 
+
+  import unittest
+  TestRunner = unittest.TextTestRunner
+  suite = unittest.TestSuite()
+
+  os.chdir(tests_home)
+
+  for test in test_list:
+    m = __import__(test)
+    if hasattr(m, 'test_suite'):
+      suite.addTest(m.test_suite())
+
+  TestRunner().run(suite)
+
+if __name__ == '__main__' :
+  runUnitTestList(test_list=sys.argv[1:])
-- 
2.30.9