Warn if dependencies can't be tested
This commit is contained in:
parent
6054a35c5a
commit
33e669b3fa
@ -21,6 +21,10 @@ sys.path[0] = os.getcwd()
|
||||
# find all of the planet test modules
|
||||
modules = map(fullmodname, glob.glob(os.path.join('tests', 'test_*.py')))
|
||||
|
||||
# enable warnings
|
||||
import planet
|
||||
planet.getLogger("WARNING")
|
||||
|
||||
# load all of the tests into a suite
|
||||
suite = unittest.TestLoader().loadTestsFromNames(modules)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unittest, os, shutil
|
||||
from planet import config, splice
|
||||
from planet import config, splice, logger
|
||||
from xml.dom import minidom
|
||||
|
||||
workdir = 'tests/work/apply'
|
||||
@ -62,3 +62,26 @@ class ApplyTest(unittest.TestCase):
|
||||
self.assertTrue(html.find('<h1>test planet</h1>')>=0)
|
||||
self.assertTrue(html.find(
|
||||
'<h4><a href="http://example.com/2">Venus</a></h4>')>=0)
|
||||
|
||||
try:
|
||||
import libxml2
|
||||
except ImportError:
|
||||
|
||||
try:
|
||||
import win32pipe
|
||||
(stdin,stdout) = win32pipe.popen4('xsltproc -V', 't')
|
||||
stdin.close()
|
||||
stdout.read()
|
||||
try:
|
||||
exitcode = stdout.close()
|
||||
except IOError:
|
||||
exitcode = -1
|
||||
except:
|
||||
import commands
|
||||
(exitstatus,output) = commands.getstatusoutput('xsltproc -V')
|
||||
exitcode = ((exitstatus>>8) & 0xFF)
|
||||
|
||||
if exitcode:
|
||||
logger.warn("xsltproc is not available => can't test XSLT templates")
|
||||
for method in dir(ApplyTest):
|
||||
if method.startswith('test_'): delattr(ApplyTest,method)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unittest, xml.dom.minidom
|
||||
from planet import shell, config
|
||||
from planet import shell, config, logger
|
||||
|
||||
class FilterTests(unittest.TestCase):
|
||||
|
||||
@ -80,12 +80,10 @@ try:
|
||||
from subprocess import Popen, PIPE
|
||||
sed=Popen(['sed','--version'],stdout=PIPE,stderr=PIPE)
|
||||
sed.communicate()
|
||||
if sed.returncode != 0: raise Exception
|
||||
except Exception, expr:
|
||||
# sed is not available
|
||||
del FilterTests.test_stripAd_yahoo
|
||||
|
||||
if isinstance(expr, ImportError):
|
||||
# Popen is not available
|
||||
for method in dir(FilterTests):
|
||||
if method.startswith('test_'): delattr(FilterTests,method)
|
||||
if sed.returncode != 0:
|
||||
logger.warn("sed is not available => can't test stripAd_yahoo")
|
||||
del FilterTests.test_stripAd_yahoo
|
||||
except ImportError:
|
||||
logger.warn("Popen is not available => can't test filters")
|
||||
for method in dir(FilterTests):
|
||||
if method.startswith('test_'): delattr(FilterTests,method)
|
||||
|
@ -3,7 +3,7 @@
|
||||
import unittest, os, shutil
|
||||
from planet.foaf import foaf2config
|
||||
from ConfigParser import ConfigParser
|
||||
from planet import config
|
||||
from planet import config, logger
|
||||
|
||||
workdir = 'tests/work/config/cache'
|
||||
|
||||
@ -119,6 +119,7 @@ class FoafTest(unittest.TestCase):
|
||||
try:
|
||||
import RDF
|
||||
except:
|
||||
logger.warn("Redland RDF is not available => can't test FOAF reading lists")
|
||||
for key in FoafTest.__dict__.keys():
|
||||
if key.startswith('test_'): delattr(FoafTest, key)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user