running test.py with instance_home products.
Has anyone found a reasonable strategy for using Zope's test.py to test products that are installed outside the Zope software home? I try running it from the software home and using the --dir option to point it to where my product is, but it tells me it can't find any tests. - C
Chris McDonough wrote:
Has anyone found a reasonable strategy for using Zope's test.py to test products that are installed outside the Zope software home? I try running it from the software home and using the --dir option to point it to where my product is, but it tells me it can't find any tests.
I think I run test.py (or somethign similar) from a shell script in which I set the PRODUCTS_PATH environment variable, as well as INSTACNE_HOME and SOFTWARE_HOME. How shoudl I be looking to do that in Zope 2.7? ;-) cheers, Chris
Chris Withers wrote:
Chris McDonough wrote:
Has anyone found a reasonable strategy for using Zope's test.py to test products that are installed outside the Zope software home? I try running it from the software home and using the --dir option to point it to where my product is, but it tells me it can't find any tests.
I think I run test.py (or somethign similar) from a shell script in which I set the PRODUCTS_PATH environment variable, as well as INSTACNE_HOME and SOFTWARE_HOME.
How shoudl I be looking to do that in Zope 2.7? ;-)
test.py needs to grow a --config-file option; if passed in, it should do the Zope.startup() dance with the passed file, e.g.:: ------------------------------- 8< ---------------------------------- import Zope import App.config from Zope.Startup import handlers, options def installConfigFileForTesting(config_file) opts = options.ZopeOptions() opts.realize(args=('-C', config_file)) handlers.handleConfig(opts.configroot, opts.confighandlers) App.config.setConfiguration(opts.configroot) Zope.startup() ------------------------------- 8< ---------------------------------- Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
Or use this patch http://zope.org/Collectors/Zope/1233 that finds the config file via the environment variable ZOPE_CONFIG during a normal import Zope; app=Zope.app() dance. -EAD On Mar 2, 2004, at 10:52 AM, Tres Seaver wrote:
Chris Withers wrote:
Chris McDonough wrote:
Has anyone found a reasonable strategy for using Zope's test.py to test products that are installed outside the Zope software home? I try running it from the software home and using the --dir option to point it to where my product is, but it tells me it can't find any tests. I think I run test.py (or somethign similar) from a shell script in which I set the PRODUCTS_PATH environment variable, as well as INSTACNE_HOME and SOFTWARE_HOME. How shoudl I be looking to do that in Zope 2.7? ;-)
test.py needs to grow a --config-file option; if passed in, it should do the Zope.startup() dance with the passed file, e.g.::
------------------------------- 8< ---------------------------------- import Zope import App.config from Zope.Startup import handlers, options
def installConfigFileForTesting(config_file) opts = options.ZopeOptions() opts.realize(args=('-C', config_file)) handlers.handleConfig(opts.configroot, opts.confighandlers) App.config.setConfiguration(opts.configroot) Zope.startup() ------------------------------- 8< ----------------------------------
Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Chris McDonough wrote at 2004-3-1 21:17 -0500:
Has anyone found a reasonable strategy for using Zope's test.py to test products that are installed outside the Zope software home? I try running it from the software home and using the --dir option to point it to where my product is, but it tells me it can't find any tests.
I do regularly. I use "... test.py --lib path_to_myProduct ..." -- Dieter
On Tue, 2004-03-02 at 14:27, Dieter Maurer wrote:
Has anyone found a reasonable strategy for using Zope's test.py to test products that are installed outside the Zope software home? I try running it from the software home and using the --dir option to point it to where my product is, but it tells me it can't find any tests.
I do regularly.
I use "... test.py --lib path_to_myProduct ..."
That didn't work (even using --libdir), it still couldn't find any tests and I didn't try to debug. I ended up just adding the following script as "all.py" to my Product's test dir and call it via "zopectl run Products/MyProduct/tests/all.py". It assumes all of the test module names start with "test" and that they're located with in the "tests" subdirectory of the product. product_name = "MyProduct" from unittest import TextTestRunner, findTestCases, TestSuite from Zope.Startup.datatypes import importable_name from Products.Websafe.tests import testQuotaTool from Products.Websafe.tests import testPropertiesTool import os import sys here = os.path.dirname(sys.argv[0]) test_names = os.listdir(here) test_modules = [] for name in test_names: if name.startswith('test') and not name.endswith('pyc'): name, ext = os.path.splitext(name) test_modules.append(importable_name('Products.%s.tests.%s' %(product_name, name))) suite = TestSuite() for module in test_modules: suite.addTest(findTestCases(module)) runner = TextTestRunner(verbosity=2) runner.run(suite)
Dieter Maurer wrote:
Chris McDonough wrote at 2004-3-1 21:17 -0500:
Has anyone found a reasonable strategy for using Zope's test.py to test products that are installed outside the Zope software home? I try running it from the software home and using the --dir option to point it to where my product is, but it tells me it can't find any tests.
I do regularly.
I use "... test.py --lib path_to_myProduct ..."
Dieter, are you installing your products under $SOFTWARE_HOME/Products? Because otherwise I don't see anything in test.py which invokes the FindHomes machinery to stitch $INSTANCE_HOME/Products into the __path__ of the Products module. Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
participants (5)
-
Chris McDonough -
Chris Withers -
Dieter Maurer -
Erik A.Dahl -
Tres Seaver